• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 
16 #ifndef RENDER_SERVICE_BASE_DISPLAY_ENGINE_RS_COLOR_TEMPERATURE_H
17 #define RENDER_SERVICE_BASE_DISPLAY_ENGINE_RS_COLOR_TEMPERATURE_H
18 
19 #include <cinttypes>
20 #include <functional>
21 #include <vector>
22 
23 #include "common/rs_macros.h"
24 #include "screen_manager/screen_types.h"
25 #ifndef ROSEN_CROSS_PLATFORM
26 #include <v1_0/cm_color_space.h>
27 #endif
28 
29 
30 namespace OHOS {
31 namespace Rosen {
32 #ifndef ROSEN_CROSS_PLATFORM
33 using namespace OHOS::HDI::Display::Graphic::Common::V1_0;
34 #endif
35 
36 class RSCctInterface {
37 public:
38     virtual ~RSCctInterface() = default;
39     virtual bool Init() = 0;
40     virtual void RegisterRefresh(std::function<void()>&&) = 0;
41     virtual void UpdateScreenStatus(ScreenId, ScreenPowerStatus) = 0;
42     virtual bool IsDimmingOn(ScreenId) = 0;
43     virtual void DimmingIncrease(ScreenId) = 0;
44     virtual std::vector<float> GetNewLinearCct(ScreenId) = 0;
45 #ifndef ROSEN_CROSS_PLATFORM
46     virtual std::vector<float> GetLayerLinearCct(ScreenId, const std::vector<uint8_t>&,
47         const CM_Matrix srcColorMatrix) = 0;
48 #endif
49 };
50 
51 class RSB_EXPORT RSColorTemperature {
52 public:
53     RSColorTemperature(const RSColorTemperature&) = delete;
54     RSColorTemperature& operator=(const RSColorTemperature&) = delete;
55     RSColorTemperature(RSColorTemperature&) = delete;
56     RSColorTemperature& operator=(RSColorTemperature&&) = delete;
57 
58     RSB_EXPORT static RSColorTemperature& Get();
59     RSB_EXPORT void Init();
60 
61     RSB_EXPORT void RegisterRefresh(std::function<void()>&& refreshFunc);
62     RSB_EXPORT void UpdateScreenStatus(ScreenId screenId, ScreenPowerStatus status);
63     RSB_EXPORT bool IsDimmingOn(ScreenId screenId);
64     RSB_EXPORT void DimmingIncrease(ScreenId screenId);
65     RSB_EXPORT std::vector<float> GetNewLinearCct(ScreenId screenId);
66 #ifndef ROSEN_CROSS_PLATFORM
67     RSB_EXPORT std::vector<float> GetLayerLinearCct(ScreenId, const std::vector<uint8_t>& metadata,
68         const CM_Matrix srcColorMatrix = CM_Matrix::MATRIX_P3);
69 #endif
70 
71 private:
72     RSColorTemperature() = default;
73     ~RSColorTemperature();
74 
75 #ifdef ROSEN_OHOS
76     bool LoadLibrary();
77     void CloseLibrary();
78 
79     bool initStatus_{false};
80     void *extLibHandle_{nullptr};
81     RSCctInterface* rSCctInterface_{nullptr};
82 
83     using CreatFunc = RSCctInterface*(*)();
84     using DestroyFunc = void(*)();
85 
86     CreatFunc create_{nullptr};
87     DestroyFunc destroy_{nullptr};
88 #endif
89 };
90 
91 } // Rosen
92 } // OHOS
93 
94 #endif // RENDER_SERVICE_BASE_DISPLAY_ENGINE_RS_COLOR_TEMPERATURE_H