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 bool GetClosePixelMapFdEnabled(); 142 static DirtyRegionDebugType GetDirtyRegionDebugType(); 143 static PartialRenderType GetPartialRenderEnabled(); 144 static PartialRenderType GetUniPartialRenderEnabled(); 145 static float GetClipRectThreshold(); 146 static bool GetAllSurfaceVisibleDebugEnabled(); 147 static bool GetVirtualDirtyDebugEnabled(); 148 static bool GetVirtualDirtyEnabled(); 149 static bool GetExpandScreenDirtyEnabled(); 150 static bool GetOcclusionEnabled(); 151 static std::string GetRSEventProperty(const std::string ¶Name); 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 GetDrawMirrorCacheImageEnabled(); 165 static bool GetPixelmapDfxEnabled(); 166 static bool GetAFBCEnabled(); 167 static bool GetReleaseResourceEnabled(); 168 static bool GetRSScreenRoundCornerEnable(); 169 static bool GetAceDebugBoundaryEnabled(); 170 171 static void SetDrawTextAsBitmap(bool flag); 172 static bool GetDrawTextAsBitmap(); 173 static void SetCacheEnabledForRotation(bool flag); 174 static bool GetCacheEnabledForRotation(); 175 static ParallelRenderingType GetPrepareParallelRenderingEnabled(); 176 static ParallelRenderingType GetParallelRenderingEnabled(); 177 static HgmRefreshRates GetHgmRefreshRatesEnabled(); 178 static void SetHgmRefreshRateModesEnabled(std::string param); 179 static HgmRefreshRateModes GetHgmRefreshRateModesEnabled(); 180 static bool GetHardCursorEnabled(); 181 182 static float GetAnimationScale(); 183 static bool GetProxyNodeDebugEnabled(); 184 static bool GetFilterCacheEnabled(); 185 static int GetFilterCacheUpdateInterval(); 186 static int GetFilterCacheSizeThreshold(); 187 static bool GetDynamicBrightnessEnabled(); 188 static bool GetMaskLinearBlurEnabled(); 189 static bool GetMotionBlurEnabled(); 190 static bool GetDrmEnabled(); 191 static bool GetMagnifierEnabled(); 192 static bool GetKawaseEnabled(); 193 static void SetForceHpsBlurDisabled(bool flag); 194 static bool GetHpsBlurEnabled(); 195 static bool GetMESABlurFuzedEnabled(); 196 static float GetKawaseRandomColorFactor(); 197 static bool GetRandomColorEnabled(); 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 GetRenderParallelEnabled(); 205 static bool GetPropertyDrawableEnable(); 206 207 static bool GetDrawFilterWithoutSnapshotEnabled(); 208 static bool GetBlurExtraFilterEnabled(); 209 static bool GetPurgeBetweenFramesEnabled(); 210 static bool GetGpuMemoryAsyncReclaimerEnabled(); 211 static bool GetGpuCacheSuppressWindowEnabled(); 212 213 static bool GetAnimationCacheEnabled(); 214 215 static bool GetBoolSystemProperty(const char* name, bool defaultValue); 216 static int WatchSystemProperty(const char* name, OnSystemPropertyChanged func, void* context); 217 static bool GetUIFirstEnabled(); 218 static bool GetUIFirstDebugEnabled(); 219 static bool GetSurfaceOffscreenEnadbled(); 220 static bool GetDebugTraceEnabled(); 221 static bool GetImageReleaseUsingPostTask(); 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 IsPhoneType(); 231 static bool IsTabletType(); 232 static bool IsPcType(); 233 static bool GetSyncTransactionEnabled(); 234 static int GetSyncTransactionWaitDelay(); 235 static bool GetSingleFrameComposerEnabled(); 236 static bool GetSingleFrameComposerCanvasNodeEnabled(); 237 static bool GetSubSurfaceEnabled(); 238 static bool GetSecurityPermissionCheckEnabled(); 239 static bool GetParallelUploadTexture(); 240 static bool GetEffectMergeEnabled(); 241 static SubTreePrepareCheckType GetSubTreePrepareCheckType(); 242 static bool IsForceClient(); 243 static bool GetHDRImageEnable(); 244 static bool GetGpuOverDrawBufferOptimizeEnabled(); 245 246 static bool GetDrmMarkedFilterEnabled(); 247 248 static DdgrOpincType GetDdgrOpincType(); 249 static bool IsDdgrOpincEnable(); 250 static bool GetAutoCacheDebugEnabled(); 251 static DdgrOpincDfxType GetDdgrOpincDfxType(); 252 static bool IsOpincRealDrawCacheEnable(); 253 static bool GetSkipDisplayIfScreenOffEnabled(); 254 static bool GetBatchRemovingOnRemoteDiedEnabled(); 255 256 #ifdef RS_ENABLE_STACK_CULLING 257 static bool GetViewOcclusionCullingEnabled(); 258 #endif 259 260 static bool GetDumpUICaptureEnabled(); 261 static bool GetDumpUIPixelmapEnabled(); 262 static int GetVirtualScreenScaleModeDFX(); 263 static bool GetDumpImgEnabled(); 264 265 static bool GetTransactionTerminateEnabled(); 266 static bool GetTextBlobAsPixelMap(); GetGpuApiType()267 static inline GpuApiType GetGpuApiType() 268 { 269 return RSSystemProperties::systemGpuApiType_; 270 } 271 272 static int GetRSNodeLimit(); IsUseVulkan()273 static inline bool IsUseVulkan() 274 { 275 return RSSystemProperties::GetGpuApiType() != GpuApiType::OPENGL; 276 } 277 278 static std::string GetVersionType(); 279 static bool GetHwcDirtyRegionEnabled(); 280 281 private: 282 RSSystemProperties() = default; 283 284 static inline bool isUniRenderEnabled_ = false; 285 inline static bool isDrawTextAsBitmap_ = false; 286 inline static bool cacheEnabledForRotation_ = false; 287 static inline bool forceHpsBlurDisabled_ = false; 288 static const GpuApiType systemGpuApiType_; 289 static const DdgrOpincType ddgrOpincType_; 290 static const DdgrOpincDfxType ddgrOpincDfxType_; 291 }; 292 } // namespace Rosen 293 } // namespace OHOS 294 295 #endif // RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H 296