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 25 namespace OHOS { 26 namespace Rosen { 27 28 enum class DirtyRegionDebugType { 29 DISABLED = 0, 30 CURRENT_SUB, 31 CURRENT_WHOLE, 32 MULTI_HISTORY, 33 CURRENT_SUB_AND_WHOLE, 34 CURRENT_WHOLE_AND_MULTI_HISTORY, 35 EGL_DAMAGE, 36 CUR_DIRTY_DETAIL_ONLY_TRACE = 10, 37 UPDATE_DIRTY_REGION, 38 OVERLAY_RECT, 39 FILTER_RECT, 40 SHADOW_RECT, 41 PREPARE_CLIP_RECT, 42 REMOVE_CHILD_RECT, 43 }; 44 45 enum class PartialRenderType { 46 DISABLED = 0, // 0, disable partial render 47 SET_DAMAGE, // 1, set damageregion, without draw_op dropping 48 SET_DAMAGE_AND_DROP_OP, // 2, drop draw_op if node is not in dirty region 49 SET_DAMAGE_AND_DROP_OP_OCCLUSION, // 3, drop draw_op if node is not in visible region (unirender) 50 SET_DAMAGE_AND_DROP_OP_NOT_VISIBLEDIRTY // 4, drop draw_op if node is not in visible dirty region (unirender) 51 }; 52 53 enum class ReleaseGpuResourceType { 54 DISABLED = 0, // 0, disable releaseGpuResource 55 WINDOW_HIDDEN, // 1, release window GpuResource when it Exit or GoBackGround 56 WINDOW_HIDDEN_AND_LAUCHER, // 2, release window and launcher GpuResource when it Exit or GoBackGround 57 }; 58 59 enum class DumpSurfaceType { 60 DISABLED = 0, 61 SINGLESURFACE, 62 ALLSURFACES, 63 PIXELMAP, 64 }; 65 66 enum class ParallelRenderingType { 67 AUTO = 0, 68 DISABLE = 1, 69 ENABLE = 2 70 }; 71 72 enum class HgmRefreshRates { 73 SET_RATE_NULL = 0, 74 SET_RATE_30 = 30, 75 SET_RATE_60 = 60, 76 SET_RATE_90 = 90, 77 SET_RATE_120 = 120 78 }; 79 80 enum class HgmRefreshRateModes { 81 SET_RATE_MODE_AUTO = -1, 82 SET_RATE_MODE_NULL = 0, 83 SET_RATE_MODE_LOW = 1, 84 SET_RATE_MODE_MEDIUN = 2, 85 SET_RATE_MODE_HIGH = 3 86 }; 87 88 using OnSystemPropertyChanged = void(*)(const char*, const char*, void*); 89 90 class RSB_EXPORT RSSystemProperties final { 91 public: 92 ~RSSystemProperties() = default; 93 94 // used by clients 95 static std::string GetRecordingFile(); 96 static bool IsSceneBoardEnabled(); 97 static int GetDumpFrameNum(); 98 static void SetRecordingDisenabled(); 99 static bool GetRecordingEnabled(); 100 101 static bool GetUniRenderEnabled(); 102 static bool GetRenderNodeTraceEnabled(); 103 static bool GetDrawOpTraceEnabled(); 104 static DirtyRegionDebugType GetDirtyRegionDebugType(); 105 static PartialRenderType GetPartialRenderEnabled(); 106 static PartialRenderType GetUniPartialRenderEnabled(); 107 static bool GetOcclusionEnabled(); 108 static std::string GetRSEventProperty(const std::string ¶Name); 109 static bool GetDirectClientCompEnableStatus(); 110 static bool GetHighContrastStatus(); 111 static uint32_t GetCorrectionMode(); 112 static DumpSurfaceType GetDumpSurfaceType(); 113 static long long int GetDumpSurfaceId(); 114 static bool GetTargetDirtyRegionDfxEnabled(std::vector<std::string>& dfxTargetSurfaceNames_); 115 static bool GetOpaqueRegionDfxEnabled(); 116 static bool GetDumpLayersEnabled(); 117 static bool GetHardwareComposerEnabled(); 118 static bool GetAFBCEnabled(); 119 static ReleaseGpuResourceType GetReleaseGpuResourceEnabled(); 120 121 static void SetDrawTextAsBitmap(bool flag); 122 static bool GetDrawTextAsBitmap(); 123 static ParallelRenderingType GetPrepareParallelRenderingEnabled(); 124 static ParallelRenderingType GetParallelRenderingEnabled(); 125 static HgmRefreshRates GetHgmRefreshRatesEnabled(); 126 static void SetHgmRefreshRateModesEnabled(std::string param); 127 static HgmRefreshRateModes GetHgmRefreshRateModesEnabled(); 128 129 static bool GetColdStartThreadEnabled(); 130 static float GetAnimationScale(); 131 static bool GetProxyNodeDebugEnabled(); 132 static bool GetFilterCacheEnabled(); 133 static int GetFilterCacheUpdateInterval(); 134 static int GetFilterCacheSizeThreshold(); 135 static bool GetKawaseEnabled(); 136 static bool GetBlurEnabled(); 137 static bool GetSkipForAlphaZeroEnabled(); 138 static bool GetSkipGeometryNotChangeEnabled(); 139 140 static bool GetBoolSystemProperty(const char* name, bool defaultValue); 141 static int WatchSystemProperty(const char* name, OnSystemPropertyChanged func, void* context); 142 static bool GetUIFirstEnabled(); 143 static bool GetDebugTraceEnabled(); 144 static bool GetCacheCmdEnabled(); 145 static bool GetASTCEnabled(); 146 static bool GetImageGpuResourceCacheEnable(int width, int height); 147 #if defined (ENABLE_DDGR_OPTIMIZE) 148 static bool GetDDGRIntegrateEnable(); 149 #endif 150 private: 151 RSSystemProperties() = default; 152 153 static inline bool isUniRenderEnabled_ = false; 154 inline static bool isDrawTextAsBitmap_ = false; 155 }; 156 157 } // namespace Rosen 158 } // namespace OHOS 159 160 #endif // RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H 161