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