1 /*
2 * Copyright (c) 2021-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 "platform/common/rs_system_properties.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 #include "transaction/rs_render_service_client.h"
24 #include "scene_board_judgement.h"
25 #include "pipeline/rs_uni_render_judgement.h"
26
27 namespace OHOS {
28 namespace Rosen {
29 namespace {
30 constexpr int DEFAULT_CACHE_WIDTH = 1250;
31 constexpr int DEFAULT_CACHE_HEIGHT = 2710;
32 constexpr int DEFAULT_PARTIAL_RENDER_ENABLED_VALUE = 2;
33 constexpr int DEFAULT_UNI_PARTIAL_RENDER_ENABLED_VALUE = 4;
34 constexpr int DEFAULT_ADVANCED_DIRTY_REGION_ENABLED_VALUE = 1;
35 constexpr int DEFAULT_DIRTY_ALIGN_ENABLED_VALUE = 0;
36 constexpr int DEFAULT_CORRECTION_MODE_VALUE = 999;
37 constexpr int DEFAULT_SCALE_MODE = 2;
38 constexpr const char* DEFAULT_CLIP_RECT_THRESHOLD = "0.9";
39 }
40
41 #if (defined (ACE_ENABLE_GL) && defined (ACE_ENABLE_VK)) || (defined (RS_ENABLE_GL) && defined (RS_ENABLE_VK))
42 const GpuApiType RSSystemProperties::systemGpuApiType_ = Drawing::SystemProperties::GetGpuApiType();
43 #elif defined (ACE_ENABLE_GL) || defined (RS_ENABLE_GL)
44 const GpuApiType RSSystemProperties::systemGpuApiType_ = GpuApiType::OPENGL;
45 #else
46 const GpuApiType RSSystemProperties::systemGpuApiType_ = GpuApiType::VULKAN;
47 #endif
48
ConvertToInt(const char * originValue,int defaultValue)49 int ConvertToInt(const char *originValue, int defaultValue)
50 {
51 return originValue == nullptr ? defaultValue : std::atoi(originValue);
52 }
ParseDfxSurfaceNamesString(const std::string & paramsStr,std::vector<std::string> & splitStrs,const std::string & seperator)53 static void ParseDfxSurfaceNamesString(const std::string& paramsStr,
54 std::vector<std::string>& splitStrs, const std::string& seperator)
55 {
56 std::string::size_type pos1 = 0;
57 std::string::size_type pos2 = paramsStr.find(seperator);
58 if (std::string::npos == pos2) {
59 splitStrs.push_back(paramsStr);
60 return;
61 }
62 while (std::string::npos != pos2) {
63 splitStrs.push_back(paramsStr.substr(pos1, pos2 - pos1));
64 pos1 = pos2 + seperator.size();
65 pos2 = paramsStr.find(seperator, pos1);
66 }
67 if (pos1 != paramsStr.length()) {
68 splitStrs.push_back(paramsStr.substr(pos1));
69 }
70 }
71
IsSceneBoardEnabled()72 bool RSSystemProperties::IsSceneBoardEnabled()
73 {
74 static bool isSCBEnabled = SceneBoardJudgement::IsSceneBoardEnabled();
75 return isSCBEnabled;
76 }
77
78 // used by clients
GetDumpFrameNum()79 int RSSystemProperties::GetDumpFrameNum()
80 {
81 static CachedHandle g_Handle = CachedParameterCreate("rosen.recording.frameNum", "0");
82 int changed = 0;
83 const char *num = CachedParameterGetChanged(g_Handle, &changed);
84 return ConvertToInt(num, 0);
85 }
86
GetSceneJankFrameThreshold()87 int RSSystemProperties::GetSceneJankFrameThreshold()
88 {
89 static int sceneJankFrameThreshold =
90 std::stoi((system::GetParameter("persist.sys.graphic.sceneJankFrameThreshold", "50")).c_str());
91 return sceneJankFrameThreshold;
92 }
93
GetRecordingEnabled()94 int RSSystemProperties::GetRecordingEnabled()
95 {
96 static CachedHandle g_Handle = CachedParameterCreate("debug.graphic.recording.enabled", "0");
97 int changed = 0;
98 const char *num = CachedParameterGetChanged(g_Handle, &changed);
99 return ConvertToInt(num, 0);
100 }
101
102
SetRecordingDisenabled()103 void RSSystemProperties::SetRecordingDisenabled()
104 {
105 system::SetParameter("debug.graphic.recording.enabled", "0");
106 RS_LOGD("RSSystemProperties::SetRecordingDisenabled");
107 }
108
GetProfilerEnabled()109 bool RSSystemProperties::GetProfilerEnabled()
110 {
111 static CachedHandle handle = CachedParameterCreate("persist.graphic.profiler.enabled", "0");
112 int32_t changed = 0;
113 return ConvertToInt(CachedParameterGetChanged(handle, &changed), 0) != 0;
114 }
115
SetProfilerDisabled()116 void RSSystemProperties::SetProfilerDisabled()
117 {
118 system::SetParameter("persist.graphic.profiler.enabled", "0");
119 }
120
GetVkQueuePriorityEnable()121 bool RSSystemProperties::GetVkQueuePriorityEnable()
122 {
123 static bool vkQueuePriorityEnabled =
124 std::atoi((system::GetParameter("persist.vkqueue.priority.enalbed", "1")).c_str()) != 0;
125 return vkQueuePriorityEnabled;
126 }
127
GetInstantRecording()128 bool RSSystemProperties::GetInstantRecording()
129 {
130 return (system::GetParameter("debug.graphic.instant.recording.enabled", "0") != "0");
131 }
132
SetInstantRecording(bool flag)133 void RSSystemProperties::SetInstantRecording(bool flag)
134 {
135 system::SetParameter("debug.graphic.instant.recording.enabled", flag ? "1" : "0");
136 }
137
GetBetaRecordingMode()138 uint32_t RSSystemProperties::GetBetaRecordingMode()
139 {
140 static CachedHandle handle = CachedParameterCreate("persist.graphic.profiler.betarecording", "0");
141 int32_t changed = 0;
142 const char* state = CachedParameterGetChanged(handle, &changed);
143 return ConvertToInt(state, 0);
144 }
145
SetBetaRecordingMode(uint32_t param)146 void RSSystemProperties::SetBetaRecordingMode(uint32_t param)
147 {
148 system::SetParameter("persist.graphic.profiler.betarecording", std::to_string(param));
149 }
150
GetSaveRDC()151 bool RSSystemProperties::GetSaveRDC()
152 {
153 return (system::GetParameter("debug.graphic.rdcenabled", "0") != "0");
154 }
155
SetSaveRDC(bool flag)156 void RSSystemProperties::SetSaveRDC(bool flag)
157 {
158 system::SetParameter("debug.graphic.rdcenabled", flag ? "1" : "0");
159 }
160
GetRecordingFile()161 std::string RSSystemProperties::GetRecordingFile()
162 {
163 static CachedHandle g_Handle = CachedParameterCreate("rosen.dumpfile.path", "");
164 int changed = 0;
165 const char *file = CachedParameterGetChanged(g_Handle, &changed);
166 return file == nullptr ? "" : file;
167 }
168
GetUniRenderEnabled()169 bool RSSystemProperties::GetUniRenderEnabled()
170 {
171 static bool inited = false;
172 if (inited) {
173 return isUniRenderEnabled_;
174 }
175
176 isUniRenderEnabled_ = std::static_pointer_cast<RSRenderServiceClient>(RSIRenderClient::CreateRenderServiceClient())
177 ->GetUniRenderEnabled();
178 inited = true;
179 ROSEN_LOGD("RSSystemProperties::GetUniRenderEnabled:%{public}d", isUniRenderEnabled_);
180 return isUniRenderEnabled_;
181 }
182
GetDrawOpTraceEnabled()183 bool RSSystemProperties::GetDrawOpTraceEnabled()
184 {
185 static bool code = system::GetParameter("persist.rosen.drawoptrace.enabled", "0") != "0";
186 return code;
187 }
188
GetRenderNodeTraceEnabled()189 bool RSSystemProperties::GetRenderNodeTraceEnabled()
190 {
191 static bool isNeedTrace = system::GetParameter("persist.rosen.rendernodetrace.enabled", "0") != "0";
192 return isNeedTrace;
193 }
194
GetAnimationTraceEnabled()195 bool RSSystemProperties::GetAnimationTraceEnabled()
196 {
197 static bool isNeedTrace = system::GetParameter("persist.rosen.animationtrace.enabled", "0") != "0";
198 return isNeedTrace;
199 }
200
GetRSClientMultiInstanceEnabled()201 bool RSSystemProperties::GetRSClientMultiInstanceEnabled()
202 {
203 static bool isMultiInstance = system::GetParameter("persist.rosen.rsclientmultiinstance.enabled", "1") != "0";
204 return isMultiInstance;
205 }
206
GetRSScreenRoundCornerEnable()207 bool RSSystemProperties::GetRSScreenRoundCornerEnable()
208 {
209 static bool isNeedScreenRCD = system::GetParameter("persist.rosen.screenroundcornerrcd.enabled", "1") != "0";
210 return isNeedScreenRCD;
211 }
212
GetRenderNodePurgeEnabled()213 bool RSSystemProperties::GetRenderNodePurgeEnabled()
214 {
215 static bool isPurgeable = system::GetParameter("persist.rosen.rendernode.purge.enabled", "1") != "0";
216 return isPurgeable;
217 }
218
GetRSImagePurgeEnabled()219 bool RSSystemProperties::GetRSImagePurgeEnabled()
220 {
221 static bool isPurgeable = system::GetParameter("persist.rosen.rsimage.purge.enabled", "1") != "0";
222 return isPurgeable;
223 }
224
GetClosePixelMapFdEnabled()225 bool RSSystemProperties::GetClosePixelMapFdEnabled()
226 {
227 static bool isClosePixelMapFd = system::GetParameter("persist.rosen.rsimage.close.fd", "0") != "0";
228 return isClosePixelMapFd;
229 }
230
GetDirtyRegionDebugType()231 DirtyRegionDebugType RSSystemProperties::GetDirtyRegionDebugType()
232 {
233 static CachedHandle g_Handle = CachedParameterCreate("rosen.dirtyregiondebug.enabled", "0");
234 int changed = 0;
235 const char *type = CachedParameterGetChanged(g_Handle, &changed);
236 return static_cast<DirtyRegionDebugType>(ConvertToInt(type, 0));
237 }
238
GetPartialRenderEnabled()239 PartialRenderType RSSystemProperties::GetPartialRenderEnabled()
240 {
241 static CachedHandle g_Handle = CachedParameterCreate("rosen.partialrender.enabled", "2");
242 int changed = 0;
243 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
244 return static_cast<PartialRenderType>(ConvertToInt(enable, DEFAULT_PARTIAL_RENDER_ENABLED_VALUE));
245 }
246
GetUniPartialRenderEnabled()247 PartialRenderType RSSystemProperties::GetUniPartialRenderEnabled()
248 {
249 int changed = 0;
250 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.partialrender.enabled", "4");
251 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
252 return static_cast<PartialRenderType>(ConvertToInt(enable, DEFAULT_UNI_PARTIAL_RENDER_ENABLED_VALUE));
253 }
254
GetStencilPixelOcclusionCullingEnabled()255 StencilPixelOcclusionCullingType RSSystemProperties::GetStencilPixelOcclusionCullingEnabled()
256 {
257 static CachedHandle g_Handle = CachedParameterCreate("rosen.stencilpixelocclusionculling.enabled", "-1");
258 int changed = 0;
259 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
260 return static_cast<StencilPixelOcclusionCullingType>(ConvertToInt(enable,
261 static_cast<int>(StencilPixelOcclusionCullingType::DEFAULT)));
262 }
263
GetAdvancedDirtyRegionEnabled()264 AdvancedDirtyRegionType RSSystemProperties::GetAdvancedDirtyRegionEnabled()
265 {
266 static CachedHandle g_Handle = CachedParameterCreate("rosen.advanceddirtyregion.enabled", "1");
267 int changed = 0;
268 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
269 return static_cast<AdvancedDirtyRegionType>(ConvertToInt(enable, DEFAULT_ADVANCED_DIRTY_REGION_ENABLED_VALUE));
270 }
271
GetDirtyAlignEnabled()272 DirtyAlignType RSSystemProperties::GetDirtyAlignEnabled()
273 {
274 static CachedHandle g_Handle = CachedParameterCreate("rosen.dirtyalign.enabled", "0");
275 int changed = 0;
276 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
277 return static_cast<DirtyAlignType>(ConvertToInt(enable, DEFAULT_DIRTY_ALIGN_ENABLED_VALUE));
278 }
279
GetClipRectThreshold()280 float RSSystemProperties::GetClipRectThreshold()
281 {
282 int changed = 0;
283 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.cliprect.threshold", DEFAULT_CLIP_RECT_THRESHOLD);
284 const char *threshold = CachedParameterGetChanged(g_Handle, &changed);
285 return threshold == nullptr ? std::atof(DEFAULT_CLIP_RECT_THRESHOLD) : std::atof(threshold);
286 }
287
GetAllSurfaceVisibleDebugEnabled()288 bool RSSystemProperties::GetAllSurfaceVisibleDebugEnabled()
289 {
290 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.allsurfacevisibledebug.enabled", "0");
291 int changed = 0;
292 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
293 return ConvertToInt(enable, 0) != 0;
294 }
295
GetVirtualDirtyDebugEnabled()296 bool RSSystemProperties::GetVirtualDirtyDebugEnabled()
297 {
298 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.virtualdirtydebug.enabled", "0");
299 int changed = 0;
300 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
301 return ConvertToInt(enable, 0) != 0;
302 }
303
GetVirtualDirtyEnabled()304 bool RSSystemProperties::GetVirtualDirtyEnabled()
305 {
306 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.virtualdirty.enabled", "1");
307 int changed = 0;
308 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
309 return ConvertToInt(enable, 0) != 0;
310 }
311
GetExpandScreenDirtyEnabled()312 bool RSSystemProperties::GetExpandScreenDirtyEnabled()
313 {
314 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.expandscreendirty.enabled", "0");
315 int changed = 0;
316 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
317 return ConvertToInt(enable, 0) != 0;
318 }
319
GetReleaseResourceEnabled()320 bool RSSystemProperties::GetReleaseResourceEnabled()
321 {
322 static CachedHandle g_Handle = CachedParameterCreate("persist.release.gpuresource.enabled", "1");
323 int changed = 0;
324 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
325 return ConvertToInt(enable, 1) != 0;
326 }
327
GetReclaimMemoryEnabled()328 bool RSSystemProperties::GetReclaimMemoryEnabled()
329 {
330 static CachedHandle g_Handle = CachedParameterCreate("persist.reclaim.memory.enabled", "1");
331 int changed = 0;
332 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
333 return (ConvertToInt(enable, 1) != 0) && (system::GetParameter("const.product.devicetype", "pc") != "wearable");
334 }
335
GetOcclusionEnabled()336 bool RSSystemProperties::GetOcclusionEnabled()
337 {
338 static CachedHandle g_Handle = CachedParameterCreate("rosen.occlusion.enabled", "1");
339 int changed = 0;
340 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
341 return ConvertToInt(enable, 1) != 0;
342 }
343
GetHardwareComposerEnabled()344 bool RSSystemProperties::GetHardwareComposerEnabled()
345 {
346 static bool hardwareComposerEnabled = system::GetParameter(
347 "persist.rosen.hardwarecomposer.enabled", "1") != "0";
348 return hardwareComposerEnabled;
349 }
350
GetDoDirectCompositionEnabled()351 bool RSSystemProperties::GetDoDirectCompositionEnabled()
352 {
353 static bool doDirectCompositionEnabled = system::GetParameter(
354 "persist.rosen.doDirectComposition.enabled", "1") != "0";
355 return doDirectCompositionEnabled;
356 }
357
GetDumpRsTreeDetailEnabled()358 bool RSSystemProperties::GetDumpRsTreeDetailEnabled()
359 {
360 static bool dumpRsTreeDetailEnabled = system::GetParameter(
361 "persist.rosen.dumpRsTreeDetail.enabled", "0") != "0";
362 return dumpRsTreeDetailEnabled;
363 }
364
GetHardwareComposerEnabledForMirrorMode()365 bool RSSystemProperties::GetHardwareComposerEnabledForMirrorMode()
366 {
367 static bool hardwareComposerMirrorEnabled =
368 system::GetParameter("persist.rosen.hardwarecomposer.mirror.enabled", "1") != "0";
369 return hardwareComposerMirrorEnabled;
370 }
371
GetHwcRegionDfxEnabled()372 bool RSSystemProperties::GetHwcRegionDfxEnabled()
373 {
374 static bool hwcRegionDfxEnabled = system::GetParameter(
375 "persist.rosen.hwcRegionDfx.enabled", "0") != "0";
376 return hwcRegionDfxEnabled;
377 }
378
GetDrawMirrorCacheImageEnabled()379 bool RSSystemProperties::GetDrawMirrorCacheImageEnabled()
380 {
381 static CachedHandle g_Handle = CachedParameterCreate("rosen.cacheimage.mirror.enabled", "1");
382 int changed = 0;
383 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
384 return ConvertToInt(enable, 0) != 0;
385 }
386
GetPixelmapDfxEnabled()387 bool RSSystemProperties::GetPixelmapDfxEnabled()
388 {
389 static CachedHandle g_Handle = CachedParameterCreate("rosen.pixelmapdfx.enabled", "0");
390 int changed = 0;
391 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
392 return ConvertToInt(enable, 0) != 0;
393 }
394
GetAFBCEnabled()395 bool RSSystemProperties::GetAFBCEnabled()
396 {
397 static CachedHandle g_Handle = CachedParameterCreate("rosen.afbc.enabled", "1");
398 int changed = 0;
399 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
400 return ConvertToInt(enable, 1) != 0;
401 }
402
GetRSEventProperty(const std::string & paraName)403 std::string RSSystemProperties::GetRSEventProperty(const std::string ¶Name)
404 {
405 return system::GetParameter(paraName, "0");
406 }
407
GetHighContrastStatus()408 bool RSSystemProperties::GetHighContrastStatus()
409 {
410 // If the value of rosen.directClientComposition.enabled is not 0 then enable the direct CLIENT composition.
411 // Direct CLIENT composition will be processed only when the num of layer is larger than 11
412 static CachedHandle g_Handle = CachedParameterCreate("rosen.HighContrast.enabled", "0");
413 int changed = 0;
414 const char *status = CachedParameterGetChanged(g_Handle, &changed);
415 return ConvertToInt(status, 0) != 0;
416 }
417
GetDrmEnabled()418 bool RSSystemProperties::GetDrmEnabled()
419 {
420 static CachedHandle g_Handle = CachedParameterCreate("rosen.drm.enabled", "1");
421 int changed = 0;
422 const char *enabled = CachedParameterGetChanged(g_Handle, &changed);
423 return ConvertToInt(enabled, 0) != 0;
424 }
425
GetTargetDirtyRegionDfxEnabled(std::vector<std::string> & dfxTargetSurfaceNames_)426 bool RSSystemProperties::GetTargetDirtyRegionDfxEnabled(std::vector<std::string>& dfxTargetSurfaceNames_)
427 {
428 static CachedHandle g_Handle = CachedParameterCreate("rosen.dirtyregiondebug.surfacenames", "0");
429 int changed = 0;
430 const char *targetSurfacesStr = CachedParameterGetChanged(g_Handle, &changed);
431 if (targetSurfacesStr == nullptr || strcmp(targetSurfacesStr, "0") == 0) {
432 dfxTargetSurfaceNames_.clear();
433 return false;
434 }
435 dfxTargetSurfaceNames_.clear();
436 ParseDfxSurfaceNamesString(targetSurfacesStr, dfxTargetSurfaceNames_, ",");
437 return true;
438 }
439
GetOpaqueRegionDfxEnabled()440 bool RSSystemProperties::GetOpaqueRegionDfxEnabled()
441 {
442 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.opaqueregiondebug", "0");
443 int changed = 0;
444 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
445 return ConvertToInt(enable, 0) != 0;
446 }
447
GetVisibleRegionDfxEnabled()448 bool RSSystemProperties::GetVisibleRegionDfxEnabled()
449 {
450 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.visibleregiondebug", "0");
451 int changed = 0;
452 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
453 return ConvertToInt(enable, 0) != 0;
454 }
455
GetSurfaceRegionDfxType()456 SurfaceRegionDebugType RSSystemProperties::GetSurfaceRegionDfxType()
457 {
458 static CachedHandle g_Handle = CachedParameterCreate("rosen.uni.surfaceregiondebug", "0");
459 int changed = 0;
460 const char *type = CachedParameterGetChanged(g_Handle, &changed);
461 return static_cast<SurfaceRegionDebugType>(ConvertToInt(type, 0));
462 }
463
GetCorrectionMode()464 uint32_t RSSystemProperties::GetCorrectionMode()
465 {
466 // If the value of rosen.directClientComposition.enabled is not 0 then enable the direct CLIENT composition.
467 // Direct CLIENT composition will be processed only when the num of layer is larger than 11
468 static CachedHandle g_Handle = CachedParameterCreate("rosen.CorrectionMode", "999");
469 int changed = 0;
470 const char *mode = CachedParameterGetChanged(g_Handle, &changed);
471 return ConvertToInt(mode, DEFAULT_CORRECTION_MODE_VALUE);
472 }
473
GetDumpSurfaceType()474 DumpSurfaceType RSSystemProperties::GetDumpSurfaceType()
475 {
476 static CachedHandle g_Handle = CachedParameterCreate("rosen.dumpsurfacetype.enabled", "0");
477 int changed = 0;
478 const char *type = CachedParameterGetChanged(g_Handle, &changed);
479 return static_cast<DumpSurfaceType>(ConvertToInt(type, 0));
480 }
481
GetDumpSurfaceId()482 long long int RSSystemProperties::GetDumpSurfaceId()
483 {
484 static CachedHandle g_Handle = CachedParameterCreate("rosen.dumpsurfaceid", "0");
485 int changed = 0;
486 const char *surfaceId = CachedParameterGetChanged(g_Handle, &changed);
487 return surfaceId == nullptr ? std::atoll("0") : std::atoll(surfaceId);
488 }
489
GetDumpLayersEnabled()490 bool RSSystemProperties::GetDumpLayersEnabled()
491 {
492 static CachedHandle g_Handle = CachedParameterCreate("rosen.dumplayer.enabled", "0");
493 int changed = 0;
494 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
495 return ConvertToInt(enable, 0) != 0;
496 }
497
SetDrawTextAsBitmap(bool flag)498 void RSSystemProperties::SetDrawTextAsBitmap(bool flag)
499 {
500 isDrawTextAsBitmap_ = flag;
501 }
GetDrawTextAsBitmap()502 bool RSSystemProperties::GetDrawTextAsBitmap()
503 {
504 return isDrawTextAsBitmap_;
505 }
506
SetCacheEnabledForRotation(bool flag)507 void RSSystemProperties::SetCacheEnabledForRotation(bool flag)
508 {
509 cacheEnabledForRotation_ = flag;
510 }
511
GetCacheEnabledForRotation()512 bool RSSystemProperties::GetCacheEnabledForRotation()
513 {
514 return cacheEnabledForRotation_;
515 }
516
GetPrepareParallelRenderingEnabled()517 ParallelRenderingType RSSystemProperties::GetPrepareParallelRenderingEnabled()
518 {
519 static ParallelRenderingType systemPropertiePrepareType = static_cast<ParallelRenderingType>(
520 std::atoi((system::GetParameter("persist.rosen.prepareparallelrender.enabled", "1")).c_str()));
521 return systemPropertiePrepareType;
522 }
523
GetParallelRenderingEnabled()524 ParallelRenderingType RSSystemProperties::GetParallelRenderingEnabled()
525 {
526 static ParallelRenderingType systemPropertieType = static_cast<ParallelRenderingType>(
527 std::atoi((system::GetParameter("persist.rosen.parallelrender.enabled", "0")).c_str()));
528 return systemPropertieType;
529 }
530
GetSurfaceNodeWatermarkEnabled()531 bool RSSystemProperties::GetSurfaceNodeWatermarkEnabled()
532 {
533 static bool watermark =
534 std::atoi((system::GetParameter("persist.rosen.watermark.enabled", "1")).c_str()) != 0;
535 return watermark;
536 }
537
GetHgmRefreshRatesEnabled()538 HgmRefreshRates RSSystemProperties::GetHgmRefreshRatesEnabled()
539 {
540 static CachedHandle g_Handle = CachedParameterCreate("rosen.sethgmrefreshrate.enabled", "0");
541 int changed = 0;
542 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
543 return static_cast<HgmRefreshRates>(ConvertToInt(enable, 0));
544 }
545
SetHgmRefreshRateModesEnabled(std::string param)546 void RSSystemProperties::SetHgmRefreshRateModesEnabled(std::string param)
547 {
548 system::SetParameter("persist.rosen.sethgmrefreshratemode.enabled", param);
549 RS_LOGI("RSSystemProperties::SetHgmRefreshRateModesEnabled set to %{public}s", param.c_str());
550 }
551
GetHgmRefreshRateModesEnabled()552 HgmRefreshRateModes RSSystemProperties::GetHgmRefreshRateModesEnabled()
553 {
554 static CachedHandle g_Handle = CachedParameterCreate("persist.rosen.sethgmrefreshratemode.enabled", "0");
555 int changed = 0;
556 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
557 return static_cast<HgmRefreshRateModes>(ConvertToInt(enable, 0));
558 }
559
GetHardCursorEnabled()560 bool RSSystemProperties::GetHardCursorEnabled()
561 {
562 static CachedHandle g_Handle = CachedParameterCreate("rosen.hardCursor.enabled", "1");
563 int changed = 0;
564 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
565 return ConvertToInt(enable, 1) != 0;
566 }
567
GetSkipForAlphaZeroEnabled()568 bool RSSystemProperties::GetSkipForAlphaZeroEnabled()
569 {
570 static CachedHandle g_Handle = CachedParameterCreate("persist.skipForAlphaZero.enabled", "1");
571 int changed = 0;
572 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
573 return ConvertToInt(enable, 1) != 0;
574 }
575
GetSkipGeometryNotChangeEnabled()576 bool RSSystemProperties::GetSkipGeometryNotChangeEnabled()
577 {
578 static bool skipGeoNotChangeEnabled =
579 std::atoi((system::GetParameter("persist.skipGeometryNotChange.enabled", "1")).c_str()) != 0;
580 return skipGeoNotChangeEnabled;
581 }
582
GetAnimationCacheEnabled()583 bool RSSystemProperties::GetAnimationCacheEnabled()
584 {
585 static bool animationCacheEnabled =
586 std::atoi((system::GetParameter("persist.animation.cache.enabled", "0")).c_str()) != 0;
587 return animationCacheEnabled;
588 }
589
GetAnimationScale()590 float RSSystemProperties::GetAnimationScale()
591 {
592 static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.animationscale", "1.0");
593 int changed = 0;
594 const char *scale = CachedParameterGetChanged(g_Handle, &changed);
595 return scale == nullptr ? std::atof("1.0") : std::atof(scale);
596 }
597
GetFilterCacheEnabled()598 bool RSSystemProperties::GetFilterCacheEnabled()
599 {
600 // Determine whether the filter cache should be enabled. The default value is 1, which means that it is enabled.
601 // If dirty-region is not properly implemented, the filter cache will act as a skip-frame strategy for filters.
602 static bool filterCacheEnabled =
603 std::atoi((system::GetParameter("persist.sys.graphic.filterCacheEnabled", "1")).c_str()) != 0;
604 return filterCacheEnabled;
605 }
606
GetFilterCacheUpdateInterval()607 int RSSystemProperties::GetFilterCacheUpdateInterval()
608 {
609 // Configure whether to enable skip-frame for the filter cache. The default value is 1, which means that the cached
610 // image is updated with a delay of 1 frame.
611 static int filterCacheUpdateInterval =
612 std::atoi((system::GetParameter("persist.sys.graphic.filterCacheUpdateInterval", "1")).c_str());
613 return filterCacheUpdateInterval;
614 }
615
GetFilterCacheSizeThreshold()616 int RSSystemProperties::GetFilterCacheSizeThreshold()
617 {
618 // Set the minimum size for enabling skip-frame in the filter cache. By default, this value is 400, which means that
619 // skip-frame is only enabled for regions where both the width and height are greater than 400.
620 static int filterCacheSizeThreshold =
621 std::atoi((system::GetParameter("persist.sys.graphic.filterCacheSizeThreshold", "400")).c_str());
622 return filterCacheSizeThreshold;
623 }
624
GetMaskLinearBlurEnabled()625 bool RSSystemProperties::GetMaskLinearBlurEnabled()
626 {
627 // Determine whether the mask LinearBlur render should be enabled. The default value is 0,
628 // which means that it is unenabled.
629 static bool enabled =
630 std::atoi((system::GetParameter("persist.sys.graphic.maskLinearBlurEnabled", "1")).c_str()) != 0;
631 return enabled;
632 }
633
GetMotionBlurEnabled()634 bool RSSystemProperties::GetMotionBlurEnabled()
635 {
636 // Determine whether the motionBlur render should be enabled. The default value is 0,
637 // which means that it is unenabled.
638 static bool enabled =
639 std::atoi((system::GetParameter("persist.sys.graphic.motionBlurEnabled", "1")).c_str()) != 0;
640 return enabled;
641 }
642
GetSLRScaleEnabled()643 bool RSSystemProperties::GetSLRScaleEnabled()
644 {
645 static CachedHandle g_Handle = CachedParameterCreate("rosen.SLRScale.enabled", "1");
646 int changed = 0;
647 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
648 return ConvertToInt(enable, 1) != 0;
649 }
650
GetDynamicBrightnessEnabled()651 bool RSSystemProperties::GetDynamicBrightnessEnabled()
652 {
653 // Determine whether the daynamic brightness render should be enabled. The default value is 1,
654 // which means that it is enabled.
655 static bool enabled =
656 std::atoi((system::GetParameter("persist.sys.graphic.dynamicBrightnessEnabled", "1")).c_str()) != 0;
657 return enabled;
658 }
659
GetMagnifierEnabled()660 bool RSSystemProperties::GetMagnifierEnabled()
661 {
662 // Determine whether the magnifier render should be enabled. The default value is 0,
663 // which means that it is unenabled.
664 static bool enabled =
665 std::atoi((system::GetParameter("persist.sys.graphic.magnifierEnabled", "1")).c_str()) != 0;
666 return enabled;
667 }
668
GetKawaseEnabled()669 bool RSSystemProperties::GetKawaseEnabled()
670 {
671 static bool kawaseBlurEnabled =
672 std::atoi((system::GetParameter("persist.sys.graphic.kawaseEnable", "1")).c_str()) != 0;
673 return kawaseBlurEnabled;
674 }
675
SetForceHpsBlurDisabled(bool flag)676 void RSSystemProperties::SetForceHpsBlurDisabled(bool flag)
677 {
678 forceHpsBlurDisabled_ = flag;
679 }
680
GetHpsBlurNoiseFactor()681 float RSSystemProperties::GetHpsBlurNoiseFactor()
682 {
683 static float noiseFactor =
684 std::atof((system::GetParameter("persist.sys.graphic.HpsBlurNoiseFactor", "1.75")).c_str());
685 return noiseFactor;
686 }
687
GetHpsBlurEnabled()688 bool RSSystemProperties::GetHpsBlurEnabled()
689 {
690 static bool hpsBlurEnabled =
691 std::atoi((system::GetParameter("persist.sys.graphic.HpsBlurEnable", "1")).c_str()) != 0;
692 return hpsBlurEnabled && !forceHpsBlurDisabled_;
693 }
694
GetMESABlurFuzedEnabled()695 bool RSSystemProperties::GetMESABlurFuzedEnabled()
696 {
697 static bool blurPixelStretchEnabled =
698 std::atoi((system::GetParameter("persist.sys.graphic.mesaBlurFuzedEnable", "1")).c_str()) != 0;
699 return blurPixelStretchEnabled;
700 }
701
GetSimplifiedMesaEnabled()702 int RSSystemProperties::GetSimplifiedMesaEnabled()
703 {
704 static int simplifiedMesaEnabled =
705 std::atoi((system::GetParameter("persist.sys.graphic.simplifiedMesaEnable", "0")).c_str());
706 return simplifiedMesaEnabled;
707 }
708
GetForceKawaseDisabled()709 bool RSSystemProperties::GetForceKawaseDisabled()
710 {
711 static bool kawaseDisabled =
712 std::atoi((system::GetParameter("persist.sys.graphic.kawaseDisable", "0")).c_str()) != 0;
713 return kawaseDisabled;
714 }
715
GetKawaseRandomColorFactor()716 float RSSystemProperties::GetKawaseRandomColorFactor()
717 {
718 static float randomFactor =
719 std::atof((system::GetParameter("persist.sys.graphic.kawaseFactor", "1.75")).c_str());
720 return randomFactor;
721 }
722
GetRandomColorEnabled()723 bool RSSystemProperties::GetRandomColorEnabled()
724 {
725 static bool randomColorEnabled =
726 std::atoi((system::GetParameter("persist.sys.graphic.randomColorEnable", "1")).c_str()) != 0;
727 return randomColorEnabled;
728 }
729
GetKawaseOriginalEnabled()730 bool RSSystemProperties::GetKawaseOriginalEnabled()
731 {
732 static bool kawaseOriginalEnabled =
733 std::atoi((system::GetParameter("persist.sys.graphic.kawaseOriginalEnable", "0")).c_str()) != 0;
734 return kawaseOriginalEnabled;
735 }
736
GetRenderParallelEnabled()737 bool RSSystemProperties::GetRenderParallelEnabled()
738 {
739 static bool enable =
740 std::atoi((system::GetParameter("persist.sys.graphic.renderParallel", "1")).c_str()) != 0;
741 return enable;
742 }
743
GetBlurEnabled()744 bool RSSystemProperties::GetBlurEnabled()
745 {
746 static bool blurEnabled =
747 std::atoi((system::GetParameter("persist.sys.graphic.blurEnabled", "1")).c_str()) != 0;
748 return blurEnabled;
749 }
750
GetForegroundFilterEnabled()751 bool RSSystemProperties::GetForegroundFilterEnabled()
752 {
753 static bool foregroundFilterEnabled =
754 std::atoi((system::GetParameter("persist.sys.graphic.foregroundFilterEnabled", "1")).c_str()) != 0;
755 return foregroundFilterEnabled;
756 }
757
GetAiInvertCoef()758 const std::vector<float>& RSSystemProperties::GetAiInvertCoef()
759 {
760 // Configure AiInvertCoef: Low, High, Threshold, Opacity, Saturation, Filter Radius.
761 static std::vector<float> aiInvertCoef = {0.0, 1.0, 0.55, 0.4, 1.6, 45.0};
762 static bool initialized = false;
763 if (!initialized) {
764 initialized = true;
765 // Configure AiInvertCoef0: Low
766 aiInvertCoef[0] =
767 std::atof((system::GetParameter("persist.sys.graphic.aiInvertLow", "0.5")).c_str());
768 // Configure AiInvertCoef1: High.
769 aiInvertCoef[1] =
770 std::atof((system::GetParameter("persist.sys.graphic.aiInvertHigh", "0.7")).c_str());
771 // Configure AiInvertCoef2: Threshold.
772 aiInvertCoef[2] =
773 std::atof((system::GetParameter("persist.sys.graphic.aiInvertThreshold", "0.5")).c_str());
774 // Configure AiInvertCoef3: Opacity.
775 aiInvertCoef[3] =
776 std::atof((system::GetParameter("persist.sys.graphic.aiInvertOpacity", "0.2")).c_str());
777 // Configure AiInvertCoef4: Saturation.
778 aiInvertCoef[4] =
779 std::atof((system::GetParameter("persist.sys.graphic.aiInvertSaturation", "1.0")).c_str());
780 // Configure AiInvertCoef5: Filter Radius.
781 aiInvertCoef[5] =
782 std::atof((system::GetParameter("persist.sys.graphic.aiInvertFilterRadius", "300")).c_str());
783 }
784 return aiInvertCoef;
785 }
786
GetProxyNodeDebugEnabled()787 bool RSSystemProperties::GetProxyNodeDebugEnabled()
788 {
789 static bool proxyNodeDebugEnabled = system::GetParameter("persist.sys.graphic.proxyNodeDebugEnabled", "0") != "0";
790 return proxyNodeDebugEnabled;
791 }
792
GetCacheOptimizeRotateEnable()793 bool RSSystemProperties::GetCacheOptimizeRotateEnable()
794 {
795 static bool debugEnable = system::GetBoolParameter("const.cache.optimize.rotate.enable", false);
796 return debugEnable;
797 }
798
GetCrossNodeOffScreenStatus()799 CrossNodeOffScreenRenderDebugType RSSystemProperties::GetCrossNodeOffScreenStatus()
800 {
801 static CachedHandle g_Handle = CachedParameterCreate("rosen.crossnode.offscreen.render.enabled", "1");
802 int chanded = 0;
803 const char *type = CachedParameterGetChanged(g_Handle, &chanded);
804 return static_cast<CrossNodeOffScreenRenderDebugType>(ConvertToInt(type, 1));
805 }
806
GetUIFirstEnabled()807 bool RSSystemProperties::GetUIFirstEnabled()
808 {
809 #ifdef ROSEN_EMULATOR
810 return false;
811 #else
812 static CachedHandle g_Handle = CachedParameterCreate("rosen.ui.first.enabled", "1");
813 int changed = 0;
814 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
815 return ConvertToInt(enable, 1) != 0;
816 #endif
817 }
818
GetSurfaceOffscreenEnadbled()819 bool RSSystemProperties::GetSurfaceOffscreenEnadbled()
820 {
821 static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.surfaceOffscreenEnabled", "1");
822 int changed = 0;
823 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
824 return ConvertToInt(enable, 1) != 0;
825 }
826
GetUIFirstDebugEnabled()827 bool RSSystemProperties::GetUIFirstDebugEnabled()
828 {
829 static bool debugEnable = system::GetIntParameter("persist.sys.graphic.uifirstDebugEnabled", 0) != 0;
830 return debugEnable;
831 }
832
GetSingleDrawableLockerEnabled()833 bool RSSystemProperties::GetSingleDrawableLockerEnabled()
834 {
835 static bool lockerEnable = system::GetIntParameter("persist.sys.graphic.singleDrawableLocker.enable", 1) != 0;
836 return lockerEnable;
837 }
838
GetTargetUIFirstDfxEnabled(std::vector<std::string> & SurfaceNames)839 bool RSSystemProperties::GetTargetUIFirstDfxEnabled(std::vector<std::string>& SurfaceNames)
840 {
841 static CachedHandle g_Handle = CachedParameterCreate("rosen.UIFirstdebug.surfacenames", "0");
842 int changed = 0;
843 const char *targetSurfacesStr = CachedParameterGetChanged(g_Handle, &changed);
844 if (targetSurfacesStr == nullptr || strcmp(targetSurfacesStr, "0") == 0) {
845 SurfaceNames.clear();
846 return false;
847 }
848 SurfaceNames.clear();
849 ParseDfxSurfaceNamesString(targetSurfacesStr, SurfaceNames, ",");
850 return true;
851 }
852
GetWideColorSpaceEnabled()853 bool RSSystemProperties::GetWideColorSpaceEnabled()
854 {
855 static CachedHandle g_Handle = CachedParameterCreate("rosen.wide.colorspace.enabled", "1");
856 int changed = 0;
857 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
858 return ConvertToInt(enable, 1) != 0;
859 }
860
GetDebugTraceEnabled()861 bool RSSystemProperties::GetDebugTraceEnabled()
862 {
863 static bool openDebugTrace = system::GetIntParameter("persist.sys.graphic.openDebugTrace", 0) != 0;
864 return openDebugTrace;
865 }
866
GetImageReleaseUsingPostTask()867 bool RSSystemProperties::GetImageReleaseUsingPostTask()
868 {
869 static bool flag =
870 std::atoi((system::GetParameter("persist.sys.graphic.iamgeReleasePostTask", "0")).c_str()) != 0;
871 return flag;
872 }
873
GetDebugTraceLevel()874 int RSSystemProperties::GetDebugTraceLevel()
875 {
876 static int openDebugTraceLevel =
877 std::atoi((system::GetParameter("persist.sys.graphic.openDebugTrace", "0")).c_str());
878 return openDebugTraceLevel;
879 }
880
GetDumpImgEnabled()881 bool RSSystemProperties::GetDumpImgEnabled()
882 {
883 static bool dumpImgEnabled =
884 std::atoi((system::GetParameter("persist.sys.graphic.dumpImgEnabled", "0")).c_str()) != 0;
885 return dumpImgEnabled;
886 }
887
GetTransactionTerminateEnabled()888 bool RSSystemProperties::GetTransactionTerminateEnabled()
889 {
890 static bool terminateEnabled =
891 std::atoi((system::GetParameter("persist.sys.graphic.transactionTerminateEnabled", "0")).c_str()) != 0;
892 return terminateEnabled;
893 }
894
GetBlurEffectTerminateLimit()895 uint32_t RSSystemProperties::GetBlurEffectTerminateLimit()
896 {
897 static int terminateLimit =
898 std::atoi((system::GetParameter("persist.sys.graphic.blurEffectTerminateLimit", "50")).c_str());
899 return terminateLimit > 0 ? static_cast<uint32_t>(terminateLimit) : 0;
900 }
901
FindNodeInTargetList(std::string node)902 bool RSSystemProperties::FindNodeInTargetList(std::string node)
903 {
904 static std::string targetStr = system::GetParameter("persist.sys.graphic.traceTargetList", "");
905 static auto strSize = targetStr.size();
906 if (strSize == 0) {
907 return false;
908 }
909 static std::vector<std::string> targetVec;
910 static bool loaded = false;
911 if (!loaded) {
912 const std::string pattern = ";";
913 targetStr += pattern;
914 strSize = targetStr.size();
915 std::string::size_type pos;
916 for (std::string::size_type i = 0; i < strSize; i++) {
917 pos = targetStr.find(pattern, i);
918 if (pos >= strSize) {
919 break;
920 }
921 auto str = targetStr.substr(i, pos - i);
922 if (str.size() > 0) {
923 targetVec.emplace_back(str);
924 }
925 i = pos;
926 }
927 loaded = true;
928 }
929 bool res = std::find(targetVec.begin(), targetVec.end(), node) != targetVec.end();
930 return res;
931 }
932
IsFoldScreenFlag()933 bool RSSystemProperties::IsFoldScreenFlag()
934 {
935 static bool isFoldScreenFlag = system::GetParameter("const.window.foldscreen.type", "") != "";
936 return isFoldScreenFlag;
937 }
938
GetCacheCmdEnabled()939 bool RSSystemProperties::GetCacheCmdEnabled()
940 {
941 static CachedHandle g_Handle = CachedParameterCreate("rosen.cacheCmd.enabled", "1");
942 int changed = 0;
943 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
944 return ConvertToInt(enable, 1) != 0;
945 }
946
GetASTCEnabled()947 bool RSSystemProperties::GetASTCEnabled()
948 {
949 static bool isASTCEnabled = std::atoi((system::GetParameter("persist.rosen.astc.enabled", "0")).c_str()) != 0;
950 return isASTCEnabled;
951 }
952
953 // GetCachedBlurPartialRenderEnabled Option On: no need to expand blur dirtyregion if blur has background cache
GetCachedBlurPartialRenderEnabled()954 bool RSSystemProperties::GetCachedBlurPartialRenderEnabled()
955 {
956 static CachedHandle g_Handle = CachedParameterCreate("rosen.cachedblurpartialrender.enabled", "0");
957 int changed = 0;
958 const char *type = CachedParameterGetChanged(g_Handle, &changed);
959 return ConvertToInt(type, 1) != 0;
960 }
961
GetParallelUploadTexture()962 bool RSSystemProperties::GetParallelUploadTexture()
963 {
964 static bool enable = std::atoi((system::GetParameter("rosen.parallelUpload,enabled", "1")).c_str()) != 0;
965 return enable;
966 }
967
GetImageGpuResourceCacheEnable(int width,int height)968 bool RSSystemProperties::GetImageGpuResourceCacheEnable(int width, int height)
969 {
970 static bool cacheEnable =
971 std::atoi((system::GetParameter("persist.sys.graphic.gpuResourceCacheEnable", "1")).c_str()) != 0;
972 if (!cacheEnable) {
973 return false;
974 }
975
976 // default cache full screen image gpu resource.
977 static int widthConfig =
978 std::atoi((system::GetParameter("persist.sys.graphic.gpuResourceCacheWidth", "0")).c_str());
979 static int heightConfig =
980 std::atoi((system::GetParameter("persist.sys.graphic.gpuResourceCacheHeight", "0")).c_str());
981 int cacheWidth = widthConfig == 0 ? DEFAULT_CACHE_WIDTH : widthConfig;
982 int cacheHeight = heightConfig == 0 ? DEFAULT_CACHE_HEIGHT : heightConfig;
983 if (width >= cacheWidth && height >= cacheHeight) {
984 return true;
985 }
986 return false;
987 }
988
GetBoolSystemProperty(const char * name,bool defaultValue)989 bool RSSystemProperties::GetBoolSystemProperty(const char* name, bool defaultValue)
990 {
991 static CachedHandle g_Handle = CachedParameterCreate(name, defaultValue ? "1" : "0");
992 int changed = 0;
993 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
994 return ConvertToInt(enable, defaultValue ? 1 : 0) != 0;
995 }
996
WatchSystemProperty(const char * name,OnSystemPropertyChanged func,void * context)997 int RSSystemProperties::WatchSystemProperty(const char* name, OnSystemPropertyChanged func, void* context)
998 {
999 return WatchParameter(name, func, context);
1000 }
1001
IsPhoneType()1002 bool RSSystemProperties::IsPhoneType()
1003 {
1004 static bool isPhone = system::GetParameter("const.product.devicetype", "pc") == "phone";
1005 return isPhone;
1006 }
1007
IsTabletType()1008 bool RSSystemProperties::IsTabletType()
1009 {
1010 static bool isTablet = system::GetParameter("const.product.devicetype", "pc") == "tablet";
1011 return isTablet;
1012 }
1013
IsPcType()1014 bool RSSystemProperties::IsPcType()
1015 {
1016 static bool isPc = (system::GetParameter("const.product.devicetype", "pc") == "pc") ||
1017 (system::GetParameter("const.product.devicetype", "pc") == "2in1");
1018 return isPc;
1019 }
1020
IsSuperFoldDisplay()1021 bool RSSystemProperties::IsSuperFoldDisplay()
1022 {
1023 static const std::string foldScreenType = system::GetParameter("const.window.foldscreen.type", "0,0,0,0");
1024 static const bool IsSuperFoldDisplay = foldScreenType.size() > 0 ? foldScreenType[0] == '6' : false;
1025 return IsSuperFoldDisplay;
1026 }
1027
IsBetaRelease()1028 bool RSSystemProperties::IsBetaRelease()
1029 {
1030 static bool isBetaRelease = system::GetParameter("const.logsystem.versiontype", "") == "beta";
1031 return isBetaRelease;
1032 }
1033
GetSyncTransactionEnabled()1034 bool RSSystemProperties::GetSyncTransactionEnabled()
1035 {
1036 static bool syncTransactionEnabled =
1037 std::atoi((system::GetParameter("persist.sys.graphic.syncTransaction.enabled", "1")).c_str()) != 0;
1038 return syncTransactionEnabled;
1039 }
1040
GetSyncTransactionWaitDelay()1041 int RSSystemProperties::GetSyncTransactionWaitDelay()
1042 {
1043 static int syncTransactionWaitDelay =
1044 std::atoi((system::GetParameter("persist.sys.graphic.syncTransactionWaitDelay", "1500")).c_str());
1045 return syncTransactionWaitDelay;
1046 }
1047
GetSingleFrameComposerEnabled()1048 bool RSSystemProperties::GetSingleFrameComposerEnabled()
1049 {
1050 static bool singleFrameComposerEnabled =
1051 (std::atoi((system::GetParameter("persist.sys.graphic.singleFrameComposer", "0")).c_str()) != 0);
1052 return singleFrameComposerEnabled;
1053 }
1054
GetSingleFrameComposerCanvasNodeEnabled()1055 bool RSSystemProperties::GetSingleFrameComposerCanvasNodeEnabled()
1056 {
1057 static bool singleFrameComposerCanvasNodeEnabled =
1058 (std::atoi((system::GetParameter("persist.sys.graphic.singleFrameComposerCanvasNode", "0")).c_str()) != 0);
1059 return singleFrameComposerCanvasNodeEnabled;
1060 }
1061
GetDrawFilterWithoutSnapshotEnabled()1062 bool RSSystemProperties::GetDrawFilterWithoutSnapshotEnabled()
1063 {
1064 static bool drawFilterWithoutSnapshotEnabled =
1065 (std::atoi(system::GetParameter("persist.sys.graphic.drawFilterWithoutSnapshot", "0").c_str()) != 0);
1066 return drawFilterWithoutSnapshotEnabled;
1067 }
1068
GetBlurExtraFilterEnabled()1069 bool RSSystemProperties::GetBlurExtraFilterEnabled()
1070 {
1071 static bool blurExtraFilterEnabled =
1072 (std::atoi(system::GetParameter("persist.sys.graphic.blurExtraFilter", "0").c_str()) != 0);
1073 return blurExtraFilterEnabled;
1074 }
1075
GetDiscardCanvasBeforeFilterEnabled()1076 bool RSSystemProperties::GetDiscardCanvasBeforeFilterEnabled()
1077 {
1078 static bool discardCanvasBeforeFilterEnabled =
1079 (std::atoi(system::GetParameter("persist.sys.graphic.discardCanvasBeforeFilter", "1").c_str()) != 0);
1080 return discardCanvasBeforeFilterEnabled;
1081 }
1082
GetPurgeBetweenFramesEnabled()1083 bool RSSystemProperties::GetPurgeBetweenFramesEnabled()
1084 {
1085 static bool purgeResourcesEveryEnabled =
1086 (std::atoi(system::GetParameter("persist.sys.graphic.mem.purge_between_frames_enabled", "1").c_str()) != 0);
1087 return purgeResourcesEveryEnabled;
1088 }
1089
GetGpuMemoryAsyncReclaimerEnabled()1090 bool RSSystemProperties::GetGpuMemoryAsyncReclaimerEnabled()
1091 {
1092 static bool gpuMemoryAsyncReclaimerEnabled =
1093 (std::atoi(
1094 system::GetParameter("persist.sys.graphic.mem.gpu_async_reclaimer_between_frames_enabled", "1").c_str()) !=
1095 0);
1096 return gpuMemoryAsyncReclaimerEnabled;
1097 }
1098
GetGpuCacheSuppressWindowEnabled()1099 bool RSSystemProperties::GetGpuCacheSuppressWindowEnabled()
1100 {
1101 static bool gpuCacheSuppressWindowEnabled =
1102 (std::atoi(
1103 system::GetParameter("persist.sys.graphic.mem.gpu_suppress_window_between_frames_enabled", "1").c_str()) !=
1104 0);
1105 return gpuCacheSuppressWindowEnabled;
1106 }
1107
1108 const DdgrOpincType RSSystemProperties::ddgrOpincType_ =
1109 static_cast<DdgrOpincType>(std::atoi((system::GetParameter("persist.ddgr.opinctype", "2")).c_str()));
1110 const DdgrOpincDfxType RSSystemProperties::ddgrOpincDfxType_ =
1111 static_cast<DdgrOpincDfxType>(std::atoi((
1112 system::GetParameter("persist.rosen.ddgr.opinctype.debugtype", "0")).c_str()));
1113
GetDdgrOpincType()1114 DdgrOpincType RSSystemProperties::GetDdgrOpincType()
1115 {
1116 return RSSystemProperties::ddgrOpincType_;
1117 }
1118
IsDdgrOpincEnable()1119 bool RSSystemProperties::IsDdgrOpincEnable()
1120 {
1121 return (GetDdgrOpincType() == DdgrOpincType::OPINC_AUTOCACHE_REALDRAW ||
1122 GetDdgrOpincType() == DdgrOpincType::OPINC_AUTOCACHE);
1123 }
1124
IsOpincRealDrawCacheEnable()1125 bool RSSystemProperties::IsOpincRealDrawCacheEnable()
1126 {
1127 return GetDdgrOpincType() == DdgrOpincType::OPINC_AUTOCACHE_REALDRAW;
1128 }
1129
GetDdgrOpincDfxType()1130 DdgrOpincDfxType RSSystemProperties::GetDdgrOpincDfxType()
1131 {
1132 return ddgrOpincDfxType_;
1133 }
1134
GetAutoCacheDebugEnabled()1135 bool RSSystemProperties::GetAutoCacheDebugEnabled()
1136 {
1137 return GetDdgrOpincDfxType() == DdgrOpincDfxType::OPINC_DFX_AUTO;
1138 }
1139
1140 #ifdef RS_ENABLE_STACK_CULLING
GetViewOcclusionCullingEnabled()1141 bool RSSystemProperties::GetViewOcclusionCullingEnabled()
1142 {
1143 static bool stackViewCullingEnabled =
1144 system::GetBoolParameter("persist.sys.graphic.stack.culling.enabled", true);
1145 return stackViewCullingEnabled;
1146 }
1147 #endif
1148
GetSecurityPermissionCheckEnabled()1149 bool RSSystemProperties::GetSecurityPermissionCheckEnabled()
1150 {
1151 static bool openSecurityPermissionCheck =
1152 std::atoi((system::GetParameter("persist.sys.graphic.openSecurityPermissionCheck", "0")).c_str()) != 0;
1153 return openSecurityPermissionCheck;
1154 }
1155
GetEffectMergeEnabled()1156 bool RSSystemProperties::GetEffectMergeEnabled()
1157 {
1158 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.effectMergeEnabled", "1");
1159 int changed = 0;
1160 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1161 return ConvertToInt(enable, 1) != 0;
1162 }
1163
GetDumpUICaptureEnabled()1164 bool RSSystemProperties::GetDumpUICaptureEnabled()
1165 {
1166 bool dumpUICaptureEnabled =
1167 std::atoi((system::GetParameter("rosen.dumpUICaptureEnabled.enabled", "0")).c_str()) != 0;
1168 return dumpUICaptureEnabled;
1169 }
1170
GetDumpUIPixelmapEnabled()1171 bool RSSystemProperties::GetDumpUIPixelmapEnabled()
1172 {
1173 bool dumpUIPixelmapEnabled =
1174 std::atoi((system::GetParameter("rosen.dumpUIPixelmapEnabled.enabled", "0")).c_str()) != 0;
1175 return dumpUIPixelmapEnabled;
1176 }
1177
GetVirtualScreenScaleModeDFX()1178 int RSSystemProperties::GetVirtualScreenScaleModeDFX()
1179 {
1180 static int scaleModeDFX =
1181 std::atoi((system::GetParameter("persist.rosen.virtualScreenScaleMode.debugType", "2")).c_str());
1182 return (scaleModeDFX > DEFAULT_SCALE_MODE) ? DEFAULT_SCALE_MODE : scaleModeDFX;
1183 }
1184
GetSubTreePrepareCheckType()1185 SubTreePrepareCheckType RSSystemProperties::GetSubTreePrepareCheckType()
1186 {
1187 static CachedHandle g_Handle = CachedParameterCreate("persist.sys.graphic.SubTreePrepareCheckType.type", "2");
1188 int changed = 0;
1189 const char *type = CachedParameterGetChanged(g_Handle, &changed);
1190 return static_cast<SubTreePrepareCheckType>(ConvertToInt(type, 2)); // Default value 2
1191 }
1192
GetHdrImageEnabled()1193 bool RSSystemProperties::GetHdrImageEnabled()
1194 {
1195 static bool isHdrImageEnabled = system::GetBoolParameter("persist.sys.graphic.hdrimage.enabled", true);
1196 return isHdrImageEnabled;
1197 }
1198
GetHdrVideoEnabled()1199 bool RSSystemProperties::GetHdrVideoEnabled()
1200 {
1201 static bool isHdrVideoEnabled = system::GetBoolParameter("persist.sys.graphic.hdrvideo.enabled", true);
1202 return isHdrVideoEnabled;
1203 }
1204
IsForceClient()1205 bool RSSystemProperties::IsForceClient()
1206 {
1207 static CachedHandle g_Handle = CachedParameterCreate("rosen.client_composition.enabled", "0");
1208 int changed = 0;
1209 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1210 return ConvertToInt(num, 0);
1211 }
1212
GetTextBlobAsPixelMap()1213 bool RSSystemProperties::GetTextBlobAsPixelMap()
1214 {
1215 static bool pixelMapEnabled =
1216 std::atoi((system::GetParameter("persist.rosen.textBlobAsPixelMapEnable.enable", "0")).c_str()) != 0;
1217 return pixelMapEnabled;
1218 }
1219
GetUnmarshParallelFlag()1220 bool RSSystemProperties::GetUnmarshParallelFlag()
1221 {
1222 static bool flag = system::GetParameter("rosen.graphic.UnmashParallelEnabled", "0") != "0";
1223 return flag;
1224 }
1225
GetUnMarshParallelSize()1226 uint32_t RSSystemProperties::GetUnMarshParallelSize()
1227 {
1228 static uint32_t size =
1229 static_cast<uint32_t>(std::atoi(
1230 (system::GetParameter("rosen.graphic.UnmashParallelSize", "102400")).c_str())); // 100K
1231 return size;
1232 }
1233
GetRSNodeLimit()1234 int RSSystemProperties::GetRSNodeLimit()
1235 {
1236 static int rsNodeLimit =
1237 std::atoi((system::GetParameter("persist.sys.graphic.rsNodeLimit", "500")).c_str());
1238 return rsNodeLimit;
1239 }
1240
GetGpuOverDrawBufferOptimizeEnabled()1241 bool RSSystemProperties::GetGpuOverDrawBufferOptimizeEnabled()
1242 {
1243 static bool flag = system::GetParameter("rosen.gpu.overdraw.optimize.enabled", "0") != "0";
1244 return flag;
1245 }
1246
GetSkipDisplayIfScreenOffEnabled()1247 bool RSSystemProperties::GetSkipDisplayIfScreenOffEnabled()
1248 {
1249 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.screenoffskipdisplayenabled", "1");
1250 int changed = 0;
1251 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1252 return ConvertToInt(num, 1) != 0;
1253 }
1254
GetBatchRemovingOnRemoteDiedEnabled()1255 bool RSSystemProperties::GetBatchRemovingOnRemoteDiedEnabled()
1256 {
1257 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.batchRemovingOnRemoteDied.enabled", "1");
1258 int changed = 0;
1259 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1260 return ConvertToInt(num, 1) != 0;
1261 }
1262
GetVersionType()1263 std::string RSSystemProperties::GetVersionType()
1264 {
1265 static std::string versionType = system::GetParameter("const.logsystem.versiontype", "");
1266 return versionType;
1267 }
1268
GetHwcDirtyRegionEnabled()1269 bool RSSystemProperties::GetHwcDirtyRegionEnabled()
1270 {
1271 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.hwcdirtyregion.enabled", "1");
1272 int changed = 0;
1273 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1274 return ConvertToInt(num, 1) != 0;
1275 }
1276
GetDrmMarkedFilterEnabled()1277 bool RSSystemProperties::GetDrmMarkedFilterEnabled()
1278 {
1279 static CachedHandle g_Handle = CachedParameterCreate("rosen.drm.markedFilter.enabled", "1");
1280 int changed = 0;
1281 const char *num = CachedParameterGetChanged(g_Handle, &changed);
1282 return ConvertToInt(num, 0);
1283 }
1284
GetHveFilterEnabled()1285 bool RSSystemProperties::GetHveFilterEnabled()
1286 {
1287 static bool hveFilterEnabled =
1288 std::atoi((system::GetParameter("persist.sys.graphic.HveFilterEnable", "1")).c_str()) != 0;
1289 return hveFilterEnabled;
1290 }
1291
GetDmaReclaimParam()1292 bool RSSystemProperties::GetDmaReclaimParam()
1293 {
1294 return system::GetBoolParameter("resourceschedule.memmgr.dma.reclaimable", false);
1295 }
1296
GetOptimizeParentNodeRegionEnabled()1297 bool RSSystemProperties::GetOptimizeParentNodeRegionEnabled()
1298 {
1299 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.optimizeParentNodeRegion.enabled", "1");
1300 int changed = 0;
1301 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1302 return ConvertToInt(enable, 1) != 0;
1303 }
1304
GetOptimizeHwcComposeAreaEnabled()1305 bool RSSystemProperties::GetOptimizeHwcComposeAreaEnabled()
1306 {
1307 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.optimizeHwcComposeArea.enabled", "1");
1308 int changed = 0;
1309 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1310 return ConvertToInt(enable, 1) != 0;
1311 }
1312
GetWindowKeyFrameEnabled()1313 bool RSSystemProperties::GetWindowKeyFrameEnabled()
1314 {
1315 static CachedHandle g_Handle = CachedParameterCreate("rosen.graphic.windowkeyframe.enabled", "1");
1316 int changed = 0;
1317 const char *enable = CachedParameterGetChanged(g_Handle, &changed);
1318 return ConvertToInt(enable, 1) != 0;
1319 }
1320
GetNodeGroupGroupedByUIEnabled()1321 bool RSSystemProperties::GetNodeGroupGroupedByUIEnabled()
1322 {
1323 static auto groupedByUIEnabled =
1324 system::GetBoolParameter("const.graphic.enable_grouped_by_ui", false);
1325 return groupedByUIEnabled;
1326 }
1327 } // namespace Rosen
1328 } // namespace OHOS
1329