• 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 #ifndef GRAPHICS_EFFECT_TONE_MAPPING_HELPER_H
16 #define GRAPHICS_EFFECT_TONE_MAPPING_HELPER_H
17 
18 #include "common/rs_vector2.h"
19 #include "common/rs_vector4.h"
20 #include "draw/color.h"
21 #include "ge_log.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 
26 constexpr float EFFECT_MAX_LUMINANCE = 2.0f;
27 
28 class GEToneMappingHelper {
29 public:
30     static Vector4f GetBrightnessMapping(float headroom, Vector4f& input);
31 
32     static float GetBrightnessMapping(float headroom, float input);
33 
34     static Drawing::Color4f GetBrightnessMapping(float brightness, Drawing::Color4f& input);
35 
NeedToneMapping(float supportHeadroom)36     static inline bool NeedToneMapping(float supportHeadroom)
37     {
38         return ROSEN_GNE(supportHeadroom, 0.0f) && ROSEN_LNE(supportHeadroom, EFFECT_MAX_LUMINANCE);
39     }
40 
41 private:
42     static bool CalcBezierResultY(
43         const Vector2f& start, const Vector2f& end, const Vector2f& control, float x, float& y);
44 };
45 } // Rosen
46 } // OHOS
47 #endif // GRAPHICS_EFFECT_TONE_MAPPING_HELPER_H