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 GetSLRScaleEnabled(); 181 static float GetAnimationScale(); 182 static bool GetProxyNodeDebugEnabled(); 183 static bool GetFilterCacheEnabled(); 184 static int GetFilterCacheUpdateInterval(); 185 static int GetFilterCacheSizeThreshold(); 186 static bool GetDynamicBrightnessEnabled(); 187 static bool GetMaskLinearBlurEnabled(); 188 static bool GetMotionBlurEnabled(); 189 static bool GetDrmEnabled(); 190 static bool GetMagnifierEnabled(); 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 GetKawaseOriginalEnabled(); 198 static bool GetBlurEnabled(); 199 static bool GetForegroundFilterEnabled(); 200 static const std::vector<float>& GetAiInvertCoef(); 201 static bool GetSkipForAlphaZeroEnabled(); 202 static bool GetSkipGeometryNotChangeEnabled(); 203 static bool GetRenderParallelEnabled(); 204 static bool GetPropertyDrawableEnable(); 205 206 static bool GetDrawFilterWithoutSnapshotEnabled(); 207 static bool GetBlurExtraFilterEnabled(); 208 static bool GetPurgeBetweenFramesEnabled(); 209 static bool GetGpuMemoryAsyncReclaimerEnabled(); 210 static bool GetGpuCacheSuppressWindowEnabled(); 211 212 static bool GetAnimationCacheEnabled(); 213 214 static bool GetBoolSystemProperty(const char* name, bool defaultValue); 215 static int WatchSystemProperty(const char* name, OnSystemPropertyChanged func, void* context); 216 static bool GetUIFirstEnabled(); 217 static bool GetUIFirstDebugEnabled(); 218 static bool GetSurfaceOffscreenEnadbled(); 219 static bool GetDebugTraceEnabled(); 220 static bool GetImageReleaseUsingPostTask(); 221 static int GetDebugTraceLevel(); 222 static bool FindNodeInTargetList(std::string node); 223 static bool IsFoldScreenFlag(); 224 static bool GetCacheCmdEnabled(); 225 static bool GetASTCEnabled(); 226 static bool GetCachedBlurPartialRenderEnabled(); 227 static bool GetImageGpuResourceCacheEnable(int width, int height); 228 static bool GetSnapshotWithDMAEnabled(); 229 static bool IsPhoneType(); 230 static bool IsTabletType(); 231 static bool IsPcType(); 232 static bool GetSyncTransactionEnabled(); 233 static int GetSyncTransactionWaitDelay(); 234 static bool GetSingleFrameComposerEnabled(); 235 static bool GetSingleFrameComposerCanvasNodeEnabled(); 236 static bool GetSubSurfaceEnabled(); 237 static bool GetSecurityPermissionCheckEnabled(); 238 static bool GetParallelUploadTexture(); 239 static bool GetEffectMergeEnabled(); 240 static SubTreePrepareCheckType GetSubTreePrepareCheckType(); 241 static bool IsForceClient(); 242 static bool GetHDRImageEnable(); 243 static bool GetGpuOverDrawBufferOptimizeEnabled(); 244 245 static bool GetDrmMarkedFilterEnabled(); 246 247 static DdgrOpincType GetDdgrOpincType(); 248 static bool IsDdgrOpincEnable(); 249 static bool GetAutoCacheDebugEnabled(); 250 static DdgrOpincDfxType GetDdgrOpincDfxType(); 251 static bool IsOpincRealDrawCacheEnable(); 252 static bool GetSkipDisplayIfScreenOffEnabled(); 253 static bool GetBatchRemovingOnRemoteDiedEnabled(); 254 255 #ifdef RS_ENABLE_STACK_CULLING 256 static bool GetViewOcclusionCullingEnabled(); 257 #endif 258 259 static bool GetDumpUICaptureEnabled(); 260 static bool GetDumpUIPixelmapEnabled(); 261 static int GetVirtualScreenScaleModeDFX(); 262 static bool GetDumpImgEnabled(); 263 264 static bool GetTransactionTerminateEnabled(); 265 static bool GetTextBlobAsPixelMap(); GetGpuApiType()266 static inline GpuApiType GetGpuApiType() 267 { 268 return RSSystemProperties::systemGpuApiType_; 269 } 270 271 static int GetRSNodeLimit(); IsUseVulkan()272 static inline bool IsUseVulkan() 273 { 274 return RSSystemProperties::GetGpuApiType() != GpuApiType::OPENGL; 275 } 276 277 static std::string GetVersionType(); 278 static bool GetHwcDirtyRegionEnabled(); 279 static bool GetHveFilterEnabled(); 280 private: 281 RSSystemProperties() = default; 282 283 static inline bool isUniRenderEnabled_ = false; 284 inline static bool isDrawTextAsBitmap_ = false; 285 inline static bool cacheEnabledForRotation_ = false; 286 static inline bool forceHpsBlurDisabled_ = false; 287 static const GpuApiType systemGpuApiType_; 288 static const DdgrOpincType ddgrOpincType_; 289 static const DdgrOpincDfxType ddgrOpincDfxType_; 290 }; 291 } // namespace Rosen 292 } // namespace OHOS 293 294 #endif // RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H 295