• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H
17 #define RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H
18 
19 #include <atomic>
20 #include <string>
21 #include <vector>
22 
23 #include "common/rs_common_def.h"
24 #include "common/rs_macros.h"
25 #include "utils/system_properties.h"
26 
27 namespace OHOS {
28 namespace Rosen {
29 
30 enum class CrossNodeOffScreenRenderDebugType {
31     DISABLED = 0,
32     ENABLE,
33     ENABLE_DFX
34 };
35 
36 enum class DirtyRegionDebugType {
37     DISABLED = 0,
38     CURRENT_SUB,
39     CURRENT_WHOLE,
40     MULTI_HISTORY,
41     CURRENT_SUB_AND_WHOLE,
42     CURRENT_WHOLE_AND_MULTI_HISTORY,
43     EGL_DAMAGE, // all dirty region information, includes detailed app dirty region and global dirty.
44     DISPLAY_DIRTY, // detailed global dirty (before merge rect).
45     MERGED_DIRTY, // advanced dirty region information, includes merged dirty region
46     CUR_DIRTY_DETAIL_ONLY_TRACE = 10,
47     UPDATE_DIRTY_REGION, // dirty region for each node.
48     OVERLAY_RECT,   // drawRegion
49     FILTER_RECT,
50     SHADOW_RECT,
51     PREPARE_CLIP_RECT,
52     REMOVE_CHILD_RECT,
53     RENDER_PROPERTIES_RECT,
54     CANVAS_NODE_SKIP_RECT,
55     OUTLINE_RECT,
56     SUBTREE_SKIP_RECT, // dirty region of the subtree if subtree is skipped in preparation.
57     SUBTREE_SKIP_OUT_OF_PARENT_RECT, // dirty region of the subtree when subtree is out of parent
58 };
59 
60 enum class SurfaceRegionDebugType {
61     DISABLED = 0,
62     OPAQUE_REGION,
63     VISIBLE_REGION,
64 };
65 
66 enum class PartialRenderType {
67     DISABLED = 0,                               // 0, disable partial render, including set damage region
68     SET_DAMAGE,                                 // 1, set damageregion, without draw_op dropping
69     SET_DAMAGE_AND_DROP_OP,                     // 2, drop draw_op if node is not in dirty region
70     SET_DAMAGE_AND_DROP_OP_OCCLUSION,           // 3, drop draw_op if node is not in visible region (unirender)
71     SET_DAMAGE_AND_DROP_OP_NOT_VISIBLEDIRTY,    // 4, drop draw_op if node is not in visible dirty region (unirender)
72     SET_DAMAGE_BUT_COMPLETE_RENDER,             // 5, set full screen dirty region and set damage
73 };
74 
75 enum class StencilPixelOcclusionCullingType {
76     DEFAULT = -1, // follow the ccm configuration
77     DISABLED = 0,
78     ENABLED = 1
79 };
80 
81 enum class AdvancedDirtyRegionType {
82     DISABLED = 0,
83     SET_ADVANCED_SURFACE_AND_DISPLAY,
84     SET_ADVANCED_DISPLAY,
85 };
86 
87 enum class DirtyAlignType {
88     DISABLED = 0,
89     ENABLED = 1,
90 };
91 
92 enum class DumpSurfaceType {
93     DISABLED = 0,
94     SINGLESURFACE,
95     ALLSURFACES,
96     PIXELMAP,
97     SURFACEBUFFER
98 };
99 
100 enum class ParallelRenderingType {
101     AUTO = 0,
102     DISABLE = 1,
103     ENABLE = 2
104 };
105 
106 enum class HgmRefreshRates {
107     SET_RATE_NULL = 0,
108     SET_RATE_30 = 30,
109     SET_RATE_60 = 60,
110     SET_RATE_90 = 90,
111     SET_RATE_120 = 120
112 };
113 
114 enum class HgmRefreshRateModes {
115     SET_RATE_MODE_AUTO = -1,
116     SET_RATE_MODE_NULL = 0,
117     SET_RATE_MODE_LOW = 1,
118     SET_RATE_MODE_MEDIUN = 2,
119     SET_RATE_MODE_HIGH = 3
120 };
121 
122 enum class SubTreePrepareCheckType {
123     DISABLED = 0,                       // 0, Disable the IsSubTreeNeedPrepare check, prepare the whole subtree
124     DISABLE_SUBTREE_DIRTY_CHECK = 1,    // 1, Disable the IsSubTreeDirty check
125     ENABLED = 2,                        // 2, Enable the IsSubTreeNeedPrepare check
126 };
127 
128 enum class DdgrOpincType {
129     OPINC_NONE = 0,
130     OPINC_AUTOCACHE,
131     OPINC_AUTOCACHE_REALDRAW,
132 };
133 
134 enum class DdgrOpincDfxType {
135     OPINC_DFX_NONE,
136     OPINC_DFX_AUTO,
137 };
138 
139 struct GetComponentSwitch {
140     ComponentEnableSwitch type;
141     bool (*ComponentHybridSwitch)();
142 };
143 
144 using OnSystemPropertyChanged = void(*)(const char*, const char*, void*);
145 
146 class RSB_EXPORT RSSystemProperties final {
147 public:
148     ~RSSystemProperties() = default;
149 
150     // used by clients
151     static std::string GetRecordingFile();
152     static bool IsSceneBoardEnabled();
153     static int GetDumpFrameNum();
154     static int GetSceneJankFrameThreshold();
155     static void SetRecordingDisenabled();
156     static int GetRecordingEnabled();
157     static bool GetVkQueuePriorityEnable();
158 
159     static bool GetProfilerEnabled();
160     static void SetProfilerDisabled();
161     static bool GetInstantRecording();
162     static bool GetProfilerPixelCheckMode();
163     static void SetProfilerPixelCheckMode(bool flag);
164     static void SetInstantRecording(bool flag);
165     static uint32_t GetBetaRecordingMode();
166     static void SetBetaRecordingMode(uint32_t param);
167     static bool GetSaveRDC();
168     static void SetSaveRDC(bool flag);
169 
170     static bool GetUniRenderEnabled();
171     static bool GetRenderNodeTraceEnabled();
172     static bool GetDrawOpTraceEnabled();
173     static bool GetAnimationTraceEnabled();
174     static bool GetAnimationDelayOptimizeEnabled();
175     static bool GetRSClientMultiInstanceEnabled();
176     static bool GetRenderNodePurgeEnabled();
177     static bool GetRSImagePurgeEnabled();
178     static bool GetClosePixelMapFdEnabled();
179     static DirtyRegionDebugType GetDirtyRegionDebugType();
180     static AdvancedDirtyRegionType GetAdvancedDirtyRegionEnabled();
181     static DirtyAlignType GetDirtyAlignEnabled();
182     static PartialRenderType GetPartialRenderEnabled();
183     static PartialRenderType GetUniPartialRenderEnabled();
184     static StencilPixelOcclusionCullingType GetStencilPixelOcclusionCullingEnabled();
185     static float GetClipRectThreshold();
186     static bool GetAllSurfaceVisibleDebugEnabled();
187     static bool GetVirtualDirtyDebugEnabled();
188     static bool GetVirtualDirtyEnabled();
189     static bool GetExpandScreenDirtyEnabled();
190     static bool GetVirtualExpandScreenSkipEnabled();
191     static bool GetOcclusionEnabled();
192     static std::string GetRSEventProperty(const std::string &paraName);
193     static bool GetHighContrastStatus();
194     static uint32_t GetCorrectionMode();
195     static DumpSurfaceType GetDumpSurfaceType();
196     static long long int GetDumpSurfaceId();
197     static bool GetTargetDirtyRegionDfxEnabled(std::vector<std::string>& dfxTargetSurfaceNames_);
198     static bool GetOpaqueRegionDfxEnabled();
199     static bool GetVisibleRegionDfxEnabled();
200     static SurfaceRegionDebugType GetSurfaceRegionDfxType();
201     static bool GetDumpLayersEnabled();
202     static bool GetHardwareComposerEnabled();
203     static bool GetDoDirectCompositionEnabled();
204     static bool GetDumpRsTreeDetailEnabled();
205     static bool GetHardwareComposerEnabledForMirrorMode();
206     static bool GetHwcRegionDfxEnabled();
207     static bool GetDrawMirrorCacheImageEnabled();
208     static bool GetPixelmapDfxEnabled();
209     static bool GetAFBCEnabled();
210     static bool GetReleaseResourceEnabled();
211     static bool GetReclaimMemoryEnabled();
212     static bool GetRSScreenRoundCornerEnable();
213 
214     static void SetDrawTextAsBitmap(bool flag);
215     static bool GetDrawTextAsBitmap();
216     static void SetCacheEnabledForRotation(bool flag);
217     static bool GetCacheEnabledForRotation();
218     static ParallelRenderingType GetPrepareParallelRenderingEnabled();
219     static ParallelRenderingType GetParallelRenderingEnabled();
220     static HgmRefreshRates GetHgmRefreshRatesEnabled();
221     static void SetHgmRefreshRateModesEnabled(std::string param);
222     static HgmRefreshRateModes GetHgmRefreshRateModesEnabled();
223     static bool GetHardCursorEnabled();
224     static bool GetSLRScaleEnabled();
225     static float GetAnimationScale();
226     static bool GetProxyNodeDebugEnabled();
227     static bool GetFilterCacheEnabled();
228     static int GetFilterCacheUpdateInterval();
229     static int GetFilterCacheSizeThreshold();
230     static bool GetMaskLinearBlurEnabled();
231     static bool GetMotionBlurEnabled();
232     static bool GetMagnifierEnabled();
233     static bool GetDynamicBrightnessEnabled();
234     static bool GetKawaseEnabled();
235     static void SetForceHpsBlurDisabled(bool flag);
236     static float GetHpsBlurNoiseFactor();
237     static bool GetHpsBlurEnabled();
238     static bool GetMESABlurFuzedEnabled();
239     static int GetSimplifiedMesaEnabled();
240     static bool GetForceKawaseDisabled();
241     static float GetKawaseRandomColorFactor();
242     static bool GetRandomColorEnabled();
243     static bool GetImageReleaseUsingPostTask();
244     static bool GetKawaseOriginalEnabled();
245     static bool GetBlurEnabled();
246     static bool GetForegroundFilterEnabled();
247     static const std::vector<float>& GetAiInvertCoef();
248     static bool GetSkipForAlphaZeroEnabled();
249     static bool GetSkipGeometryNotChangeEnabled();
250     static bool GetRenderParallelEnabled();
251     static bool GetPropertyDrawableEnable();
252 
253     static bool GetDrawFilterWithoutSnapshotEnabled();
254     static bool GetBlurExtraFilterEnabled();
255     static bool GetDiscardCanvasBeforeFilterEnabled();
256     static bool GetPurgeBetweenFramesEnabled();
257     static bool GetGpuMemoryAsyncReclaimerEnabled();
258     static bool GetGpuCacheSuppressWindowEnabled();
259 
260     static bool GetAnimationCacheEnabled();
261 
262     static bool GetBoolSystemProperty(const char* name, bool defaultValue);
263     static int WatchSystemProperty(const char* name, OnSystemPropertyChanged func, void* context);
264     static bool GetCacheOptimizeRotateEnable();
265     static CrossNodeOffScreenRenderDebugType GetCrossNodeOffScreenStatus();
266     static bool GetSingleDrawableLockerEnabled();
267     static bool GetUIFirstEnabled();
268     static bool GetHeterogComputingHDREnabled();
269     static bool GetUIFirstDebugEnabled();
270     static bool GetUIFirstOptScheduleEnabled();
271     static bool GetUIFirstBehindWindowEnabled();
272     static bool GetUIFirstDirtyEnabled();
273     static bool GetUIFirstDirtyDebugEnabled();
274     static bool GetTargetUIFirstDfxEnabled(std::vector<std::string>& SurfaceNames);
275     static bool GetUIFirstBehindWindowFilterEnabled();
276     static bool GetWideColorSpaceEnabled();
277     static bool GetSubtreeParallelEnable();
278     static uint32_t GetSubtreeDebugOption();
279     static bool GetSurfaceOffscreenEnadbled();
280     static bool GetDebugTraceEnabled();
281     static int GetDebugTraceLevel();
282     static bool FindNodeInTargetList(std::string node);
283     static bool IsFoldScreenFlag();
284     static bool IsSmallFoldDevice();
285     static bool GetCacheCmdEnabled();
286     static bool GetASTCEnabled();
287     static bool GetCachedBlurPartialRenderEnabled();
288     static bool GetImageGpuResourceCacheEnable(int width, int height);
289     static bool GetDrmEnabled();
290     static bool GetSurfaceNodeWatermarkEnabled();
291     static bool IsPhoneType();
292     static bool IsSuperFoldDisplay();
293     static bool IsBetaRelease();
294     static bool GetSyncTransactionEnabled();
295     static int GetSyncTransactionWaitDelay();
296     static bool GetSingleFrameComposerEnabled();
297     static bool GetSingleFrameComposerCanvasNodeEnabled();
298     static bool GetSecurityPermissionCheckEnabled();
299     static bool GetEffectMergeEnabled();
300     static SubTreePrepareCheckType GetSubTreePrepareCheckType();
301     static bool GetHdrImageEnabled();
302     static bool GetHdrVideoEnabled();
303     static bool IsForceClient();
304     static bool GetDrmMarkedFilterEnabled();
305     static bool GetGpuOverDrawBufferOptimizeEnabled();
306 
307     static DdgrOpincType GetDdgrOpincType();
308     static bool IsDdgrOpincEnable();
309     static bool GetAutoCacheDebugEnabled();
310     static DdgrOpincDfxType GetDdgrOpincDfxType();
311     static bool IsOpincRealDrawCacheEnable();
312     static bool GetSkipDisplayIfScreenOffEnabled();
313     static bool GetBatchRemovingOnRemoteDiedEnabled();
314 #ifdef RS_ENABLE_STACK_CULLING
315     static bool GetViewOcclusionCullingEnabled();
316 #endif
317 
318     static bool GetDumpUICaptureEnabled();
319     static bool GetDumpUIPixelmapEnabled();
320     static bool GetDumpImgEnabled();
321 
322     static bool GetTransactionTerminateEnabled();
323     static uint32_t GetBlurEffectTerminateLimit();
324 
325     static int GetVirtualScreenScaleModeDFX();
326     static bool GetTextBlobAsPixelMap();
GetGpuApiType()327     static inline GpuApiType GetGpuApiType()
328     {
329         return RSSystemProperties::systemGpuApiType_;
330     }
331 
IsUseVulkan()332     static inline bool IsUseVulkan()
333     {
334         return RSSystemProperties::GetGpuApiType() != GpuApiType::OPENGL;
335     }
336 
337     static bool ViewDrawNodeType();
338     static bool GetJankLoadOptimizeEnabled();
339     static int GetRSNodeLimit();
340     static std::string GetVersionType();
341     static bool GetHwcDirtyRegionEnabled();
342     static bool GetHveFilterEnabled();
343     static bool GetDmaReclaimParam();
344     static bool GetOptimizeParentNodeRegionEnabled();
345     static bool GetOptimizeHwcComposeAreaEnabled();
346     static bool GetOptimizeCanvasDrawRegionEnabled();
347     static bool GetHpaeBlurUsingAAE();
348 
349     static bool GetWindowKeyFrameEnabled();
350     static bool GetNodeGroupGroupedByUIEnabled();
351     static bool GetTimeVsyncDisabled();
352     static void SetDebugFmtTraceEnabled(bool flag);
353     static bool GetTextureExportDFXEnabled();
354     static bool GetDebugFmtTraceEnabled();
355 
356     static bool GetHybridRenderEnabled();
357     static bool GetHybridRenderDfxEnabled();
358     static uint32_t GetHybridRenderTextBlobLenCount();
359     static bool GetHybridRenderParallelConvertEnabled();
360     static bool GetHybridRenderCanvasEnabled();
361     static bool GetHybridRenderMemeoryReleaseEnabled();
362     static bool GetHybridRenderSystemEnabled();
363     static int32_t GetHybridRenderCcmEnabled();
364     static bool GetHybridRenderSwitch(ComponentEnableSwitch bitSeq);
365     static bool GetHybridRenderTextBlobEnabled();
366     static bool GetHybridRenderSvgEnabled();
367     static bool GetHybridRenderHmsymbolEnabled();
368     static bool GetTypicalResidentProcess();
369     static void SetTypicalResidentProcess(bool isTypicalResidentProcess);
370 
371     static bool GetVKImageUseEnabled();
372     static void SetBehindWindowFilterEnabled(bool enabled);
373     static bool GetBehindWindowFilterEnabled();
374     static bool GetSubThreadControlFrameRate();
375     static int GetSubThreadDropFrameInterval();
376     static bool GetCompositeLayerEnabled();
377     static bool GetEarlyZEnable();
378     static bool GetAIBarOptEnabled();
379     static bool GetRSMemoryInfoManagerParam();
380     static bool GetSelfDrawingDirtyRegionEnabled();
381     static bool GetOptBatchRemovingOnRemoteDiedEnabled();
382     static bool GetGpuDirtyApsEnabled();
383     static bool GetSupportScreenFreezeEnabled();
384 
385 private:
386     RSSystemProperties() = default;
387 
388     static inline bool isUniRenderEnabled_ = false;
389     inline static bool isDrawTextAsBitmap_ = false;
390     inline static bool cacheEnabledForRotation_ = false;
391     static inline bool forceHpsBlurDisabled_ = false;
392     static inline bool debugFmtTraceEnable_ = false;
393     static inline bool isBehindWindowFilterEnabled_ = true;
394     static inline bool isTypicalResidentProcess_ = false;
395     static bool isEnableEarlyZ_;
396     static const GpuApiType systemGpuApiType_;
397     static const DdgrOpincType ddgrOpincType_;
398     static const DdgrOpincDfxType ddgrOpincDfxType_;
399 };
400 
401 } // namespace Rosen
402 } // namespace OHOS
403 
404 #endif // RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H
405