1 /* 2 * Copyright (c) 2023-2023 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 BRIGHTNESS_CALCULATION_CURVE_H 17 #define BRIGHTNESS_CALCULATION_CURVE_H 18 19 #include <cstdint> 20 #include <mutex> 21 #include <unordered_map> 22 #include <vector> 23 24 #include "brightness_base.h" 25 #include "config_parser.h" 26 27 namespace OHOS { 28 namespace DisplayPowerMgr { 29 class BrightnessCalculationCurve { 30 public: 31 BrightnessCalculationCurve() = default; 32 BrightnessCalculationCurve(const BrightnessCalculationCurve&) = delete; 33 BrightnessCalculationCurve& operator=(const BrightnessCalculationCurve&) = delete; 34 BrightnessCalculationCurve(BrightnessCalculationCurve&&) = delete; 35 BrightnessCalculationCurve& operator=(BrightnessCalculationCurve&&) = delete; 36 37 void InitParameters(); 38 float GetCurrentBrightness(float lux); 39 void UpdateCurveAmbientLux(float lux); 40 void UpdateCurrentUserId(int userId); 41 int GetDisplayIdWithDisplayMode(int displayMode); 42 int GetSensorIdWithDisplayMode(int displayMode); 43 int GetDisplayIdWithFoldstatus(int foldStatus); 44 int GetSensorIdWithFoldstatus(int foldStatus); 45 private: 46 static const uint32_t DEFAULT_DISPLAY_ID = 0; 47 static const uint32_t DEFAULT_SENSOR_ID = 5; 48 49 float GetBrightnessCurveLevel(std::vector<PointXy>& linePointsList, float lux); 50 51 Config mCurveConfig{}; 52 uint32_t mDisplayId {0}; 53 float mDefaultBrightness {100.0f}; 54 float mCurveAmbientLux {0.0f}; 55 int mCurrentUserId {0}; 56 ScreenConfig mScreenConfig{}; 57 }; 58 59 } // namespace DisplayPowerMgr 60 } // namespace OHOS 61 62 #endif // BRIGHTNESS_CALCULATION_CURVE_H 63 64