• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "rs_system_parameters.h"
17 
18 #include <cstdlib>
19 #include <parameter.h>
20 #include <parameters.h>
21 #include "param/sys_param.h"
22 #include "platform/common/rs_log.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 constexpr int DEFAULT_QUICK_SKIP_PREPARE_TYPE_VALUE = 3;
ConvertToInt(const char * originValue,int defaultValue)27 int ConvertToInt(const char *originValue, int defaultValue)
28 {
29     return originValue == nullptr ? defaultValue : std::atoi(originValue);
30 }
GetCalcCostEnabled()31 bool RSSystemParameters::GetCalcCostEnabled()
32 {
33     static CachedHandle g_Handle = CachedParameterCreate("rosen.calcCost.enabled", "0");
34     int changed = 0;
35     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
36     return ConvertToInt(enable, 0) != 0;
37 }
38 
GetDrawingCacheEnabled()39 bool RSSystemParameters::GetDrawingCacheEnabled()
40 {
41     static CachedHandle g_Handle = CachedParameterCreate("rosen.drawingCache.enabled", "1");
42     int changed = 0;
43     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
44     return ConvertToInt(enable, 1) != 0;
45 }
46 
GetDrawingCacheEnabledDfx()47 bool RSSystemParameters::GetDrawingCacheEnabledDfx()
48 {
49     static CachedHandle g_Handle = CachedParameterCreate("rosen.drawingCache.enabledDfx", "0");
50     int changed = 0;
51     const char *enabledDfx = CachedParameterGetChanged(g_Handle, &changed);
52     return ConvertToInt(enabledDfx, 0) != 0;
53 }
54 
GetShowRefreshRateEnabled()55 bool RSSystemParameters::GetShowRefreshRateEnabled()
56 {
57     static CachedHandle g_Handle = CachedParameterCreate("rosen.showRefreshRate.enabled", "0");
58     int changed = 0;
59     const char *enabled = CachedParameterGetChanged(g_Handle, &changed);
60     return ConvertToInt(enabled, 0) != 0;
61 }
62 
GetQuickSkipPrepareType()63 QuickSkipPrepareType RSSystemParameters::GetQuickSkipPrepareType()
64 {
65     static CachedHandle g_Handle = CachedParameterCreate("rosen.quickskipprepare.enabled", "5");
66     int changed = 0;
67     const char *type = CachedParameterGetChanged(g_Handle, &changed);
68     return static_cast<QuickSkipPrepareType>(ConvertToInt(type, DEFAULT_QUICK_SKIP_PREPARE_TYPE_VALUE));
69 }
70 
GetVSyncControlEnabled()71 bool RSSystemParameters::GetVSyncControlEnabled()
72 {
73     static bool vsyncControlEnabled =
74         std::atoi((system::GetParameter("persist.sys.graphic.vsyncControlEnabled", "1")).c_str()) != 0;
75     return vsyncControlEnabled;
76 }
77 
GetSystemAnimatedScenesEnabled()78 bool RSSystemParameters::GetSystemAnimatedScenesEnabled()
79 {
80     static bool systemAnimatedScenesEnabled =
81         std::atoi((system::GetParameter("persist.sys.graphic.systemAnimatedScenesEnabled", "1")).c_str()) != 0;
82     return systemAnimatedScenesEnabled;
83 }
84 
GetFilterCacheOcculusionEnabled()85 bool RSSystemParameters::GetFilterCacheOcculusionEnabled()
86 {
87     static bool filterCacheOcclusionEnabled =
88         std::atoi((system::GetParameter("persist.sys.graphic.filterCacheOcclusionEnabled", "1")).c_str()) != 0;
89     return filterCacheOcclusionEnabled;
90 }
91 
GetSkipCanvasNodeOutofScreenEnabled()92 bool RSSystemParameters::GetSkipCanvasNodeOutofScreenEnabled()
93 {
94     static CachedHandle g_Handle = CachedParameterCreate("rosen.skipCanvasNodeOutofScreen.enabled", "1");
95     int changed = 0;
96     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
97     return ConvertToInt(enable, 1) != 0;
98 }
99 
GetDrawingEffectRegionEnabledDfx()100 bool RSSystemParameters::GetDrawingEffectRegionEnabledDfx()
101 {
102     static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.drawingEffectRegionEnabledDfx", "0");
103     int changed = 0;
104     const char *enableDfx = CachedParameterGetChanged(g_Handle, &changed);
105     return ConvertToInt(enableDfx, 0) != 0;
106 }
107 } // namespace Rosen
108 } // namespace OHOS
109