1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef COLOR_MANAGER_H 17 #define COLOR_MANAGER_H 18 19 #include <displaycolor/displaycolor.h> 20 21 #include "DisplaySceneInfo.h" 22 #include "ExynosDeviceModule.h" 23 #include "ExynosHwc3Types.h" 24 25 using namespace displaycolor; 26 class ExynosDisplay; 27 28 namespace gs101 { 29 30 class ExynosDeviceModule; 31 32 class ColorManager { 33 public: ColorManager(ExynosDisplay * display,ExynosDeviceModule * device)34 ColorManager(ExynosDisplay* display, ExynosDeviceModule* device) 35 : mExynosDisplay(display), mDevice(device) {} 36 getDisplaySceneInfo()37 DisplaySceneInfo& getDisplaySceneInfo() { return mDisplaySceneInfo; } 38 39 using GsInterfaceType = gs::ColorDrmBlobFactory::GsInterfaceType; getDisplayColorInterface()40 GsInterfaceType* getDisplayColorInterface() { return mDevice->getDisplayColorInterface(); } 41 42 int32_t getColorModes(uint32_t* outNumModes, int32_t* outModes); 43 int32_t setColorMode(int32_t mode); 44 int32_t getRenderIntents(int32_t mode, uint32_t* outNumIntents, int32_t* outIntents); 45 int32_t setColorModeWithRenderIntent(int32_t mode, int32_t intent); 46 int32_t setColorTransform(const float* matrix, int32_t hint); 47 48 /* Call getDppForLayer() only if hasDppForLayer() is true */ 49 bool hasDppForLayer(ExynosMPPSource* layer); 50 const GsInterfaceType::IDpp& getDppForLayer(ExynosMPPSource* layer); 51 int32_t getDppIndexForLayer(ExynosMPPSource* layer); 52 /* Check if layer's assigned plane id has changed, save the new planeId. 53 * call only if hasDppForLayer is true */ checkAndSaveLayerPlaneId(ExynosMPPSource * layer,uint32_t planeId)54 bool checkAndSaveLayerPlaneId(ExynosMPPSource* layer, uint32_t planeId) { 55 auto& info = getDisplaySceneInfo().layerDataMappingInfo[layer]; 56 bool change = info.planeId != planeId; 57 info.planeId = planeId; 58 return change; 59 } 60 61 const GsInterfaceType::IDqe& getDqe(); 62 63 int32_t updateColorConversionInfo(); 64 int32_t resetColorMappingInfo(ExynosMPPSource* mppSrc); 65 66 private: 67 int32_t setLayersColorData(); 68 69 ExynosDisplay* mExynosDisplay; 70 ExynosDeviceModule* mDevice; 71 DisplaySceneInfo mDisplaySceneInfo; 72 }; 73 74 } // namespace gs101 75 76 #endif // COLOR_MANAGER_H 77