1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_COLORSPACE_CONVERT_H 16 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_COLORSPACE_CONVERT_H 17 18 #include "colorspace_converter_display.h" 19 #include "draw/canvas.h" 20 #include "effect/color_filter.h" 21 #include "image/image.h" 22 #include "render/rs_image_base.h" 23 24 #include "screen_manager/screen_types.h" 25 26 #define HDIV HDI::Display::Graphic::Common::V1_0 27 28 namespace OHOS { 29 namespace Media { 30 class PixelMap; 31 } 32 namespace Rosen { 33 34 using DynamicRangeMode = enum { 35 HIGH = 0, 36 CONSTRAINT = 1, 37 STANDARD = 2, 38 }; 39 40 using VPEConvert = Media::VideoProcessingEngine::ColorSpaceConverterDisplay; 41 using VPEColorSpaceConvertDisplayHandle = Media::VideoProcessingEngine::ColorSpaceConvertDisplayHandle; 42 using VPEParameter = Media::VideoProcessingEngine::ColorSpaceConverterDisplayParameter; 43 using VPEColorSpaceConvertDisplayCreate = VPEColorSpaceConvertDisplayHandle *(*)(); 44 using VPEColorSpaceConvertDisplayDestroy = void(*)(VPEColorSpaceConvertDisplayHandle *); 45 46 struct ColorSpaceConvertDisplayHandleImpl { 47 std::shared_ptr<VPEConvert> obj; 48 }; 49 50 class RSB_EXPORT RSColorSpaceConvert { 51 public: 52 ~RSColorSpaceConvert(); 53 static RSColorSpaceConvert& Instance(); 54 55 bool ColorSpaceConvertor(std::shared_ptr<Drawing::ShaderEffect> inputShader, 56 const sptr<SurfaceBuffer>& surfaceBuffer, Drawing::Paint& paint, GraphicColorGamut targetColorSpace, 57 ScreenId screenId, uint32_t dynamicRangeMode); 58 bool SetColorSpaceConverterDisplayParameter(const sptr<SurfaceBuffer>& surfaceBuffer, VPEParameter& parameter, 59 GraphicColorGamut targetColorSpace, ScreenId screenId, uint32_t dynamicRangeMode); 60 bool ConvertColorGamutToSpaceInfo(const GraphicColorGamut& colorGamut, HDIV::CM_ColorSpaceInfo& colorSpaceInfo); 61 62 private: 63 RSColorSpaceConvert(); 64 std::shared_ptr<VPEConvert> colorSpaceConverterDisplay_ = nullptr; 65 VPEColorSpaceConvertDisplayCreate colorSpaceConvertDisplayCreate_ = nullptr; 66 VPEColorSpaceConvertDisplayDestroy colorSpaceConvertDisplayDestroy_ = nullptr; 67 VPEColorSpaceConvertDisplayHandle *colorSpaceConvertDisplayHandle_ = nullptr; 68 void *handle_ = nullptr; 69 }; 70 71 } // namespace Rosen 72 } // namespace OHOS 73 74 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_COLORSPACE_CONVERT_H