• 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 }
31 
GetCalcCostEnabled()32 bool RSSystemParameters::GetCalcCostEnabled()
33 {
34     static CachedHandle g_Handle = CachedParameterCreate("rosen.calcCost.enabled", "0");
35     int changed = 0;
36     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
37     return ConvertToInt(enable, 0) != 0;
38 }
39 
GetDumpRSTreeCount()40 int RSSystemParameters::GetDumpRSTreeCount()
41 {
42     static CachedHandle g_Handle = CachedParameterCreate("debug.graphic.dumpRSTreeCount", "0");
43     int changed = 0;
44     const char *num = CachedParameterGetChanged(g_Handle, &changed);
45     return ConvertToInt(num, 0);
46 }
47 
SetDumpRSTreeCount(int count)48 void RSSystemParameters::SetDumpRSTreeCount(int count)
49 {
50     count = (count > 0) ? count : 0;
51     system::SetParameter("debug.graphic.dumpRSTreeCount", std::to_string(count));
52     RS_LOGD("RSSystemParameters::SetDumpRSTreeCount %{public}d", count);
53 }
54 
GetDrawingCacheEnabled()55 bool RSSystemParameters::GetDrawingCacheEnabled()
56 {
57     static CachedHandle g_Handle = CachedParameterCreate("rosen.drawingCache.enabled", "1");
58     int changed = 0;
59     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
60     return ConvertToInt(enable, 1) != 0;
61 }
62 
GetDrawingCacheEnabledDfx()63 bool RSSystemParameters::GetDrawingCacheEnabledDfx()
64 {
65     static CachedHandle g_Handle = CachedParameterCreate("rosen.drawingCache.enabledDfx", "0");
66     int changed = 0;
67     const char *enabledDfx = CachedParameterGetChanged(g_Handle, &changed);
68     return ConvertToInt(enabledDfx, 0) != 0;
69 }
70 
GetShowRefreshRateEnabled(int * changed)71 bool RSSystemParameters::GetShowRefreshRateEnabled(int *changed)
72 {
73     static CachedHandle g_Handle = CachedParameterCreate("rosen.showRefreshRate.enabled", "0");
74     const char *enabled = CachedParameterGetChanged(g_Handle, changed);
75     return ConvertToInt(enabled, 0) != 0;
76 }
77 
GetQuickSkipPrepareType()78 QuickSkipPrepareType RSSystemParameters::GetQuickSkipPrepareType()
79 {
80     static CachedHandle g_Handle = CachedParameterCreate("rosen.quickskipprepare.enabled", "2");
81     int changed = 0;
82     const char *type = CachedParameterGetChanged(g_Handle, &changed);
83     return static_cast<QuickSkipPrepareType>(ConvertToInt(type, DEFAULT_QUICK_SKIP_PREPARE_TYPE_VALUE));
84 }
85 
GetRsParallelType()86 RsParallelType RSSystemParameters::GetRsParallelType()
87 {
88     static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.parallel.type", "0");
89     int changed = 0;
90     const char *type = CachedParameterGetChanged(g_Handle, &changed);
91     return static_cast<RsParallelType>(ConvertToInt(type, 0));
92 }
93 
GetRsSurfaceCaptureType()94 RsSurfaceCaptureType RSSystemParameters::GetRsSurfaceCaptureType()
95 {
96     if (GetRsParallelType() == RsParallelType::RS_PARALLEL_TYPE_SINGLE_THREAD) {
97         return RsSurfaceCaptureType::RS_SURFACE_CAPTURE_TYPE_MAIN_THREAD;
98     }
99     static CachedHandle g_Handle =
100         CachedParameterCreate("persist.sys.graphic.surface_capture.type", "0");
101     int changed = 0;
102     const char *type = CachedParameterGetChanged(g_Handle, &changed);
103     return static_cast<RsSurfaceCaptureType>(ConvertToInt(type, 0));
104 }
105 
GetVRateControlEnabled()106 bool RSSystemParameters::GetVRateControlEnabled()
107 {
108     static CachedHandle g_Handle = CachedParameterCreate("rosen.vRateControl.enabled", "1");
109     int changed = 0;
110     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
111     return ConvertToInt(enable, 1) != 0;
112 }
113 
GetVSyncControlEnabled()114 bool RSSystemParameters::GetVSyncControlEnabled()
115 {
116     static bool vsyncControlEnabled =
117         std::atoi((system::GetParameter("persist.sys.graphic.vsyncControlEnabled", "1")).c_str()) != 0;
118     return vsyncControlEnabled;
119 }
120 
GetSystemAnimatedScenesEnabled()121 bool RSSystemParameters::GetSystemAnimatedScenesEnabled()
122 {
123     static bool systemAnimatedScenesEnabled =
124         std::atoi((system::GetParameter("persist.sys.graphic.systemAnimatedScenesEnabled", "1")).c_str()) != 0;
125     return systemAnimatedScenesEnabled;
126 }
127 
GetFilterCacheOcculusionEnabled()128 bool RSSystemParameters::GetFilterCacheOcculusionEnabled()
129 {
130     static bool filterCacheOcclusionEnabled =
131         std::atoi((system::GetParameter("persist.sys.graphic.filterCacheOcclusionEnabled", "1")).c_str()) != 0;
132     return filterCacheOcclusionEnabled;
133 }
134 
GetSkipCanvasNodeOutofScreenEnabled()135 bool RSSystemParameters::GetSkipCanvasNodeOutofScreenEnabled()
136 {
137     static CachedHandle g_Handle = CachedParameterCreate("rosen.skipCanvasNodeOutofScreen.enabled", "0");
138     int changed = 0;
139     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
140     return ConvertToInt(enable, 1) != 0;
141 }
142 
GetDrawingEffectRegionEnabledDfx()143 bool RSSystemParameters::GetDrawingEffectRegionEnabledDfx()
144 {
145     static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.drawingEffectRegionEnabledDfx", "0");
146     int changed = 0;
147     const char *enableDfx = CachedParameterGetChanged(g_Handle, &changed);
148     return ConvertToInt(enableDfx, 0) != 0;
149 }
150 
GetRenderStop()151 bool RSSystemParameters::GetRenderStop()
152 {
153     static CachedHandle g_Handle = CachedParameterCreate("rosen.render.stop", "0");
154     int changed = 0;
155     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
156     return ConvertToInt(enable, 0) != 0;
157 }
158 
GetOcclusionCallBackToWMSDebugType()159 bool RSSystemParameters::GetOcclusionCallBackToWMSDebugType()
160 {
161     static CachedHandle g_Handle = CachedParameterCreate("rosen.occlusion.callbacktowms.debug.enabled", "0");
162     int changed = 0;
163     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
164     return ConvertToInt(enable, 0) != 0;
165 }
166 
GetPrevalidateHwcNodeEnabled()167 bool RSSystemParameters::GetPrevalidateHwcNodeEnabled()
168 {
169     static bool prevalidateHwcNodeEnabled =
170         std::atoi((system::GetParameter("persist.sys.graphic.prevalidateHwcNode.Enabled", "1")).c_str()) != 0;
171     return prevalidateHwcNodeEnabled;
172 }
173 
GetSolidLayerHwcEnabled()174 bool RSSystemParameters::GetSolidLayerHwcEnabled()
175 {
176     static bool solidLayerHwcEnabled =
177         std::atoi((system::GetParameter("persist.sys.graphic.solidLayer.Enabled", "1")).c_str()) != 0;
178     return solidLayerHwcEnabled;
179 }
180 
GetControlBufferConsumeEnabled()181 bool RSSystemParameters::GetControlBufferConsumeEnabled()
182 {
183     static bool controlBufferConsume =
184         std::atoi((system::GetParameter("persist.sys.graphic.controlBufferConsume.Enabled", "1")).c_str()) != 0;
185     return controlBufferConsume;
186 }
187 
GetHideNotchStatus()188 bool RSSystemParameters::GetHideNotchStatus()
189 {
190     static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.hideNotch.status", "0");
191     int changed = 0;
192     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
193     if (!enable) {
194         return false;
195     }
196     return (strcmp(enable, "2") == 0);
197 }
198 
GetHpaeBlurEnabled()199 bool RSSystemParameters::GetHpaeBlurEnabled()
200 {
201     static CachedHandle g_Handle = CachedParameterCreate("debug.graphic.hpae.blur.enabled", "0");
202     int changed = 0;
203     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
204     return ConvertToInt(enable, 1) != 0;
205 }
206 
GetTcacheEnabled()207 bool RSSystemParameters::GetTcacheEnabled()
208 {
209     static bool flag = system::GetBoolParameter("persist.sys.graphic.tcache.enable", true);
210     return flag;
211 }
212 
GetDumpCanvasDrawingNodeEnabled()213 bool RSSystemParameters::GetDumpCanvasDrawingNodeEnabled()
214 {
215     static CachedHandle g_Handle = CachedParameterCreate("debug.graphic.canvasDrawingEnabled", "0");
216     int changed = 0;
217     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
218     return ConvertToInt(enable, 0) != 0;
219 }
220 
IsNeedScRGBForP3(const GraphicColorGamut & currentGamut)221 bool RSSystemParameters::IsNeedScRGBForP3(const GraphicColorGamut& currentGamut)
222 {
223     static bool isSupportScRGBForP3_ = system::GetBoolParameter("persist.sys.graphic.scrgb.enabled", false);
224     return isSupportScRGBForP3_ && (currentGamut != GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB);
225 }
226 
GetWiredScreenOndrawEnabled()227 bool RSSystemParameters::GetWiredScreenOndrawEnabled()
228 {
229     static CachedHandle g_Handle = CachedParameterCreate("rosen.wiredScreenOndraw.enabled", "1");
230     int changed = 0;
231     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
232     return ConvertToInt(enable, 0) != 0;
233 }
234 
GetDebugMirrorOndrawEnabled()235 bool RSSystemParameters::GetDebugMirrorOndrawEnabled()
236 {
237     static CachedHandle g_Handle = CachedParameterCreate("rosen.debugMirrorOndraw.enabled", "0");
238     int changed = 0;
239     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
240     return ConvertToInt(enable, 1) != 0;
241 }
242 
GetArsrPreEnabled()243 bool RSSystemParameters::GetArsrPreEnabled()
244 {
245     static bool flag = system::GetBoolParameter("const.display.enable_arsr_pre", true);
246     return flag;
247 }
248 
GetIsCopybitSupported()249 bool RSSystemParameters::GetIsCopybitSupported()
250 {
251     static bool flag = system::GetBoolParameter("const.display.support_copybit", false);
252     return flag;
253 }
254 
GetMultimediaEnableCameraRotationCompensation()255 bool RSSystemParameters::GetMultimediaEnableCameraRotationCompensation()
256 {
257     static bool flag = system::GetBoolParameter("const.multimedia.enable_camera_rotation_compensation", 0);
258     return flag;
259 }
260 
GetCanvasDrawingNodeRegionEnabled()261 bool RSSystemParameters::GetCanvasDrawingNodeRegionEnabled()
262 {
263     static CachedHandle g_Handle = CachedParameterCreate("rosen.canvas_drawing_node.region.enabled", "0");
264     int changed = 0;
265     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
266     return ConvertToInt(enable, 0) != 0;
267 }
268 
GetWindowScreenScanType()269 int32_t RSSystemParameters::GetWindowScreenScanType()
270 {
271     static int32_t screenScanType = system::GetIntParameter<int32_t>("const.window.screen.scan_type", 0);
272     return screenScanType;
273 }
274 
GetPurgeableResourceLimit()275 int32_t RSSystemParameters::GetPurgeableResourceLimit()
276 {
277     static int32_t purgeableResourceLimit =
278         system::GetIntParameter<int32_t>("persist.sys.graphic.purgeableResourceLimit", 40000); // purge limit: 40000
279     return purgeableResourceLimit;
280 }
281 
GetAnimationOcclusionEnabled()282 bool RSSystemParameters::GetAnimationOcclusionEnabled()
283 {
284     static CachedHandle g_Handle = CachedParameterCreate("rosen.ani.occlusion.enabled", "1");
285     int changed = 0;
286     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
287     return ConvertToInt(enable, 0) != 0;
288 }
289 
GetUIFirstPurgeEnabled()290 bool RSSystemParameters::GetUIFirstPurgeEnabled()
291 {
292     static CachedHandle g_Handle = CachedParameterCreate("rosen.uifirst.purge.enable", "1");
293     int changed = 0;
294     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
295     return ConvertToInt(enable, 0) != 0;
296 }
297 
GetUIFirstOcclusionEnabled()298 bool RSSystemParameters::GetUIFirstOcclusionEnabled()
299 {
300     static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.uifirst.occlusion.enable", "1");
301     int changed = 0;
302     const char *enable = CachedParameterGetChanged(g_Handle, &changed);
303     return ConvertToInt(enable, 0);
304 }
305 
GetUIFirstCaptrueReuseEnabled()306 bool RSSystemParameters::GetUIFirstCaptrueReuseEnabled()
307 {
308     static bool enable =
309         std::atoi((system::GetParameter("persist.sys.graphic.uifirst.captrue.reuse.enable", "1")).c_str()) != 0;
310     return enable;
311 }
GetUIFirstStartingWindowCacheEnabled()312 bool RSSystemParameters::GetUIFirstStartingWindowCacheEnabled()
313 {
314     static bool enable =
315         std::atoi((system::GetParameter("persist.sys.graphic.uifirst.startingWindow.cache.enable", "1")).c_str()) != 0;
316     return enable;
317 }
318 } // namespace Rosen
319 } // namespace OHOS
320