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