1 /*
2 * Copyright (c) 2021-2025 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 "platform/common/rs_system_properties.h"
17
18 #include <charconv>
19 #include <cstdlib>
20 #include <parameter.h>
21 #include <parameters.h>
22 #include <unistd.h>
23 #include "param/sys_param.h"
24 #include "platform/common/rs_log.h"
25 #include "transaction/rs_render_service_client.h"
26 #include "scene_board_judgement.h"
27 #include "pipeline/rs_uni_render_judgement.h"
28
29 namespace OHOS {
30 namespace Rosen {
31 namespace {
32 constexpr int DEFAULT_CACHE_WIDTH = 1250;
33 constexpr int DEFAULT_CACHE_HEIGHT = 2710;
34 constexpr int DEFAULT_PARTIAL_RENDER_ENABLED_VALUE = 2;
35 constexpr int DEFAULT_UNI_PARTIAL_RENDER_ENABLED_VALUE = 4;
36 constexpr int DEFAULT_ADVANCED_DIRTY_REGION_ENABLED_VALUE = 1;
37 constexpr int DEFAULT_DIRTY_ALIGN_ENABLED_VALUE = 0;
38 constexpr int DEFAULT_CORRECTION_MODE_VALUE = 999;
39 constexpr int DEFAULT_SCALE_MODE = 2;
40 constexpr const char* DEFAULT_CLIP_RECT_THRESHOLD = "0.7";
41 constexpr const char* VULKAN_CONFIG_FILE_PATH = "/vendor/etc/vulkan/icd.d";
42 constexpr int DEFAULT_TEXTBLOB_LINE_COUNT = 9;
43 struct GetComponentSwitch ComponentSwitchTable[] = {
44 {ComponentEnableSwitch::TEXTBLOB, RSSystemProperties::GetHybridRenderTextBlobEnabled},
45 {ComponentEnableSwitch::SVG, RSSystemProperties::GetHybridRenderSvgEnabled},
46 {ComponentEnableSwitch::HMSYMBOL, RSSystemProperties::GetHybridRenderHmsymbolEnabled},
47 {ComponentEnableSwitch::CANVAS, RSSystemProperties::GetHybridRenderCanvasEnabled},
48 };
49 }
50
51 #if (defined (ACE_ENABLE_GL) && defined (ACE_ENABLE_VK)) || (defined (RS_ENABLE_GL) && defined (RS_ENABLE_VK))
52 const GpuApiType RSSystemProperties::systemGpuApiType_ = Drawing::SystemProperties::GetGpuApiType();
53 #elif defined (ACE_ENABLE_GL) || defined (RS_ENABLE_GL)
54 const GpuApiType RSSystemProperties::systemGpuApiType_ = GpuApiType::OPENGL;
55 #else
56 const GpuApiType RSSystemProperties::systemGpuApiType_ = GpuApiType::VULKAN;
57 #endif
58
59 bool RSSystemProperties::isEnableEarlyZ_ = system::GetBoolParameter("persist.sys.graphic.ddgrEarlyZ.enabled", true);
60
ConvertToInt(const char * originValue,int defaultValue)61 int ConvertToInt(const char *originValue, int defaultValue)
62 {
63 if (originValue == nullptr) {
64 return defaultValue;
65 }
66 int value;
67 auto result = std::from_chars(originValue, originValue + std::strlen(originValue), value);
68 if (result.ec == std::errc()) {
69 return value;
70 } else {
71 return defaultValue;
72 }
73 }
74
ParseDfxSurfaceNamesString(const std::string & paramsStr,std::vector<std::string> & splitStrs,const std::string & seperator)75 static void ParseDfxSurfaceNamesString(const std::string& paramsStr,
76 std::vector<std::string>& splitStrs, const std::string& seperator)
77 {
78 std::string::size_type pos1 = 0;
79 std::string::size_type pos2 = paramsStr.find(seperator);
80 if (std::string::npos == pos2) {
81 splitStrs.push_back(paramsStr);
82 return;
83 }
84 while (std::string::npos != pos2) {
85 splitStrs.push_back(paramsStr.substr(pos1, pos2 - pos1));
86 pos1 = pos2 + seperator.size();
87 pos2 = paramsStr.find(seperator, pos1);
88 }
89 if (pos1 != paramsStr.length()) {
90 splitStrs.push_back(paramsStr.substr(pos1));
91 }
92 }
93
IsSceneBoardEnabled()94 bool RSSystemProperties::IsSceneBoardEnabled()
95 {
96 static bool isSCBEnabled = SceneBoardJudgement::IsSceneBoardEnabled();
97 return isSCBEnabled;
98 }
99
100 // used by clients
GetDumpFrameNum()101 int RSSystemProperties::GetDumpFrameNum()
102 {
103 static CachedHandle g_Handle = CachedParameterCreate("rosen.recording.frameNum", "0");
104 int changed = 0;
105 const char *num = CachedParameterGetChanged(g_Handle, &changed);
106 return ConvertToInt(num, 0);
107 }
108
GetSceneJankFrameThreshold()109 int RSSystemProperties::GetSceneJankFrameThreshold()
110 {
111 static int sceneJankFrameThreshold =
112 std::stoi((system::GetParameter("persist.sys.graphic.sceneJankFrameThreshold", "50")).c_str());
113 return sceneJankFrameThreshold;
114 }
115
GetProfilerPixelCheckMode()116 bool RSSystemProperties::GetProfilerPixelCheckMode()
117 {
118 static CachedHandle handle = CachedParameterCreate("persist.graphic.profiler.pixelcheck", "0");
119 int32_t changed = 0;
120 return ConvertToInt(CachedParameterGetChanged(handle, &changed), 0) != 0;
121 }
122
SetProfilerPixelCheckMode(bool flag)123 void RSSystemProperties::SetProfilerPixelCheckMode(bool flag)
124 {
125 system::SetParameter("persist.graphic.profiler.pixelcheck", flag ? "1" : "0");
126 }
127
GetRecordingEnabled()128 int RSSystemProperties::GetRecordingEnabled()
129 {
130 static CachedHandle g_Handle = CachedParameterCreate("debug.graphic.recording.enabled", "0");
131 int changed = 0;
132 const char *num = CachedParameterGetChanged(g_Handle, &changed);
133 return ConvertToInt(num, 0);
134 }
135
SetRecordingDisenabled()136 void RSSystemProperties::SetRecordingDisenabled()
137 {
138 system::SetParameter("debug.graphic.recording.enabled", "0");
139 RS_LOGD("RSSystemProperties::SetRecordingDisenabled");
140 }
141
GetProfilerEnabled()142 bool RSSystemProperties::GetProfilerEnabled()
143 {
144 static CachedHandle handle = CachedParameterCreate("persist.graphic.profiler.enabled", "0");
145 int32_t changed = 0;
146 return ConvertToInt(CachedParameterGetChanged(handle, &changed), 0) != 0;
147 }
148
SetProfilerDisabled()149 void RSSystemProperties::SetProfilerDisabled()
150 {
151 system::SetParameter("persist.graphic.profiler.enabled", "0");
152 }
153
GetVkQueuePriorityEnable()154 bool RSSystemProperties::GetVkQueuePriorityEnable()
155 {
156 static bool vkQueuePriorityEnabled =
157 std::atoi((system::GetParameter("persist.vkqueue.priority.enalbed", "1")).c_str()) != 0;
158 return vkQueuePriorityEnabled;
159 }
160
GetInstantRecording()161 bool RSSystemProperties::GetInstantRecording()
162 {
163 return (system::GetParameter("debug.graphic.instant.recording.enabled", "0") != "0");
164 }
165
SetInstantRecording(bool flag)166 void RSSystemProperties::SetInstantRecording(bool flag)
167 {
168 system::SetParameter("debug.graphic.instant.recording.enabled", flag ? "1" : "0");
169 }
170
GetBetaRecordingMode()171 uint32_t RSSystemProperties::GetBetaRecordingMode()
172 {
173 static CachedHandle handle = CachedParameterCreate("persist.graphic.profiler.betarecording", "0");
174 int32_t changed = 0;
175 const char* state = CachedParameterGetChanged(handle, &changed);
176 return ConvertToInt(state, 0);
177 }
178
SetBetaRecordingMode(uint32_t param)179 void RSSystemProperties::SetBetaRecordingMode(uint32_t param)
180 {
181 system::SetParameter("persist.graphic.profiler.betarecording", std::to_string(param));
182 }
183
GetSaveRDC()184 bool RSSystemProperties::GetSaveRDC()
185 {
186 return (system::GetParameter("debug.graphic.rdcenabled", "0") != "0");
187 }
188
SetSaveRDC(bool flag)189 void RSSystemProperties::SetSaveRDC(bool flag)
190 {
191 system::SetParameter("debug.graphic.rdcenabled", flag ? "1" : "0");
192 }
193
GetRecordingFile()194 std::string RSSystemProperties::GetRecordingFile()
195 {
196 static CachedHandle g_Handle = CachedParameterCreate("rosen.dumpfile.path", "");
197 int changed = 0;
198 const char *file = CachedParameterGetChanged(g_Handle, &changed);
199 return file == nullptr ? "" : file;
200 }
201
GetUniRenderEnabled()202 bool RSSystemProperties::GetUniRenderEnabled()
203 {
204 static bool inited = false;
205 if (inited) {
206 return isUniRenderEnabled_;
207 }
208
209 isUniRenderEnabled_ = std::static_pointer_cast<RSRenderServiceClient>(RSIRenderClient::CreateRenderServiceClient())
210 ->GetUniRenderEnabled();
211 inited = true;
212 ROSEN_LOGD("RSSystemProperties::GetUniRenderEnabled:%{public}d", isUniRenderEnabled_);
213 return isUniRenderEnabled_;
214 }
215
GetDrawOpTraceEnabled()216 bool RSSystemProperties::GetDrawOpTraceEnabled()
217 {
218 static bool code = system::GetParameter("persist.rosen.drawoptrace.enabled", "0") != "0";
219 return code;
220 }
221
GetRenderNodeTraceEnabled()222 bool RSSystemProperties::GetRenderNodeTraceEnabled()
223 {
224 static bool isNeedTrace = system::GetParameter("persist.rosen.rendernodetrace.enabled", "0") != "0";
225 return isNeedTrace;
226 }
227
GetAnimationTraceEnabled()228 bool RSSystemProperties::GetAnimationTraceEnabled()
229 {
230 bool isAnimationTraceDebugEnabled = system::GetParameter("persist.rosen.animationtrace.enabled", "0") != "0";
231 bool isOpenTestModeTraceDebug = system::GetParameter("sys.graphic.openTestModeTrace", "0") != "0";
232 return isAnimationTraceDebugEnabled || isOpenTestModeTraceDebug;
233 }
234
GetAnimationDelayOptimizeEnabled()235 bool RSSystemProperties::GetAnimationDelayOptimizeEnabled()
236 {
237 constexpr int DEFAULT_OPTIMIZE_STATUS = 1;
238 constexpr int DISABLED_STATUS = 0;
239
240 static CachedHandle g_Handle = CachedParameterCreate("rosen.animationdelay.optimize.enabled", "1");
241 int changed = 0;
242 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
243 return ConvertToInt(enable, DEFAULT_OPTIMIZE_STATUS) != DISABLED_STATUS;
244 }
245
GetRSClientMultiInstanceEnabled()246 bool RSSystemProperties::GetRSClientMultiInstanceEnabled()
247 {
248 static bool isMultiInstance = system::GetParameter("persist.rosen.rsclientmultiinstance.enabled", "1") != "0";
249 static bool isPhone = system::GetParameter("const.product.devicetype", "phone") == "phone";
250 return isMultiInstance && isPhone;
251 }
252
GetRSScreenRoundCornerEnable()253 bool RSSystemProperties::GetRSScreenRoundCornerEnable()
254 {
255 static bool isNeedScreenRCD = system::GetParameter("persist.rosen.screenroundcornerrcd.enabled", "1") != "0";
256 return isNeedScreenRCD;
257 }
258
GetRenderNodePurgeEnabled()259 bool RSSystemProperties::GetRenderNodePurgeEnabled()
260 {
261 static bool isPurgeable = system::GetParameter("persist.rosen.rendernode.purge.enabled", "1") != "0";
262 return isPurgeable;
263 }
264
GetRSImagePurgeEnabled()265 bool RSSystemProperties::GetRSImagePurgeEnabled()
266 {
267 static bool isPurgeable = system::GetParameter("persist.rosen.rsimage.purge.enabled", "1") != "0";
268 return isPurgeable;
269 }
270
GetClosePixelMapFdEnabled()271 bool RSSystemProperties::GetClosePixelMapFdEnabled()
272 {
273 static bool isClosePixelMapFd = system::GetParameter("persist.rosen.rsimage.close.fd", "0") != "0";
274 return isClosePixelMapFd;
275 }
276
GetDirtyRegionDebugType()277 DirtyRegionDebugType RSSystemProperties::GetDirtyRegionDebugType()
278 {
279 static CachedHandle g_Handle = CachedParameterCreate("rosen.dirtyregiondebug.enabled", "0");
280 int changed = 0;
281 const char *type = CachedParameterGetChanged(g_Handle, &changed);
282 return static_cast<DirtyRegionDebugType>(ConvertToInt(type, 0));
283 }
284
GetPartialRenderEnabled()285 PartialRenderType RSSystemProperties::GetPartialRenderEnabled()
286 {
287 static CachedHandle g_Handle = CachedParameterCreate("rosen.partialrender.enabled", "2");
288 int changed = 0;
289 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
290 return static_cast<PartialRenderType>(ConvertToInt(enable, DEFAULT_PARTIAL_RENDER_ENABLED_VALUE));
291 }
292
GetUniPartialRenderEnabled()293 PartialRenderType RSSystemProperties::GetUniPartialRenderEnabled()
294 {
295 int changed = 0;
296 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.partialrender.enabled", "4");
297 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
298 return static_cast<PartialRenderType>(ConvertToInt(enable, DEFAULT_UNI_PARTIAL_RENDER_ENABLED_VALUE));
299 }
300
GetStencilPixelOcclusionCullingEnabled()301 StencilPixelOcclusionCullingType RSSystemProperties::GetStencilPixelOcclusionCullingEnabled()
302 {
303 static CachedHandle g_Handle = CachedParameterCreate("rosen.stencilpixelocclusionculling.enabled", "-1");
304 int changed = 0;
305 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
306 return static_cast<StencilPixelOcclusionCullingType>(ConvertToInt(enable,
307 static_cast<int>(StencilPixelOcclusionCullingType::DEFAULT)));
308 }
309
GetAdvancedDirtyRegionEnabled()310 AdvancedDirtyRegionType RSSystemProperties::GetAdvancedDirtyRegionEnabled()
311 {
312 static CachedHandle g_Handle = CachedParameterCreate("rosen.advanceddirtyregion.enabled", "1");
313 int changed = 0;
314 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
315 return static_cast<AdvancedDirtyRegionType>(ConvertToInt(enable, DEFAULT_ADVANCED_DIRTY_REGION_ENABLED_VALUE));
316 }
317
GetDirtyAlignEnabled()318 DirtyAlignType RSSystemProperties::GetDirtyAlignEnabled()
319 {
320 static CachedHandle g_Handle = CachedParameterCreate("rosen.dirtyalign.enabled", "0");
321 int changed = 0;
322 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
323 return static_cast<DirtyAlignType>(ConvertToInt(enable, DEFAULT_DIRTY_ALIGN_ENABLED_VALUE));
324 }
325
GetClipRectThreshold()326 float RSSystemProperties::GetClipRectThreshold()
327 {
328 int changed = 0;
329 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.cliprect.threshold", DEFAULT_CLIP_RECT_THRESHOLD);
330 const char *threshold = CachedParameterGetChanged(g_Handle, &changed);
331 return threshold == nullptr ? std::atof(DEFAULT_CLIP_RECT_THRESHOLD) : std::atof(threshold);
332 }
333
GetAllSurfaceVisibleDebugEnabled()334 bool RSSystemProperties::GetAllSurfaceVisibleDebugEnabled()
335 {
336 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.allsurfacevisibledebug.enabled", "0");
337 int changed = 0;
338 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
339 return ConvertToInt(enable, 0) != 0;
340 }
341
GetVirtualDirtyDebugEnabled()342 bool RSSystemProperties::GetVirtualDirtyDebugEnabled()
343 {
344 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.virtualdirtydebug.enabled", "0");
345 int changed = 0;
346 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
347 return ConvertToInt(enable, 0) != 0;
348 }
349
GetVirtualDirtyEnabled()350 bool RSSystemProperties::GetVirtualDirtyEnabled()
351 {
352 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.virtualdirty.enabled", "1");
353 int changed = 0;
354 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
355 return ConvertToInt(enable, 0) != 0;
356 }
357
GetExpandScreenDirtyEnabled()358 bool RSSystemProperties::GetExpandScreenDirtyEnabled()
359 {
360 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.expandscreendirty.enabled", "0");
361 int changed = 0;
362 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
363 return ConvertToInt(enable, 0) != 0;
364 }
365
GetVirtualExpandScreenSkipEnabled()366 bool RSSystemProperties::GetVirtualExpandScreenSkipEnabled()
367 {
368 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.virtualexpandscreenskip.enabled", "1");
369 int changed = 0;
370 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
371 return ConvertToInt(enable, 1) != 0;
372 }
373
GetReleaseResourceEnabled()374 bool RSSystemProperties::GetReleaseResourceEnabled()
375 {
376 static CachedHandle g_Handle = CachedParameterCreate("persist.release.gpuresource.enabled", "1");
377 int changed = 0;
378 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
379 return ConvertToInt(enable, 1) != 0;
380 }
381
GetReclaimMemoryEnabled()382 bool RSSystemProperties::GetReclaimMemoryEnabled()
383 {
384 static CachedHandle g_Handle = CachedParameterCreate("persist.relcaim.memory.enabled", "1");
385 int changed = 0;
386 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
387 return ConvertToInt(enable, 1) != 0;
388 }
389
GetOcclusionEnabled()390 bool RSSystemProperties::GetOcclusionEnabled()
391 {
392 static CachedHandle g_Handle = CachedParameterCreate("rosen.occlusion.enabled", "1");
393 int changed = 0;
394 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
395 return ConvertToInt(enable, 1) != 0;
396 }
397
GetHardwareComposerEnabled()398 bool RSSystemProperties::GetHardwareComposerEnabled()
399 {
400 static bool hardwareComposerEnabled = system::GetParameter(
401 "persist.rosen.hardwarecomposer.enabled", "1") != "0";
402 return hardwareComposerEnabled;
403 }
404
GetDoDirectCompositionEnabled()405 bool RSSystemProperties::GetDoDirectCompositionEnabled()
406 {
407 static bool doDirectCompositionEnabled = system::GetParameter(
408 "persist.rosen.doDirectComposition.enabled", "1") != "0";
409 return doDirectCompositionEnabled;
410 }
411
GetDumpRsTreeDetailEnabled()412 bool RSSystemProperties::GetDumpRsTreeDetailEnabled()
413 {
414 static bool dumpRsTreeDetailEnabled = system::GetParameter(
415 "persist.rosen.dumpRsTreeDetail.enabled", "0") != "0";
416 return dumpRsTreeDetailEnabled;
417 }
418
GetHardwareComposerEnabledForMirrorMode()419 bool RSSystemProperties::GetHardwareComposerEnabledForMirrorMode()
420 {
421 static bool hardwareComposerMirrorEnabled =
422 system::GetParameter("persist.rosen.hardwarecomposer.mirror.enabled", "0") != "0";
423 return hardwareComposerMirrorEnabled;
424 }
425
GetHwcRegionDfxEnabled()426 bool RSSystemProperties::GetHwcRegionDfxEnabled()
427 {
428 static bool hwcRegionDfxEnabled = system::GetParameter(
429 "persist.rosen.hwcRegionDfx.enabled", "0") != "0";
430 return hwcRegionDfxEnabled;
431 }
432
GetDrawMirrorCacheImageEnabled()433 bool RSSystemProperties::GetDrawMirrorCacheImageEnabled()
434 {
435 static CachedHandle g_Handle = CachedParameterCreate("rosen.cacheimage.mirror.enabled", "1");
436 int changed = 0;
437 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
438 return ConvertToInt(enable, 0) != 0;
439 }
440
GetPixelmapDfxEnabled()441 bool RSSystemProperties::GetPixelmapDfxEnabled()
442 {
443 static CachedHandle g_Handle = CachedParameterCreate("rosen.pixelmapdfx.enabled", "0");
444 int changed = 0;
445 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
446 return ConvertToInt(enable, 0) != 0;
447 }
448
GetAFBCEnabled()449 bool RSSystemProperties::GetAFBCEnabled()
450 {
451 static CachedHandle g_Handle = CachedParameterCreate("rosen.afbc.enabled", "1");
452 int changed = 0;
453 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
454 return ConvertToInt(enable, 1) != 0;
455 }
456
GetRSEventProperty(const std::string & paraName)457 std::string RSSystemProperties::GetRSEventProperty(const std::string ¶Name)
458 {
459 return system::GetParameter(paraName, "0");
460 }
461
GetHighContrastStatus()462 bool RSSystemProperties::GetHighContrastStatus()
463 {
464 // If the value of rosen.directClientComposition.enabled is not 0 then enable the direct CLIENT composition.
465 // Direct CLIENT composition will be processed only when the num of layer is larger than 11
466 static CachedHandle g_Handle = CachedParameterCreate("rosen.HighContrast.enabled", "0");
467 int changed = 0;
468 const char *status = CachedParameterGetChanged(g_Handle, &changed);
469 return ConvertToInt(status, 0) != 0;
470 }
471
GetDrmEnabled()472 bool RSSystemProperties::GetDrmEnabled()
473 {
474 static CachedHandle g_Handle = CachedParameterCreate("rosen.drm.enabled", "1");
475 int changed = 0;
476 const char *enabled = CachedParameterGetChanged(g_Handle, &changed);
477 return ConvertToInt(enabled, 0) != 0;
478 }
479
GetTargetDirtyRegionDfxEnabled(std::vector<std::string> & dfxTargetSurfaceNames_)480 bool RSSystemProperties::GetTargetDirtyRegionDfxEnabled(std::vector<std::string>& dfxTargetSurfaceNames_)
481 {
482 static CachedHandle g_Handle = CachedParameterCreate("rosen.dirtyregiondebug.surfacenames", "0");
483 int changed = 0;
484 const char *targetSurfacesStr = CachedParameterGetChanged(g_Handle, &changed);
485 if (targetSurfacesStr == nullptr || strcmp(targetSurfacesStr, "0") == 0) {
486 dfxTargetSurfaceNames_.clear();
487 return false;
488 }
489 dfxTargetSurfaceNames_.clear();
490 ParseDfxSurfaceNamesString(targetSurfacesStr, dfxTargetSurfaceNames_, ",");
491 return true;
492 }
493
GetOpaqueRegionDfxEnabled()494 bool RSSystemProperties::GetOpaqueRegionDfxEnabled()
495 {
496 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.opaqueregiondebug", "0");
497 int changed = 0;
498 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
499 return ConvertToInt(enable, 0) != 0;
500 }
501
GetVisibleRegionDfxEnabled()502 bool RSSystemProperties::GetVisibleRegionDfxEnabled()
503 {
504 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.visibleregiondebug", "0");
505 int changed = 0;
506 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
507 return ConvertToInt(enable, 0) != 0;
508 }
509
GetSurfaceRegionDfxType()510 SurfaceRegionDebugType RSSystemProperties::GetSurfaceRegionDfxType()
511 {
512 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.surfaceregiondebug", "0");
513 int changed = 0;
514 const char *type = CachedParameterGetChanged(g_Handle, &changed);
515 return static_cast<SurfaceRegionDebugType>(ConvertToInt(type, 0));
516 }
517
GetCorrectionMode()518 uint32_t RSSystemProperties::GetCorrectionMode()
519 {
520 // If the value of rosen.directClientComposition.enabled is not 0 then enable the direct CLIENT composition.
521 // Direct CLIENT composition will be processed only when the num of layer is larger than 11
522 static CachedHandle g_Handle = CachedParameterCreate("rosen.CorrectionMode", "999");
523 int changed = 0;
524 const char *mode = CachedParameterGetChanged(g_Handle, &changed);
525 return ConvertToInt(mode, DEFAULT_CORRECTION_MODE_VALUE);
526 }
527
GetDumpSurfaceType()528 DumpSurfaceType RSSystemProperties::GetDumpSurfaceType()
529 {
530 static CachedHandle g_Handle = CachedParameterCreate("rosen.dumpsurfacetype.enabled", "0");
531 int changed = 0;
532 const char *type = CachedParameterGetChanged(g_Handle, &changed);
533 return static_cast<DumpSurfaceType>(ConvertToInt(type, 0));
534 }
535
GetDumpSurfaceId()536 long long int RSSystemProperties::GetDumpSurfaceId()
537 {
538 static CachedHandle g_Handle = CachedParameterCreate("rosen.dumpsurfaceid", "0");
539 int changed = 0;
540 const char *surfaceId = CachedParameterGetChanged(g_Handle, &changed);
541 return surfaceId == nullptr ? std::atoll("0") : std::atoll(surfaceId);
542 }
543
GetDumpLayersEnabled()544 bool RSSystemProperties::GetDumpLayersEnabled()
545 {
546 static CachedHandle g_Handle = CachedParameterCreate("rosen.dumplayer.enabled", "0");
547 int changed = 0;
548 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
549 return ConvertToInt(enable, 0) != 0;
550 }
551
SetDrawTextAsBitmap(bool flag)552 void RSSystemProperties::SetDrawTextAsBitmap(bool flag)
553 {
554 isDrawTextAsBitmap_ = flag;
555 }
GetDrawTextAsBitmap()556 bool RSSystemProperties::GetDrawTextAsBitmap()
557 {
558 return isDrawTextAsBitmap_;
559 }
560
SetCacheEnabledForRotation(bool flag)561 void RSSystemProperties::SetCacheEnabledForRotation(bool flag)
562 {
563 cacheEnabledForRotation_ = flag;
564 }
565
GetCacheEnabledForRotation()566 bool RSSystemProperties::GetCacheEnabledForRotation()
567 {
568 return cacheEnabledForRotation_;
569 }
570
GetPrepareParallelRenderingEnabled()571 ParallelRenderingType RSSystemProperties::GetPrepareParallelRenderingEnabled()
572 {
573 static ParallelRenderingType systemPropertiePrepareType = static_cast<ParallelRenderingType>(
574 std::atoi((system::GetParameter("persist.rosen.prepareparallelrender.enabled", "1")).c_str()));
575 return systemPropertiePrepareType;
576 }
577
GetParallelRenderingEnabled()578 ParallelRenderingType RSSystemProperties::GetParallelRenderingEnabled()
579 {
580 static ParallelRenderingType systemPropertieType = static_cast<ParallelRenderingType>(
581 std::atoi((system::GetParameter("persist.rosen.parallelrender.enabled", "0")).c_str()));
582 return systemPropertieType;
583 }
584
GetSurfaceNodeWatermarkEnabled()585 bool RSSystemProperties::GetSurfaceNodeWatermarkEnabled()
586 {
587 static bool watermark =
588 std::atoi((system::GetParameter("persist.rosen.watermark.enabled", "1")).c_str()) != 0;
589 return watermark;
590 }
591
GetHgmRefreshRatesEnabled()592 HgmRefreshRates RSSystemProperties::GetHgmRefreshRatesEnabled()
593 {
594 static CachedHandle g_Handle = CachedParameterCreate("rosen.sethgmrefreshrate.enabled", "0");
595 int changed = 0;
596 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
597 return static_cast<HgmRefreshRates>(ConvertToInt(enable, 0));
598 }
599
SetHgmRefreshRateModesEnabled(std::string param)600 void RSSystemProperties::SetHgmRefreshRateModesEnabled(std::string param)
601 {
602 system::SetParameter("persist.rosen.sethgmrefreshratemode.enabled", param);
603 RS_LOGI("RSSystemProperties::SetHgmRefreshRateModesEnabled set to %{public}s", param.c_str());
604 }
605
GetHgmRefreshRateModesEnabled()606 HgmRefreshRateModes RSSystemProperties::GetHgmRefreshRateModesEnabled()
607 {
608 static CachedHandle g_Handle = CachedParameterCreate("persist.rosen.sethgmrefreshratemode.enabled", "0");
609 int changed = 0;
610 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
611 return static_cast<HgmRefreshRateModes>(ConvertToInt(enable, 0));
612 }
613
GetHardCursorEnabled()614 bool RSSystemProperties::GetHardCursorEnabled()
615 {
616 static CachedHandle g_Handle = CachedParameterCreate("rosen.hardCursor.enabled", "1");
617 int changed = 0;
618 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
619 return ConvertToInt(enable, 1) != 0;
620 }
621
GetSkipForAlphaZeroEnabled()622 bool RSSystemProperties::GetSkipForAlphaZeroEnabled()
623 {
624 static CachedHandle g_Handle = CachedParameterCreate("persist.skipForAlphaZero.enabled", "1");
625 int changed = 0;
626 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
627 return ConvertToInt(enable, 1) != 0;
628 }
629
GetSkipGeometryNotChangeEnabled()630 bool RSSystemProperties::GetSkipGeometryNotChangeEnabled()
631 {
632 static bool skipGeoNotChangeEnabled =
633 std::atoi((system::GetParameter("persist.skipGeometryNotChange.enabled", "1")).c_str()) != 0;
634 return skipGeoNotChangeEnabled;
635 }
636
GetAnimationCacheEnabled()637 bool RSSystemProperties::GetAnimationCacheEnabled()
638 {
639 static bool animationCacheEnabled =
640 std::atoi((system::GetParameter("persist.animation.cache.enabled", "0")).c_str()) != 0;
641 return animationCacheEnabled;
642 }
643
GetAnimationScale()644 float RSSystemProperties::GetAnimationScale()
645 {
646 static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.animationscale", "1.0");
647 int changed = 0;
648 const char *scale = CachedParameterGetChanged(g_Handle, &changed);
649 return scale == nullptr ? std::atof("1.0") : std::atof(scale);
650 }
651
GetFilterCacheEnabled()652 bool RSSystemProperties::GetFilterCacheEnabled()
653 {
654 // Determine whether the filter cache should be enabled. The default value is 1, which means that it is enabled.
655 // If dirty-region is not properly implemented, the filter cache will act as a skip-frame strategy for filters.
656 static bool filterCacheEnabled =
657 std::atoi((system::GetParameter("persist.sys.graphic.filterCacheEnabled", "1")).c_str()) != 0;
658 return filterCacheEnabled;
659 }
660
GetFilterCacheUpdateInterval()661 int RSSystemProperties::GetFilterCacheUpdateInterval()
662 {
663 // Configure whether to enable skip-frame for the filter cache. The default value is 1, which means that the cached
664 // image is updated with a delay of 1 frame.
665 static int filterCacheUpdateInterval =
666 std::atoi((system::GetParameter("persist.sys.graphic.filterCacheUpdateInterval", "1")).c_str());
667 return filterCacheUpdateInterval;
668 }
669
GetFilterCacheSizeThreshold()670 int RSSystemProperties::GetFilterCacheSizeThreshold()
671 {
672 // Set the minimum size for enabling skip-frame in the filter cache. By default, this value is 400, which means that
673 // skip-frame is only enabled for regions where both the width and height are greater than 400.
674 static int filterCacheSizeThreshold =
675 std::atoi((system::GetParameter("persist.sys.graphic.filterCacheSizeThreshold", "400")).c_str());
676 return filterCacheSizeThreshold;
677 }
678
GetMaskLinearBlurEnabled()679 bool RSSystemProperties::GetMaskLinearBlurEnabled()
680 {
681 // Determine whether the mask LinearBlur render should be enabled. The default value is 0,
682 // which means that it is unenabled.
683 static bool enabled =
684 std::atoi((system::GetParameter("persist.sys.graphic.maskLinearBlurEnabled", "1")).c_str()) != 0;
685 return enabled;
686 }
687
GetMotionBlurEnabled()688 bool RSSystemProperties::GetMotionBlurEnabled()
689 {
690 // Determine whether the motionBlur render should be enabled. The default value is 0,
691 // which means that it is unenabled.
692 static bool enabled =
693 std::atoi((system::GetParameter("persist.sys.graphic.motionBlurEnabled", "1")).c_str()) != 0;
694 return enabled;
695 }
696
GetSLRScaleEnabled()697 bool RSSystemProperties::GetSLRScaleEnabled()
698 {
699 static CachedHandle g_Handle = CachedParameterCreate("rosen.SLRScale.enabled", "1");
700 int changed = 0;
701 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
702 return ConvertToInt(enable, 1) != 0;
703 }
704
GetDynamicBrightnessEnabled()705 bool RSSystemProperties::GetDynamicBrightnessEnabled()
706 {
707 // Determine whether the daynamic brightness render should be enabled. The default value is 1,
708 // which means that it is enabled.
709 static bool enabled =
710 std::atoi((system::GetParameter("persist.sys.graphic.dynamicBrightnessEnabled", "1")).c_str()) != 0;
711 return enabled;
712 }
713
GetMagnifierEnabled()714 bool RSSystemProperties::GetMagnifierEnabled()
715 {
716 // Determine whether the magnifier render should be enabled. The default value is 0,
717 // which means that it is unenabled.
718 static bool enabled =
719 std::atoi((system::GetParameter("persist.sys.graphic.magnifierEnabled", "1")).c_str()) != 0;
720 return enabled;
721 }
722
GetKawaseEnabled()723 bool RSSystemProperties::GetKawaseEnabled()
724 {
725 static bool kawaseBlurEnabled =
726 std::atoi((system::GetParameter("persist.sys.graphic.kawaseEnable", "1")).c_str()) != 0;
727 return kawaseBlurEnabled;
728 }
729
SetForceHpsBlurDisabled(bool flag)730 void RSSystemProperties::SetForceHpsBlurDisabled(bool flag)
731 {
732 forceHpsBlurDisabled_ = flag;
733 }
734
GetHpsBlurNoiseFactor()735 float RSSystemProperties::GetHpsBlurNoiseFactor()
736 {
737 static float noiseFactor =
738 std::atof((system::GetParameter("persist.sys.graphic.HpsBlurNoiseFactor", "1.75")).c_str());
739 return noiseFactor;
740 }
741
GetHpsBlurEnabled()742 bool RSSystemProperties::GetHpsBlurEnabled()
743 {
744 static bool hpsBlurEnabled =
745 std::atoi((system::GetParameter("persist.sys.graphic.HpsBlurEnable", "1")).c_str()) != 0;
746 return hpsBlurEnabled && !forceHpsBlurDisabled_;
747 }
748
GetMESABlurFuzedEnabled()749 bool RSSystemProperties::GetMESABlurFuzedEnabled()
750 {
751 static bool blurPixelStretchEnabled =
752 std::atoi((system::GetParameter("persist.sys.graphic.mesaBlurFuzedEnable", "1")).c_str()) != 0;
753 return blurPixelStretchEnabled;
754 }
755
GetSimplifiedMesaEnabled()756 int RSSystemProperties::GetSimplifiedMesaEnabled()
757 {
758 static int simplifiedMesaEnabled =
759 std::atoi((system::GetParameter("persist.sys.graphic.simplifiedMesaEnable", "0")).c_str());
760 return simplifiedMesaEnabled;
761 }
762
GetForceKawaseDisabled()763 bool RSSystemProperties::GetForceKawaseDisabled()
764 {
765 static bool kawaseDisabled =
766 std::atoi((system::GetParameter("persist.sys.graphic.kawaseDisable", "0")).c_str()) != 0;
767 return kawaseDisabled;
768 }
769
GetKawaseRandomColorFactor()770 float RSSystemProperties::GetKawaseRandomColorFactor()
771 {
772 static float randomFactor =
773 std::atof((system::GetParameter("persist.sys.graphic.kawaseFactor", "1.75")).c_str());
774 return randomFactor;
775 }
776
GetRandomColorEnabled()777 bool RSSystemProperties::GetRandomColorEnabled()
778 {
779 static bool randomColorEnabled =
780 std::atoi((system::GetParameter("persist.sys.graphic.randomColorEnable", "1")).c_str()) != 0;
781 return randomColorEnabled;
782 }
783
GetKawaseOriginalEnabled()784 bool RSSystemProperties::GetKawaseOriginalEnabled()
785 {
786 static bool kawaseOriginalEnabled =
787 std::atoi((system::GetParameter("persist.sys.graphic.kawaseOriginalEnable", "0")).c_str()) != 0;
788 return kawaseOriginalEnabled;
789 }
790
GetRenderParallelEnabled()791 bool RSSystemProperties::GetRenderParallelEnabled()
792 {
793 static bool enable =
794 std::atoi((system::GetParameter("persist.sys.graphic.renderParallel", "1")).c_str()) != 0;
795 return enable;
796 }
797
GetBlurEnabled()798 bool RSSystemProperties::GetBlurEnabled()
799 {
800 static bool blurEnabled =
801 std::atoi((system::GetParameter("persist.sys.graphic.blurEnabled", "1")).c_str()) != 0;
802 return blurEnabled;
803 }
804
GetForegroundFilterEnabled()805 bool RSSystemProperties::GetForegroundFilterEnabled()
806 {
807 static bool foregroundFilterEnabled =
808 std::atoi((system::GetParameter("persist.sys.graphic.foregroundFilterEnabled", "1")).c_str()) != 0;
809 return foregroundFilterEnabled;
810 }
811
GetAiInvertCoef()812 const std::vector<float>& RSSystemProperties::GetAiInvertCoef()
813 {
814 // Configure AiInvertCoef: Low, High, Threshold, Opacity, Saturation, Filter Radius.
815 static std::vector<float> aiInvertCoef = {0.0, 1.0, 0.55, 0.4, 1.6, 45.0};
816 static bool initialized = false;
817 if (!initialized) {
818 initialized = true;
819 // Configure AiInvertCoef0: Low
820 aiInvertCoef[0] =
821 std::atof((system::GetParameter("persist.sys.graphic.aiInvertLow", "0.5")).c_str());
822 // Configure AiInvertCoef1: High.
823 aiInvertCoef[1] =
824 std::atof((system::GetParameter("persist.sys.graphic.aiInvertHigh", "0.7")).c_str());
825 // Configure AiInvertCoef2: Threshold.
826 aiInvertCoef[2] =
827 std::atof((system::GetParameter("persist.sys.graphic.aiInvertThreshold", "0.5")).c_str());
828 // Configure AiInvertCoef3: Opacity.
829 aiInvertCoef[3] =
830 std::atof((system::GetParameter("persist.sys.graphic.aiInvertOpacity", "0.2")).c_str());
831 // Configure AiInvertCoef4: Saturation.
832 aiInvertCoef[4] =
833 std::atof((system::GetParameter("persist.sys.graphic.aiInvertSaturation", "1.0")).c_str());
834 // Configure AiInvertCoef5: Filter Radius.
835 aiInvertCoef[5] =
836 std::atof((system::GetParameter("persist.sys.graphic.aiInvertFilterRadius", "300")).c_str());
837 }
838 return aiInvertCoef;
839 }
840
GetProxyNodeDebugEnabled()841 bool RSSystemProperties::GetProxyNodeDebugEnabled()
842 {
843 static bool proxyNodeDebugEnabled = system::GetParameter("persist.sys.graphic.proxyNodeDebugEnabled", "0") != "0";
844 return proxyNodeDebugEnabled;
845 }
846
GetCacheOptimizeRotateEnable()847 bool RSSystemProperties::GetCacheOptimizeRotateEnable()
848 {
849 static bool debugEnable = system::GetBoolParameter("const.cache.optimize.rotate.enable", false);
850 return debugEnable;
851 }
852
GetCrossNodeOffScreenStatus()853 CrossNodeOffScreenRenderDebugType RSSystemProperties::GetCrossNodeOffScreenStatus()
854 {
855 static CachedHandle g_Handle = CachedParameterCreate("rosen.crossnode.offscreen.render.enabled", "1");
856 int chanded = 0;
857 const char *type = CachedParameterGetChanged(g_Handle, &chanded);
858 return static_cast<CrossNodeOffScreenRenderDebugType>(ConvertToInt(type, 1));
859 }
860
GetSubtreeParallelEnable()861 bool RSSystemProperties::GetSubtreeParallelEnable()
862 {
863 static const bool subtreeParallelEnable = std::atoi((system::GetParameter(
864 "persist.sys.graphic.subtreeParallelEnable", "1")).c_str()) != 0;
865 return subtreeParallelEnable;
866 }
867
GetSubtreeDebugOption()868 uint32_t RSSystemProperties::GetSubtreeDebugOption()
869 {
870 static const uint32_t subtreeDebugOption =
871 std::atoi((system::GetParameter("persist.sys.graphic.subtreeDebugOption", "0")).c_str());
872 return subtreeDebugOption;
873 }
874
GetUIFirstEnabled()875 bool RSSystemProperties::GetUIFirstEnabled()
876 {
877 #ifdef ROSEN_EMULATOR
878 return false;
879 #else
880 static CachedHandle g_Handle = CachedParameterCreate("rosen.ui.first.enabled", "1");
881 int changed = 0;
882 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
883 return ConvertToInt(enable, 1) != 0;
884 #endif
885 }
886
GetUIFirstOptScheduleEnabled()887 bool RSSystemProperties::GetUIFirstOptScheduleEnabled()
888 {
889 static CachedHandle g_Handle = CachedParameterCreate("rosen.ui.first.optSchedule.enabled", "1");
890 int changed = 0;
891 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
892 return ConvertToInt(enable, 1) != 0;
893 }
894
GetUIFirstBehindWindowEnabled()895 bool RSSystemProperties::GetUIFirstBehindWindowEnabled()
896 {
897 static CachedHandle g_Handle = CachedParameterCreate("rosen.ui.first.behindwindow.enabled", "1");
898 int changed = 0;
899 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
900 return ConvertToInt(enable, 1) != 0;
901 }
902
GetUIFirstDirtyEnabled()903 bool RSSystemProperties::GetUIFirstDirtyEnabled()
904 {
905 static CachedHandle g_Handle = CachedParameterCreate("rosen.ui.first.dirty.enabled", "1");
906 int changed = 0;
907 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
908 return ConvertToInt(enable, 1) != 0;
909 }
910
GetUIFirstDirtyDebugEnabled()911 bool RSSystemProperties::GetUIFirstDirtyDebugEnabled()
912 {
913 static CachedHandle g_Handle = CachedParameterCreate("rosen.ui.first.dirty.dfx.enabled", "0");
914 int changed = 0;
915 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
916 return ConvertToInt(enable, 1) != 0;
917 }
918
GetUIFirstBehindWindowFilterEnabled()919 bool RSSystemProperties::GetUIFirstBehindWindowFilterEnabled()
920 {
921 static CachedHandle g_Handle = CachedParameterCreate("rosen.ui.first.behindWindowFilter.enabled", "1");
922 int changed = 0;
923 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
924 return ConvertToInt(enable, 1) != 0;
925 }
926
GetHeterogComputingHDREnabled()927 bool RSSystemProperties::GetHeterogComputingHDREnabled()
928 {
929 static CachedHandle g_Handle = CachedParameterCreate("rosen.heterog.computing.hdr.enabled", "1");
930 int changed = 0;
931 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
932 return ConvertToInt(enable, 1) != 0;
933 }
934
GetSurfaceOffscreenEnadbled()935 bool RSSystemProperties::GetSurfaceOffscreenEnadbled()
936 {
937 static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.surfaceOffscreenEnabled", "1");
938 int changed = 0;
939 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
940 return ConvertToInt(enable, 1) != 0;
941 }
942
GetUIFirstDebugEnabled()943 bool RSSystemProperties::GetUIFirstDebugEnabled()
944 {
945 static bool debugEnable = system::GetIntParameter("persist.sys.graphic.uifirstDebugEnabled", 0) != 0;
946 return debugEnable;
947 }
948
GetSingleDrawableLockerEnabled()949 bool RSSystemProperties::GetSingleDrawableLockerEnabled()
950 {
951 static bool lockerEnable = system::GetIntParameter("persist.sys.graphic.singleDrawableLocker.enable", 1) != 0;
952 return lockerEnable;
953 }
954
GetTargetUIFirstDfxEnabled(std::vector<std::string> & SurfaceNames)955 bool RSSystemProperties::GetTargetUIFirstDfxEnabled(std::vector<std::string>& SurfaceNames)
956 {
957 static CachedHandle g_Handle = CachedParameterCreate("rosen.UIFirstdebug.surfacenames", "0");
958 int changed = 0;
959 const char *targetSurfacesStr = CachedParameterGetChanged(g_Handle, &changed);
960 if (targetSurfacesStr == nullptr || strcmp(targetSurfacesStr, "0") == 0) {
961 SurfaceNames.clear();
962 return false;
963 }
964 SurfaceNames.clear();
965 ParseDfxSurfaceNamesString(targetSurfacesStr, SurfaceNames, ",");
966 return true;
967 }
968
GetWideColorSpaceEnabled()969 bool RSSystemProperties::GetWideColorSpaceEnabled()
970 {
971 static CachedHandle g_Handle = CachedParameterCreate("rosen.wide.colorspace.enabled", "1");
972 int changed = 0;
973 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
974 return ConvertToInt(enable, 1) != 0;
975 }
976
GetDebugTraceEnabled()977 bool RSSystemProperties::GetDebugTraceEnabled()
978 {
979 static bool openDebugTrace = system::GetIntParameter("persist.sys.graphic.openDebugTrace", 0) != 0;
980 return openDebugTrace;
981 }
982
GetImageReleaseUsingPostTask()983 bool RSSystemProperties::GetImageReleaseUsingPostTask()
984 {
985 static bool flag =
986 std::atoi((system::GetParameter("persist.sys.graphic.iamgeReleasePostTask", "0")).c_str()) != 0;
987 return flag;
988 }
989
GetDebugTraceLevel()990 int RSSystemProperties::GetDebugTraceLevel()
991 {
992 static int openDebugTraceLevel =
993 std::atoi((system::GetParameter("persist.sys.graphic.openDebugTrace", "0")).c_str());
994 return openDebugTraceLevel;
995 }
996
GetDumpImgEnabled()997 bool RSSystemProperties::GetDumpImgEnabled()
998 {
999 static bool dumpImgEnabled =
1000 std::atoi((system::GetParameter("persist.sys.graphic.dumpImgEnabled", "0")).c_str()) != 0;
1001 return dumpImgEnabled;
1002 }
1003
GetTransactionTerminateEnabled()1004 bool RSSystemProperties::GetTransactionTerminateEnabled()
1005 {
1006 static bool terminateEnabled =
1007 std::atoi((system::GetParameter("persist.sys.graphic.transactionTerminateEnabled", "0")).c_str()) != 0;
1008 return terminateEnabled;
1009 }
1010
GetBlurEffectTerminateLimit()1011 uint32_t RSSystemProperties::GetBlurEffectTerminateLimit()
1012 {
1013 static int terminateLimit =
1014 std::atoi((system::GetParameter("persist.sys.graphic.blurEffectTerminateLimit", "50")).c_str());
1015 return terminateLimit > 0 ? static_cast<uint32_t>(terminateLimit) : 0;
1016 }
1017
FindNodeInTargetList(std::string node)1018 bool RSSystemProperties::FindNodeInTargetList(std::string node)
1019 {
1020 static std::string targetStr = system::GetParameter("persist.sys.graphic.traceTargetList", "");
1021 static auto strSize = targetStr.size();
1022 if (strSize == 0) {
1023 return false;
1024 }
1025 static std::vector<std::string> targetVec;
1026 static bool loaded = false;
1027 if (!loaded) {
1028 const std::string pattern = ";";
1029 targetStr += pattern;
1030 strSize = targetStr.size();
1031 std::string::size_type pos;
1032 for (std::string::size_type i = 0; i < strSize; i++) {
1033 pos = targetStr.find(pattern, i);
1034 if (pos >= strSize) {
1035 break;
1036 }
1037 auto str = targetStr.substr(i, pos - i);
1038 if (str.size() > 0) {
1039 targetVec.emplace_back(str);
1040 }
1041 i = pos;
1042 }
1043 loaded = true;
1044 }
1045 bool res = std::find(targetVec.begin(), targetVec.end(), node) != targetVec.end();
1046 return res;
1047 }
1048
IsFoldScreenFlag()1049 bool RSSystemProperties::IsFoldScreenFlag()
1050 {
1051 static bool isFoldScreenFlag = system::GetParameter("const.window.foldscreen.type", "") != "";
1052 return isFoldScreenFlag;
1053 }
1054
IsSmallFoldDevice()1055 bool RSSystemProperties::IsSmallFoldDevice()
1056 {
1057 static std::string foldType = system::GetParameter("const.window.foldscreen.type", "0,0,0,0");
1058 return foldType == "2,0,0,0" || foldType == "4,2,0,0";
1059 }
1060
GetCacheCmdEnabled()1061 bool RSSystemProperties::GetCacheCmdEnabled()
1062 {
1063 static CachedHandle g_Handle = CachedParameterCreate("rosen.cacheCmd.enabled", "1");
1064 int changed = 0;
1065 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1066 return ConvertToInt(enable, 1) != 0;
1067 }
1068
GetTimeVsyncDisabled()1069 bool RSSystemProperties::GetTimeVsyncDisabled()
1070 {
1071 static bool timeVsyncDisabled =
1072 std::atoi((system::GetParameter("persist.sys.graphic.timeVsyncDisabled", "0")).c_str()) != 0;
1073 return timeVsyncDisabled;
1074 }
1075
GetASTCEnabled()1076 bool RSSystemProperties::GetASTCEnabled()
1077 {
1078 static bool isASTCEnabled = std::atoi((system::GetParameter("persist.rosen.astc.enabled", "0")).c_str()) != 0;
1079 return isASTCEnabled;
1080 }
1081
1082 // GetCachedBlurPartialRenderEnabled Option On: no need to expand blur dirtyregion if blur has background cache
GetCachedBlurPartialRenderEnabled()1083 bool RSSystemProperties::GetCachedBlurPartialRenderEnabled()
1084 {
1085 static CachedHandle g_Handle = CachedParameterCreate("rosen.cachedblurpartialrender.enabled", "0");
1086 int changed = 0;
1087 const char *type = CachedParameterGetChanged(g_Handle, &changed);
1088 return ConvertToInt(type, 1) != 0;
1089 }
1090
GetImageGpuResourceCacheEnable(int width,int height)1091 bool RSSystemProperties::GetImageGpuResourceCacheEnable(int width, int height)
1092 {
1093 static bool cacheEnable =
1094 std::atoi((system::GetParameter("persist.sys.graphic.gpuResourceCacheEnable", "1")).c_str()) != 0;
1095 if (!cacheEnable) {
1096 return false;
1097 }
1098
1099 // default cache full screen image gpu resource.
1100 static int widthConfig =
1101 std::atoi((system::GetParameter("persist.sys.graphic.gpuResourceCacheWidth", "0")).c_str());
1102 static int heightConfig =
1103 std::atoi((system::GetParameter("persist.sys.graphic.gpuResourceCacheHeight", "0")).c_str());
1104 int cacheWidth = widthConfig == 0 ? DEFAULT_CACHE_WIDTH : widthConfig;
1105 int cacheHeight = heightConfig == 0 ? DEFAULT_CACHE_HEIGHT : heightConfig;
1106 if (width >= cacheWidth && height >= cacheHeight) {
1107 return true;
1108 }
1109 return false;
1110 }
1111
GetBoolSystemProperty(const char * name,bool defaultValue)1112 bool RSSystemProperties::GetBoolSystemProperty(const char* name, bool defaultValue)
1113 {
1114 static CachedHandle g_Handle = CachedParameterCreate(name, defaultValue ? "1" : "0");
1115 int changed = 0;
1116 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1117 return ConvertToInt(enable, defaultValue ? 1 : 0) != 0;
1118 }
1119
WatchSystemProperty(const char * name,OnSystemPropertyChanged func,void * context)1120 int RSSystemProperties::WatchSystemProperty(const char* name, OnSystemPropertyChanged func, void* context)
1121 {
1122 return WatchParameter(name, func, context);
1123 }
1124
IsPhoneType()1125 bool RSSystemProperties::IsPhoneType()
1126 {
1127 static bool isPhone = system::GetParameter("const.product.devicetype", "pc") == "phone";
1128 return isPhone;
1129 }
1130
IsSuperFoldDisplay()1131 bool RSSystemProperties::IsSuperFoldDisplay()
1132 {
1133 static const std::string foldScreenType = system::GetParameter("const.window.foldscreen.type", "0,0,0,0");
1134 static const bool IsSuperFoldDisplay = foldScreenType.size() > 0 ? foldScreenType[0] == '6' : false;
1135 return IsSuperFoldDisplay;
1136 }
1137
IsBetaRelease()1138 bool RSSystemProperties::IsBetaRelease()
1139 {
1140 static bool isBetaRelease = system::GetParameter("const.logsystem.versiontype", "") == "beta";
1141 return isBetaRelease;
1142 }
1143
GetSyncTransactionEnabled()1144 bool RSSystemProperties::GetSyncTransactionEnabled()
1145 {
1146 static bool syncTransactionEnabled =
1147 std::atoi((system::GetParameter("persist.sys.graphic.syncTransaction.enabled", "1")).c_str()) != 0;
1148 return syncTransactionEnabled;
1149 }
1150
GetSyncTransactionWaitDelay()1151 int RSSystemProperties::GetSyncTransactionWaitDelay()
1152 {
1153 static int syncTransactionWaitDelay =
1154 std::atoi((system::GetParameter("persist.sys.graphic.syncTransactionWaitDelay", "1500")).c_str());
1155 return syncTransactionWaitDelay;
1156 }
1157
GetSingleFrameComposerEnabled()1158 bool RSSystemProperties::GetSingleFrameComposerEnabled()
1159 {
1160 static bool singleFrameComposerEnabled =
1161 (std::atoi((system::GetParameter("persist.sys.graphic.singleFrameComposer", "0")).c_str()) != 0);
1162 return singleFrameComposerEnabled;
1163 }
1164
GetSingleFrameComposerCanvasNodeEnabled()1165 bool RSSystemProperties::GetSingleFrameComposerCanvasNodeEnabled()
1166 {
1167 static bool singleFrameComposerCanvasNodeEnabled =
1168 (std::atoi((system::GetParameter("persist.sys.graphic.singleFrameComposerCanvasNode", "0")).c_str()) != 0);
1169 return singleFrameComposerCanvasNodeEnabled;
1170 }
1171
GetDrawFilterWithoutSnapshotEnabled()1172 bool RSSystemProperties::GetDrawFilterWithoutSnapshotEnabled()
1173 {
1174 static bool drawFilterWithoutSnapshotEnabled =
1175 (std::atoi(system::GetParameter("persist.sys.graphic.drawFilterWithoutSnapshot", "0").c_str()) != 0);
1176 return drawFilterWithoutSnapshotEnabled;
1177 }
1178
GetBlurExtraFilterEnabled()1179 bool RSSystemProperties::GetBlurExtraFilterEnabled()
1180 {
1181 static bool blurExtraFilterEnabled =
1182 (std::atoi(system::GetParameter("persist.sys.graphic.blurExtraFilter", "0").c_str()) != 0);
1183 return blurExtraFilterEnabled;
1184 }
1185
GetDiscardCanvasBeforeFilterEnabled()1186 bool RSSystemProperties::GetDiscardCanvasBeforeFilterEnabled()
1187 {
1188 static bool discardCanvasBeforeFilterEnabled =
1189 (std::atoi(system::GetParameter("persist.sys.graphic.discardCanvasBeforeFilter", "1").c_str()) != 0);
1190 return discardCanvasBeforeFilterEnabled;
1191 }
1192
GetPurgeBetweenFramesEnabled()1193 bool RSSystemProperties::GetPurgeBetweenFramesEnabled()
1194 {
1195 static bool purgeResourcesEveryEnabled =
1196 (std::atoi(system::GetParameter("persist.sys.graphic.mem.purge_between_frames_enabled", "1").c_str()) != 0);
1197 return purgeResourcesEveryEnabled;
1198 }
1199
GetGpuMemoryAsyncReclaimerEnabled()1200 bool RSSystemProperties::GetGpuMemoryAsyncReclaimerEnabled()
1201 {
1202 static bool gpuMemoryAsyncReclaimerEnabled =
1203 (std::atoi(
1204 system::GetParameter("persist.sys.graphic.mem.gpu_async_reclaimer_between_frames_enabled", "1").c_str()) !=
1205 0);
1206 return gpuMemoryAsyncReclaimerEnabled;
1207 }
1208
GetGpuCacheSuppressWindowEnabled()1209 bool RSSystemProperties::GetGpuCacheSuppressWindowEnabled()
1210 {
1211 static bool gpuCacheSuppressWindowEnabled =
1212 (std::atoi(
1213 system::GetParameter("persist.sys.graphic.mem.gpu_suppress_window_between_frames_enabled", "1").c_str()) !=
1214 0);
1215 return gpuCacheSuppressWindowEnabled;
1216 }
1217
1218 const DdgrOpincType RSSystemProperties::ddgrOpincType_ =
1219 static_cast<DdgrOpincType>(std::atoi((system::GetParameter("persist.ddgr.opinctype", "2")).c_str()));
1220 const DdgrOpincDfxType RSSystemProperties::ddgrOpincDfxType_ =
1221 static_cast<DdgrOpincDfxType>(std::atoi((
1222 system::GetParameter("persist.rosen.ddgr.opinctype.debugtype", "0")).c_str()));
1223
GetDdgrOpincType()1224 DdgrOpincType RSSystemProperties::GetDdgrOpincType()
1225 {
1226 return RSSystemProperties::ddgrOpincType_;
1227 }
1228
IsDdgrOpincEnable()1229 bool RSSystemProperties::IsDdgrOpincEnable()
1230 {
1231 return (GetDdgrOpincType() == DdgrOpincType::OPINC_AUTOCACHE_REALDRAW ||
1232 GetDdgrOpincType() == DdgrOpincType::OPINC_AUTOCACHE);
1233 }
1234
IsOpincRealDrawCacheEnable()1235 bool RSSystemProperties::IsOpincRealDrawCacheEnable()
1236 {
1237 return GetDdgrOpincType() == DdgrOpincType::OPINC_AUTOCACHE_REALDRAW;
1238 }
1239
GetDdgrOpincDfxType()1240 DdgrOpincDfxType RSSystemProperties::GetDdgrOpincDfxType()
1241 {
1242 return ddgrOpincDfxType_;
1243 }
1244
GetAutoCacheDebugEnabled()1245 bool RSSystemProperties::GetAutoCacheDebugEnabled()
1246 {
1247 return GetDdgrOpincDfxType() == DdgrOpincDfxType::OPINC_DFX_AUTO;
1248 }
1249
1250 #ifdef RS_ENABLE_STACK_CULLING
GetViewOcclusionCullingEnabled()1251 bool RSSystemProperties::GetViewOcclusionCullingEnabled()
1252 {
1253 static bool stackViewCullingEnabled =
1254 system::GetBoolParameter("persist.sys.graphic.stack.culling.enabled", true);
1255 return stackViewCullingEnabled;
1256 }
1257 #endif
1258
GetSecurityPermissionCheckEnabled()1259 bool RSSystemProperties::GetSecurityPermissionCheckEnabled()
1260 {
1261 static bool openSecurityPermissionCheck =
1262 std::atoi((system::GetParameter("persist.sys.graphic.openSecurityPermissionCheck", "0")).c_str()) != 0;
1263 return openSecurityPermissionCheck;
1264 }
1265
GetEffectMergeEnabled()1266 bool RSSystemProperties::GetEffectMergeEnabled()
1267 {
1268 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.effectMergeEnabled", "1");
1269 int changed = 0;
1270 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1271 return ConvertToInt(enable, 1) != 0;
1272 }
1273
GetDumpUICaptureEnabled()1274 bool RSSystemProperties::GetDumpUICaptureEnabled()
1275 {
1276 bool dumpUICaptureEnabled =
1277 std::atoi((system::GetParameter("rosen.dumpUICaptureEnabled.enabled", "0")).c_str()) != 0;
1278 return dumpUICaptureEnabled;
1279 }
1280
GetDumpUIPixelmapEnabled()1281 bool RSSystemProperties::GetDumpUIPixelmapEnabled()
1282 {
1283 bool dumpUIPixelmapEnabled =
1284 std::atoi((system::GetParameter("rosen.dumpUIPixelmapEnabled.enabled", "0")).c_str()) != 0;
1285 return dumpUIPixelmapEnabled;
1286 }
1287
GetVirtualScreenScaleModeDFX()1288 int RSSystemProperties::GetVirtualScreenScaleModeDFX()
1289 {
1290 static int scaleModeDFX =
1291 std::atoi((system::GetParameter("persist.rosen.virtualScreenScaleMode.debugType", "2")).c_str());
1292 return (scaleModeDFX > DEFAULT_SCALE_MODE) ? DEFAULT_SCALE_MODE : scaleModeDFX;
1293 }
1294
GetSubTreePrepareCheckType()1295 SubTreePrepareCheckType RSSystemProperties::GetSubTreePrepareCheckType()
1296 {
1297 static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.SubTreePrepareCheckType.type", "2");
1298 int changed = 0;
1299 const char *type = CachedParameterGetChanged(g_Handle, &changed);
1300 return static_cast<SubTreePrepareCheckType>(ConvertToInt(type, 2)); // Default value 2
1301 }
1302
IsForceClient()1303 bool RSSystemProperties::IsForceClient()
1304 {
1305 static CachedHandle g_Handle = CachedParameterCreate("rosen.client_composition.enabled", "0");
1306 int changed = 0;
1307 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1308 return ConvertToInt(num, 0);
1309 }
1310
GetTextBlobAsPixelMap()1311 bool RSSystemProperties::GetTextBlobAsPixelMap()
1312 {
1313 static bool pixelMapEnabled =
1314 std::atoi((system::GetParameter("persist.rosen.textBlobAsPixelMapEnable.enable", "0")).c_str()) != 0;
1315 return pixelMapEnabled;
1316 }
1317
GetHdrImageEnabled()1318 bool RSSystemProperties::GetHdrImageEnabled()
1319 {
1320 static bool isHdrImageEnabled = system::GetBoolParameter("persist.sys.graphic.hdrimage.enabled", true);
1321 return isHdrImageEnabled;
1322 }
1323
GetHdrVideoEnabled()1324 bool RSSystemProperties::GetHdrVideoEnabled()
1325 {
1326 static bool isHdrVideoEnabled = system::GetBoolParameter("persist.sys.graphic.hdrvideo.enabled", true);
1327 return isHdrVideoEnabled;
1328 }
1329
GetJankLoadOptimizeEnabled()1330 bool RSSystemProperties::GetJankLoadOptimizeEnabled()
1331 {
1332 static bool jankLoadOptimizeEnabled =
1333 system::GetBoolParameter("persist.sys.graphic.jankLoadOptimize.enabled", true);
1334 return jankLoadOptimizeEnabled;
1335 }
1336
GetRSNodeLimit()1337 int RSSystemProperties::GetRSNodeLimit()
1338 {
1339 static int rsNodeLimit =
1340 std::atoi((system::GetParameter("persist.sys.graphic.rsNodeLimit", "500")).c_str());
1341 return rsNodeLimit;
1342 }
1343
GetGpuOverDrawBufferOptimizeEnabled()1344 bool RSSystemProperties::GetGpuOverDrawBufferOptimizeEnabled()
1345 {
1346 static bool flag = system::GetParameter("rosen.gpu.overdraw.optimize.enabled", "0") != "0";
1347 return flag;
1348 }
1349
GetSkipDisplayIfScreenOffEnabled()1350 bool RSSystemProperties::GetSkipDisplayIfScreenOffEnabled()
1351 {
1352 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.screenoffskipdisplayenabled", "1");
1353 int changed = 0;
1354 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1355 return ConvertToInt(num, 1) != 0;
1356 }
1357
GetBatchRemovingOnRemoteDiedEnabled()1358 bool RSSystemProperties::GetBatchRemovingOnRemoteDiedEnabled()
1359 {
1360 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.batchRemovingOnRemoteDied.enabled", "1");
1361 int changed = 0;
1362 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1363 return ConvertToInt(num, 1) != 0;
1364 }
1365
GetOptBatchRemovingOnRemoteDiedEnabled()1366 bool RSSystemProperties::GetOptBatchRemovingOnRemoteDiedEnabled()
1367 {
1368 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.optbatchRemovingOnRemoteDied.enabled", "1");
1369 int changed = 0;
1370 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1371 return ConvertToInt(num, 1) != 0;
1372 }
1373
GetVersionType()1374 std::string RSSystemProperties::GetVersionType()
1375 {
1376 static std::string versionType = system::GetParameter("const.logsystem.versiontype", "");
1377 return versionType;
1378 }
1379
GetHwcDirtyRegionEnabled()1380 bool RSSystemProperties::GetHwcDirtyRegionEnabled()
1381 {
1382 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.hwcdirtyregion.enabled", "1");
1383 int changed = 0;
1384 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1385 return ConvertToInt(num, 1) != 0;
1386 }
1387
GetDrmMarkedFilterEnabled()1388 bool RSSystemProperties::GetDrmMarkedFilterEnabled()
1389 {
1390 static CachedHandle g_Handle = CachedParameterCreate("rosen.drm.markedFilter.enabled", "1");
1391 int changed = 0;
1392 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1393 return ConvertToInt(num, 0);
1394 }
1395
GetHveFilterEnabled()1396 bool RSSystemProperties::GetHveFilterEnabled()
1397 {
1398 static bool hveFilterEnabled =
1399 std::atoi((system::GetParameter("persist.sys.graphic.HveFilterEnable", "1")).c_str()) != 0;
1400 return hveFilterEnabled;
1401 }
1402
GetDmaReclaimParam()1403 bool RSSystemProperties::GetDmaReclaimParam()
1404 {
1405 return system::GetBoolParameter("resourceschedule.memmgr.dma.reclaimable", false);
1406 }
1407
GetOptimizeParentNodeRegionEnabled()1408 bool RSSystemProperties::GetOptimizeParentNodeRegionEnabled()
1409 {
1410 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.optimizeParentNodeRegion.enabled", "1");
1411 int changed = 0;
1412 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1413 return ConvertToInt(enable, 1) != 0;
1414 }
1415
GetOptimizeHwcComposeAreaEnabled()1416 bool RSSystemProperties::GetOptimizeHwcComposeAreaEnabled()
1417 {
1418 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.optimizeHwcComposeArea.enabled", "1");
1419 int changed = 0;
1420 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1421 return ConvertToInt(enable, 1) != 0;
1422 }
1423
GetOptimizeCanvasDrawRegionEnabled()1424 bool RSSystemProperties::GetOptimizeCanvasDrawRegionEnabled()
1425 {
1426 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.optimizeCanvasDrawRegion.enabled", "1");
1427 int changed = 0;
1428 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1429 return ConvertToInt(enable, 1) != 0;
1430 }
1431
GetHpaeBlurUsingAAE()1432 bool RSSystemProperties::GetHpaeBlurUsingAAE()
1433 {
1434 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.hpae.blur.aee.enabled", "0");
1435 int changed = 0;
1436 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1437 return ConvertToInt(enable, 1) != 0;
1438 }
1439
GetWindowKeyFrameEnabled()1440 bool RSSystemProperties::GetWindowKeyFrameEnabled()
1441 {
1442 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.windowkeyframe.enabled", "1");
1443 int changed = 0;
1444 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1445 return ConvertToInt(enable, 1) != 0;
1446 }
1447
GetNodeGroupGroupedByUIEnabled()1448 bool RSSystemProperties::GetNodeGroupGroupedByUIEnabled()
1449 {
1450 static auto groupedByUIEnabled =
1451 system::GetBoolParameter("const.graphic.enable_grouped_by_ui", false);
1452 return groupedByUIEnabled;
1453 }
1454
GetTextureExportDFXEnabled()1455 bool RSSystemProperties::GetTextureExportDFXEnabled()
1456 {
1457 static bool textureexportDFXEnabled =
1458 std::atoi((system::GetParameter("persist.rosen.textureexportdfx.enabled", "0")).c_str()) != 0;
1459 return textureexportDFXEnabled;
1460 }
1461
GetHybridRenderEnabled()1462 bool RSSystemProperties::GetHybridRenderEnabled()
1463 {
1464 // isTypicalResidentProcess_ : currently typical resident process is not allowed to enable hybrid render.
1465 return !isTypicalResidentProcess_ && (GetHybridRenderSystemEnabled() || GetHybridRenderCcmEnabled());
1466 }
1467
GetHybridRenderCcmEnabled()1468 int32_t RSSystemProperties::GetHybridRenderCcmEnabled()
1469 {
1470 static int32_t hybridRenderCcmEnabled = Drawing::SystemProperties::IsUseVulkan() &&
1471 std::atoi((system::GetParameter("const.graphics.hybridrenderenable", "0")).c_str());
1472 return hybridRenderCcmEnabled;
1473 }
1474
1475 // The switch are for scheme debugging. After the scheme is stabilizated, the switch will be removed.
GetHybridRenderSystemEnabled()1476 bool RSSystemProperties::GetHybridRenderSystemEnabled()
1477 {
1478 static bool hybridRenderSystemEnabled = Drawing::SystemProperties::IsUseVulkan() &&
1479 system::GetBoolParameter("persist.sys.graphic.hybrid_render", false);
1480 return hybridRenderSystemEnabled;
1481 }
1482
GetHybridRenderDfxEnabled()1483 bool RSSystemProperties::GetHybridRenderDfxEnabled()
1484 {
1485 static bool hybridRenderDfxEnabled = GetHybridRenderEnabled() &&
1486 system::GetBoolParameter("persist.sys.graphic.hybrid_render_dfx_enabled", false);
1487 return hybridRenderDfxEnabled;
1488 }
1489
GetHybridRenderTextBlobLenCount()1490 uint32_t RSSystemProperties::GetHybridRenderTextBlobLenCount()
1491 {
1492 static uint32_t textBlobLenCount = static_cast<uint32_t>(
1493 system::GetIntParameter("persist.sys.graphic.hybrid_render_text_blob_len_count", DEFAULT_TEXTBLOB_LINE_COUNT));
1494 return textBlobLenCount;
1495 }
1496
ViewDrawNodeType()1497 bool RSSystemProperties::ViewDrawNodeType()
1498 {
1499 static CachedHandle handle = CachedParameterCreate("persist.graphic.ViewDrawNodeType", "0");
1500 int32_t changed = 0;
1501 return ConvertToInt(CachedParameterGetChanged(handle, &changed), 0) != 0;
1502 }
1503
GetHybridRenderParallelConvertEnabled()1504 bool RSSystemProperties::GetHybridRenderParallelConvertEnabled()
1505 {
1506 static bool paraConvertEnabled = GetHybridRenderEnabled() &&
1507 system::GetBoolParameter("persist.sys.graphic.hybrid_render_parallelconvert_enabled", true);
1508 return paraConvertEnabled;
1509 }
1510
1511 // The switch are for scheme debugging. After the scheme is stabilizated, the switch will be removed.
GetHybridRenderCanvasEnabled()1512 bool RSSystemProperties::GetHybridRenderCanvasEnabled()
1513 {
1514 static bool canvasEnabled = GetHybridRenderEnabled() &&
1515 system::GetBoolParameter("persist.sys.graphic.hybrid_render_canvas_drawing_node_enabled", false);
1516 return canvasEnabled;
1517 }
1518
GetHybridRenderMemeoryReleaseEnabled()1519 bool RSSystemProperties::GetHybridRenderMemeoryReleaseEnabled()
1520 {
1521 static bool memoryReleaseEnabled = GetHybridRenderEnabled() &&
1522 system::GetBoolParameter("persist.sys.graphic.hybrid_render_memory_release_enabled", true);
1523 return memoryReleaseEnabled;
1524 }
1525
1526 // The switch are for scheme debugging. After the scheme is stabilizated, the switch will be removed.
GetHybridRenderTextBlobEnabled()1527 bool RSSystemProperties::GetHybridRenderTextBlobEnabled()
1528 {
1529 static bool textblobEnabled = GetHybridRenderEnabled() &&
1530 system::GetBoolParameter("persist.sys.graphic.hybrid_render_textblob_enabled", false);
1531 return textblobEnabled;
1532 }
1533
1534 // The switch are for scheme debugging. After the scheme is stabilizated, the switch will be removed.
GetHybridRenderSvgEnabled()1535 bool RSSystemProperties::GetHybridRenderSvgEnabled()
1536 {
1537 static bool svgEnabled = GetHybridRenderEnabled() &&
1538 system::GetBoolParameter("persist.sys.graphic.hybrid_render_svg_enabled", false);
1539 return svgEnabled;
1540 }
1541
1542 // The switch are for scheme debugging. After the scheme is stabilizated, the switch will be removed.
GetHybridRenderHmsymbolEnabled()1543 bool RSSystemProperties::GetHybridRenderHmsymbolEnabled()
1544 {
1545 static bool hmsymbolEnabled = GetHybridRenderEnabled() &&
1546 system::GetBoolParameter("persist.sys.graphic.hybrid_render_hmsymbol_enabled", false);
1547 return hmsymbolEnabled;
1548 }
1549
GetTypicalResidentProcess()1550 bool RSSystemProperties::GetTypicalResidentProcess()
1551 {
1552 return isTypicalResidentProcess_;
1553 }
1554
SetTypicalResidentProcess(bool isTypicalResidentProcess)1555 void RSSystemProperties::SetTypicalResidentProcess(bool isTypicalResidentProcess)
1556 {
1557 isTypicalResidentProcess_ = isTypicalResidentProcess;
1558 }
1559
GetHybridRenderSwitch(ComponentEnableSwitch bitSeq)1560 bool RSSystemProperties::GetHybridRenderSwitch(ComponentEnableSwitch bitSeq)
1561 {
1562 static int isAccessToVulkanConfigFile = access(VULKAN_CONFIG_FILE_PATH, F_OK);
1563 if (isAccessToVulkanConfigFile == -1) {
1564 ROSEN_LOGD("GetHybridRenderSwitch access to [%{public}s] is denied", VULKAN_CONFIG_FILE_PATH);
1565 return false;
1566 }
1567 char* endPtr = nullptr;
1568 static uint32_t hybridRenderFeatureSwitch =
1569 std::strtoul(system::GetParameter("const.graphics.hybridrenderfeatureswitch", "0x00").c_str(), &endPtr, 16);
1570 static std::vector<int> hybridRenderSystemProperty(std::size(ComponentSwitchTable));
1571
1572 if (bitSeq < ComponentEnableSwitch::TEXTBLOB || bitSeq >= ComponentEnableSwitch::MAX_VALUE) {
1573 return false;
1574 }
1575 if (!GetHybridRenderEnabled()) {
1576 return false;
1577 }
1578
1579 hybridRenderSystemProperty[static_cast<uint32_t>(bitSeq)] =
1580 ComponentSwitchTable[static_cast<uint32_t>(bitSeq)].ComponentHybridSwitch();
1581
1582 uint32_t hybridRenderFeatureSwitchValue = hybridRenderFeatureSwitch == 0 ? 0 :
1583 (1 << static_cast<uint32_t>(bitSeq)) & hybridRenderFeatureSwitch;
1584 return (GetHybridRenderCcmEnabled() && hybridRenderFeatureSwitchValue != 0) ||
1585 hybridRenderSystemProperty[static_cast<uint32_t>(bitSeq)];
1586 }
1587
GetVKImageUseEnabled()1588 bool RSSystemProperties::GetVKImageUseEnabled()
1589 {
1590 static bool enable = IsUseVulkan() &&
1591 system::GetBoolParameter("persist.sys.graphic.vkimage_reuse", true);
1592 return enable;
1593 }
1594
SetDebugFmtTraceEnabled(bool flag)1595 void RSSystemProperties::SetDebugFmtTraceEnabled(bool flag)
1596 {
1597 debugFmtTraceEnable_ = flag;
1598 ROSEN_LOGI("RSSystemProperties::SetDebugFmtTraceEnabled:%{public}d", debugFmtTraceEnable_);
1599 }
1600
GetDebugFmtTraceEnabled()1601 bool RSSystemProperties::GetDebugFmtTraceEnabled()
1602 {
1603 return GetDebugTraceEnabled() || debugFmtTraceEnable_;
1604 }
1605
SetBehindWindowFilterEnabled(bool enabled)1606 void RSSystemProperties::SetBehindWindowFilterEnabled(bool enabled)
1607 {
1608 isBehindWindowFilterEnabled_ = enabled;
1609 }
1610
GetBehindWindowFilterEnabled()1611 bool RSSystemProperties::GetBehindWindowFilterEnabled()
1612 {
1613 return isBehindWindowFilterEnabled_;
1614 }
1615
GetSubThreadControlFrameRate()1616 bool RSSystemProperties::GetSubThreadControlFrameRate()
1617 {
1618 static bool subThreadControlFrameRateEnable =
1619 system::GetBoolParameter("const.graphic.subthread.control.framerate", false);
1620 return subThreadControlFrameRateEnable;
1621 }
1622
GetSubThreadDropFrameInterval()1623 int RSSystemProperties::GetSubThreadDropFrameInterval()
1624 {
1625 static bool dropFrameInterval =
1626 system::GetIntParameter("const.graphic.subthread.dropframe.interval", 1);
1627 return dropFrameInterval;
1628 }
1629
GetCompositeLayerEnabled()1630 bool RSSystemProperties::GetCompositeLayerEnabled()
1631 {
1632 static bool compositeLayerEnable =
1633 system::GetBoolParameter("rosen.graphic.composite.layer", true);
1634 return compositeLayerEnable;
1635 }
1636
GetEarlyZEnable()1637 bool RSSystemProperties::GetEarlyZEnable()
1638 {
1639 return isEnableEarlyZ_;
1640 }
1641
GetAIBarOptEnabled()1642 bool RSSystemProperties::GetAIBarOptEnabled()
1643 {
1644 static bool isAIBarOptEnabled = system::GetIntParameter("persist.rosen.aibaropt.enabled", 1) != 0;
1645 return isAIBarOptEnabled;
1646 }
1647
GetRSMemoryInfoManagerParam()1648 bool RSSystemProperties::GetRSMemoryInfoManagerParam()
1649 {
1650 return false;
1651 }
1652
GetSupportScreenFreezeEnabled()1653 bool RSSystemProperties::GetSupportScreenFreezeEnabled()
1654 {
1655 static CachedHandle g_Handle = CachedParameterCreate("rosen.debug.screen.freeze.enabled", "1");
1656 int changed = 0;
1657 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1658 return ConvertToInt(enable, 1) != 0;
1659 }
1660
GetSelfDrawingDirtyRegionEnabled()1661 bool RSSystemProperties::GetSelfDrawingDirtyRegionEnabled()
1662 {
1663 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.selfdrawingdirtyregion.enabled", "0");
1664 int changed = 0;
1665 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1666 return ConvertToInt(enable, 0) != 0;
1667 }
1668
GetGpuDirtyApsEnabled()1669 bool RSSystemProperties::GetGpuDirtyApsEnabled()
1670 {
1671 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.gpudirtyaps.enabled", "0");
1672 int changed = 0;
1673 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1674 return ConvertToInt(enable, 0) != 0;
1675 }
1676 } // namespace Rosen
1677 } // namespace OHOS
1678