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 }; 49 50 enum class SurfaceRegionDebugType { 51 DISABLED = 0, 52 OPAQUE_REGION, 53 VISIBLE_REGION, 54 }; 55 56 enum class PartialRenderType { 57 DISABLED = 0, // 0, disable partial render 58 SET_DAMAGE, // 1, set damageregion, without draw_op dropping 59 SET_DAMAGE_AND_DROP_OP, // 2, drop draw_op if node is not in dirty region 60 SET_DAMAGE_AND_DROP_OP_OCCLUSION, // 3, drop draw_op if node is not in visible region (unirender) 61 SET_DAMAGE_AND_DROP_OP_NOT_VISIBLEDIRTY // 4, drop draw_op if node is not in visible dirty region (unirender) 62 }; 63 64 enum class DumpSurfaceType { 65 DISABLED = 0, 66 SINGLESURFACE, 67 ALLSURFACES, 68 PIXELMAP, 69 SURFACEBUFFER 70 }; 71 72 enum class ParallelRenderingType { 73 AUTO = 0, 74 DISABLE = 1, 75 ENABLE = 2 76 }; 77 78 enum class HgmRefreshRates { 79 SET_RATE_NULL = 0, 80 SET_RATE_30 = 30, 81 SET_RATE_60 = 60, 82 SET_RATE_90 = 90, 83 SET_RATE_120 = 120 84 }; 85 86 enum class HgmRefreshRateModes { 87 SET_RATE_MODE_AUTO = -1, 88 SET_RATE_MODE_NULL = 0, 89 SET_RATE_MODE_LOW = 1, 90 SET_RATE_MODE_MEDIUN = 2, 91 SET_RATE_MODE_HIGH = 3 92 }; 93 94 using OnSystemPropertyChanged = void(*)(const char*, const char*, void*); 95 96 class RSB_EXPORT RSSystemProperties final { 97 public: 98 ~RSSystemProperties() = default; 99 100 // used by clients 101 static std::string GetRecordingFile(); 102 static bool IsSceneBoardEnabled(); 103 static int GetDumpFrameNum(); 104 static void SetRecordingDisenabled(); 105 static int GetRecordingEnabled(); 106 static int GetDumpRSTreeCount(); 107 static void SetDumpRSTreeCount(int count); 108 109 static bool GetUniRenderEnabled(); 110 static bool GetRenderNodeTraceEnabled(); 111 static bool GetDrawOpTraceEnabled(); 112 static DirtyRegionDebugType GetDirtyRegionDebugType(); 113 static PartialRenderType GetPartialRenderEnabled(); 114 static PartialRenderType GetUniPartialRenderEnabled(); 115 static bool GetOcclusionEnabled(); 116 static std::string GetRSEventProperty(const std::string ¶Name); 117 static bool GetDirectClientCompEnableStatus(); 118 static bool GetHighContrastStatus(); 119 static uint32_t GetCorrectionMode(); 120 static DumpSurfaceType GetDumpSurfaceType(); 121 static long long int GetDumpSurfaceId(); 122 static bool GetTargetDirtyRegionDfxEnabled(std::vector<std::string>& dfxTargetSurfaceNames_); 123 static bool GetOpaqueRegionDfxEnabled(); 124 static bool GetVisibleRegionDfxEnabled(); 125 static SurfaceRegionDebugType GetSurfaceRegionDfxType(); 126 static bool GetDumpLayersEnabled(); 127 static bool GetHardwareComposerEnabled(); 128 static bool GetAFBCEnabled(); 129 static bool GetReleaseResourceEnabled(); 130 static bool GetRSScreenRoundCornerEnable(); 131 132 static void SetDrawTextAsBitmap(bool flag); 133 static bool GetDrawTextAsBitmap(); 134 static void SetCacheEnabledForRotation(bool flag); 135 static bool GetCacheEnabledForRotation(); 136 static ParallelRenderingType GetPrepareParallelRenderingEnabled(); 137 static ParallelRenderingType GetParallelRenderingEnabled(); 138 static HgmRefreshRates GetHgmRefreshRatesEnabled(); 139 static void SetHgmRefreshRateModesEnabled(std::string param); 140 static HgmRefreshRateModes GetHgmRefreshRateModesEnabled(); 141 142 static float GetAnimationScale(); 143 static bool GetProxyNodeDebugEnabled(); 144 static bool GetFilterCacheEnabled(); 145 static int GetFilterCacheUpdateInterval(); 146 static int GetFilterCacheSizeThreshold(); 147 static bool GetFilterPartialRenderEnabled(); 148 static bool GetColorPickerPartialEnabled(); 149 static bool GetMaskLinearBlurEnabled(); 150 static bool GetKawaseEnabled(); 151 static float GetKawaseRandomColorFactor(); 152 static bool GetRandomColorEnabled(); 153 static bool GetKawaseOriginalEnabled(); 154 static bool GetBlurEnabled(); 155 static const std::vector<float>& GetAiInvertCoef(); 156 static bool GetSkipForAlphaZeroEnabled(); 157 static bool GetSkipGeometryNotChangeEnabled(); 158 static bool GetPropertyDrawableEnable(); 159 160 static bool GetAnimationCacheEnabled(); 161 162 static bool GetBoolSystemProperty(const char* name, bool defaultValue); 163 static int WatchSystemProperty(const char* name, OnSystemPropertyChanged func, void* context); 164 static bool GetUIFirstEnabled(); 165 static bool GetDebugTraceEnabled(); 166 static bool FindNodeInTargetList(std::string node); 167 static bool IsFoldScreenFlag(); 168 static bool GetCacheCmdEnabled(); 169 static bool GetASTCEnabled(); 170 static bool GetCachedBlurPartialRenderEnabled(); 171 static bool GetImageGpuResourceCacheEnable(int width, int height); 172 #if defined (ENABLE_DDGR_OPTIMIZE) 173 static bool GetDDGRIntegrateEnable(); 174 #endif 175 static bool GetSnapshotWithDMAEnabled(); 176 static bool IsPhoneType(); 177 static bool IsPcType(); 178 static bool GetSyncTransactionEnabled(); 179 static int GetSyncTransactionWaitDelay(); 180 static bool GetUseShadowBatchingEnabled(); 181 static bool GetSingleFrameComposerEnabled(); 182 static bool GetSingleFrameComposerCanvasNodeEnabled(); 183 static bool GetSubSurfaceEnabled(); 184 static bool GetSecurityPermissionCheckEnabled(); 185 static bool GetParallelUploadTexture(); 186 static bool GetEffectMergeEnabled(); 187 188 static bool GetDumpUICaptureEnabled(); 189 static bool GetDumpUIPixelmapEnabled(); 190 GetGpuApiType()191 static inline GpuApiType GetGpuApiType() 192 { 193 return RSSystemProperties::systemGpuApiType_; 194 } 195 196 private: 197 RSSystemProperties() = default; 198 199 static inline bool isUniRenderEnabled_ = false; 200 inline static bool isDrawTextAsBitmap_ = false; 201 inline static bool cacheEnabledForRotation_ = false; 202 static const GpuApiType systemGpuApiType_; 203 }; 204 205 } // namespace Rosen 206 } // namespace OHOS 207 208 #endif // RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H 209