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_BASE_H
17595d5899Sopenharmony_ci#define BRIGHTNESS_BASE_H
18595d5899Sopenharmony_ci
19595d5899Sopenharmony_ci#include <ctime>
20595d5899Sopenharmony_ci#include <cmath>
21595d5899Sopenharmony_ci#include <string>
22595d5899Sopenharmony_ci
23595d5899Sopenharmony_cinamespace OHOS {
24595d5899Sopenharmony_cinamespace DisplayPowerMgr {
25595d5899Sopenharmony_ci
26595d5899Sopenharmony_ciconstexpr uint32_t DEFAULT_DISPLAY_ID = 0;
27595d5899Sopenharmony_ciconstexpr uint32_t OUTTER_SCREEN_DISPLAY_ID = 5;
28595d5899Sopenharmony_ciconst float EPSILON = 0.0000001f;
29595d5899Sopenharmony_ciconst int MSECPERSEC = 1000;
30595d5899Sopenharmony_ciconst int NSECPERMSEC = 1000000;
31595d5899Sopenharmony_ci
32595d5899Sopenharmony_cienum class BrightnessFilterMode {
33595d5899Sopenharmony_ci    MEAN_FILTER = 0,
34595d5899Sopenharmony_ci    WEIGHT_FILTER,
35595d5899Sopenharmony_ci    FITLER_END
36595d5899Sopenharmony_ci};
37595d5899Sopenharmony_ci
38595d5899Sopenharmony_cienum class BrightnessSceneMode {
39595d5899Sopenharmony_ci    MODE_DEFAULT = 0,
40595d5899Sopenharmony_ci    MODE_GAME,
41595d5899Sopenharmony_ci    MODE_VIDEO,
42595d5899Sopenharmony_ci    SCENCE_END
43595d5899Sopenharmony_ci};
44595d5899Sopenharmony_ci
45595d5899Sopenharmony_cienum class BrightnessModeState {
46595d5899Sopenharmony_ci    CAMERA_MODE,
47595d5899Sopenharmony_ci    GAME_MODE,
48595d5899Sopenharmony_ci    DEFAULT_MODE
49595d5899Sopenharmony_ci};
50595d5899Sopenharmony_ci
51595d5899Sopenharmony_ciinline int64_t GetCurrentTimeMillis()
52595d5899Sopenharmony_ci{
53595d5899Sopenharmony_ci    struct timespec val {};
54595d5899Sopenharmony_ci    if (clock_gettime(CLOCK_BOOTTIME, &val) == 0) {
55595d5899Sopenharmony_ci        return static_cast<int64_t>(val.tv_sec) * MSECPERSEC + val.tv_nsec / NSECPERMSEC;
56595d5899Sopenharmony_ci    }
57595d5899Sopenharmony_ci    return 0;
58595d5899Sopenharmony_ci}
59595d5899Sopenharmony_ci
60595d5899Sopenharmony_ciinline bool IsEqualF(float a, float b)
61595d5899Sopenharmony_ci{
62595d5899Sopenharmony_ci    return fabs(a - b) < EPSILON;
63595d5899Sopenharmony_ci}
64595d5899Sopenharmony_ci} // namespace BrightnessPowerMgr
65595d5899Sopenharmony_ci} // namespace OHOS
66595d5899Sopenharmony_ci#endif // BRIGHTNESS_BASE_H