1595d5899Sopenharmony_ci/* 2595d5899Sopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3595d5899Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4595d5899Sopenharmony_ci * you may not use this file except in compliance with the License. 5595d5899Sopenharmony_ci * You may obtain a copy of the License at 6595d5899Sopenharmony_ci * 7595d5899Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8595d5899Sopenharmony_ci * 9595d5899Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10595d5899Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11595d5899Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12595d5899Sopenharmony_ci * See the License for the specific language governing permissions and 13595d5899Sopenharmony_ci * limitations under the License. 14595d5899Sopenharmony_ci */ 15595d5899Sopenharmony_ci 16595d5899Sopenharmony_ci#ifndef BRIGHTNESS_CALCULATION_MANAGER_H 17595d5899Sopenharmony_ci#define BRIGHTNESS_CALCULATION_MANAGER_H 18595d5899Sopenharmony_ci 19595d5899Sopenharmony_ci#include <memory> 20595d5899Sopenharmony_ci#include <mutex> 21595d5899Sopenharmony_ci#include <vector> 22595d5899Sopenharmony_ci 23595d5899Sopenharmony_ci#include "calculation_curve.h" 24595d5899Sopenharmony_ci 25595d5899Sopenharmony_cinamespace OHOS { 26595d5899Sopenharmony_cinamespace DisplayPowerMgr { 27595d5899Sopenharmony_ci 28595d5899Sopenharmony_ciclass BrightnessCalculationManager { 29595d5899Sopenharmony_cipublic: 30595d5899Sopenharmony_ci BrightnessCalculationManager() = default; 31595d5899Sopenharmony_ci virtual ~BrightnessCalculationManager() = default;; 32595d5899Sopenharmony_ci BrightnessCalculationManager(const BrightnessCalculationManager&) = delete; 33595d5899Sopenharmony_ci BrightnessCalculationManager& operator=(const BrightnessCalculationManager&) = delete; 34595d5899Sopenharmony_ci BrightnessCalculationManager(BrightnessCalculationManager&&) = delete; 35595d5899Sopenharmony_ci BrightnessCalculationManager& operator=(BrightnessCalculationManager&&) = delete; 36595d5899Sopenharmony_ci void InitParameters(); 37595d5899Sopenharmony_ci float GetInterpolatedValue(float lux); 38595d5899Sopenharmony_ci void UpdateCurrentUserId(int userId); 39595d5899Sopenharmony_ci void UpdateBrightnessOffset(float posBrightness, float lux); 40595d5899Sopenharmony_ci void SetGameModeEnable(bool isGameCurveEnable); 41595d5899Sopenharmony_ci void SetCameraModeEnable(bool isCameraCurveEnable); 42595d5899Sopenharmony_ci void ResetOffsetFromHumanFactor(bool isOffsetResetEnable, int minOffsetBrightness, int maxOffsetBrightness); 43595d5899Sopenharmony_ci int GetDisplayIdWithDisplayMode(int displayMode); 44595d5899Sopenharmony_ci int GetSensorIdWithDisplayMode(int displayMode); 45595d5899Sopenharmony_ci int GetDisplayIdWithFoldstatus(int foldStatus); 46595d5899Sopenharmony_ci int GetSensorIdWithFoldstatus(int foldStatus); 47595d5899Sopenharmony_ci 48595d5899Sopenharmony_ciprivate: 49595d5899Sopenharmony_ci void UpdateParaFromReboot(); 50595d5899Sopenharmony_ci void UpdateCurveAmbientLux(float lux); 51595d5899Sopenharmony_ci float GetInterpolatedBrightenssLevel(float positionBrightness, float lux); 52595d5899Sopenharmony_ci void UpdateDefaultBrightness(float lux); 53595d5899Sopenharmony_ci float GetCurrentBrightness(float lux); 54595d5899Sopenharmony_ci 55595d5899Sopenharmony_ci bool IsDefaultBrightnessMode(float positionBrightness); 56595d5899Sopenharmony_ci float GetAmbientOffsetLux(); 57595d5899Sopenharmony_ci float GetBrightenOffsetNoValidBrightenLux(float lux); 58595d5899Sopenharmony_ci 59595d5899Sopenharmony_ci float GetOffsetLevel(float brightnessStartOrig, float brightnessEndOrig, 60595d5899Sopenharmony_ci float brightnessStartNew, float delta); 61595d5899Sopenharmony_ci float GetDefaultBrightenOffsetBrightenRaio(float brightnessStartOrig, float brightnessEndOrig, 62595d5899Sopenharmony_ci float brightnessStartNew, float deltaStart); 63595d5899Sopenharmony_ci float GetDefaultDarkenOffsetBrightenRatio(float brightnessStartOrig, float brightnessEndOrig, 64595d5899Sopenharmony_ci float brightnessStartNew, float deltaStart); 65595d5899Sopenharmony_ci float GetDefaultDarkenOffsetDarkenRatio(float brightnessStartOrig, float brightnessEndOrig, 66595d5899Sopenharmony_ci float brightnessStartNew, float deltaStart); 67595d5899Sopenharmony_ci float GetDefaultBrightenOffsetDarkenRatio(float brightnessStartOrig, float brightnessEndOrig, 68595d5899Sopenharmony_ci float brightnessStartNew); 69595d5899Sopenharmony_ci void ResetDefaultBrightnessOffset(); 70595d5899Sopenharmony_ci 71595d5899Sopenharmony_ci BrightnessCalculationCurve mBrightnessCalculationCurve{}; 72595d5899Sopenharmony_ci int mCurrentUserId{0}; 73595d5899Sopenharmony_ci bool mIsCameraCurveEnable{false}; 74595d5899Sopenharmony_ci bool mIsGameCurveEnable{false}; 75595d5899Sopenharmony_ci float mDelta{0.0f}; 76595d5899Sopenharmony_ci float mOffsetLux{0.0f}; 77595d5899Sopenharmony_ci float mPosBrightness{0.0f}; 78595d5899Sopenharmony_ci bool mIsReboot{false}; 79595d5899Sopenharmony_ci float mOffsetBrightnessLast{0.0f}; 80595d5899Sopenharmony_ci float mLastLuxDefaultBrightness{0.0f}; 81595d5899Sopenharmony_ci float mStartLuxDefaultBrightness{0.0f}; 82595d5899Sopenharmony_ci float mCurveLux{0.0f}; 83595d5899Sopenharmony_ci float mDefaultBrightnessFromLux{0.0f}; 84595d5899Sopenharmony_ci float offsetBrightenAlphaRight{0.0f}; 85595d5899Sopenharmony_ci float offsetDarkenAlphaLeft{0.0f}; 86595d5899Sopenharmony_ci float offsetBrightenAlphaLeft{0.0f}; 87595d5899Sopenharmony_ci float offsetBrightenRatioLeft{0.0f}; 88595d5899Sopenharmony_ci}; 89595d5899Sopenharmony_ci 90595d5899Sopenharmony_ci} // namespace DisplayPowerMgr 91595d5899Sopenharmony_ci} // namespace OHOS 92595d5899Sopenharmony_ci 93595d5899Sopenharmony_ci#endif // BRIGHTNESS_CALCULATION_MANAGER_H 94