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 }; 37 38 enum class PartialRenderType { 39 DISABLED = 0, // 0, disable partial render 40 SET_DAMAGE, // 1, set damageregion, without draw_op dropping 41 SET_DAMAGE_AND_DROP_OP, // 2, drop draw_op if node is not in dirty region 42 SET_DAMAGE_AND_DROP_OP_OCCLUSION, // 3, drop draw_op if node is not in visible region (unirender) 43 SET_DAMAGE_AND_DROP_OP_NOT_VISIBLEDIRTY // 4, drop draw_op if node is not in visible dirty region (unirender) 44 }; 45 46 enum class DumpSurfaceType { 47 DISABLED = 0, 48 SINGLESURFACE, 49 ALLSURFACES, 50 PIXELMAP, 51 }; 52 53 /* ContainerWindowConfigType 54 // -1, disable round corner's transparent region 55 // 0, roundcorner surfacenode has a strip size transparent region 56 // 1, on the base of ENABLED_LEVEL_0, unfocused surface's side boundary is opaque 57 // 2, on the base of ENABLED_LEVEL_0, unfocused surface only has 4 little squares as transparent region 58 */ 59 enum class ContainerWindowConfigType { 60 DISABLED = -1, 61 ENABLED_LEVEL_0 = 0, 62 ENABLED_UNFOCUSED_WINDOW_LEVEL_1 = 1, 63 ENABLED_UNFOCUSED_WINDOW_LEVEL_2 = 2, 64 }; 65 66 using OnSystemPropertyChanged = void(*)(const char*, const char*, void*); 67 68 class RSB_EXPORT RSSystemProperties final { 69 public: 70 ~RSSystemProperties() = default; 71 72 // used by clients 73 static bool GetUniRenderEnabled(); 74 static bool GetRenderNodeTraceEnabled(); 75 static DirtyRegionDebugType GetDirtyRegionDebugType(); 76 static PartialRenderType GetPartialRenderEnabled(); 77 static PartialRenderType GetUniPartialRenderEnabled(); 78 static ContainerWindowConfigType GetContainerWindowConfig(); 79 static bool GetOcclusionEnabled(); 80 static std::string GetRSEventProperty(const std::string ¶Name); 81 static bool GetDirectClientCompEnableStatus(); 82 static bool GetHighContrastStatus(); 83 static uint32_t GetCorrectionMode(); 84 static bool IsUniRenderMode(); 85 static void SetRenderMode(bool isUni); 86 static DumpSurfaceType GetDumpSurfaceType(); 87 static uint64_t GetDumpSurfaceId(); 88 static bool GetTargetDirtyRegionDfxEnabled(std::vector<std::string>& dfxTargetSurfaceNames_); 89 90 static void SetDrawTextAsBitmap(bool flag); 91 static bool GetDrawTextAsBitmap(); 92 93 static bool GetColdStartThreadEnabled(); 94 static float GetAnimationScale(); 95 96 static bool GetBoolSystemProperty(const char* name, bool defaultValue); 97 static int WatchSystemProperty(const char* name, OnSystemPropertyChanged func, void* context); 98 private: 99 RSSystemProperties() = default; 100 101 static inline bool isUniRenderEnabled_ = false; 102 static inline std::atomic_bool isUniRenderMode_ = false; 103 inline static bool isDrawTextAsBitmap_ = false; 104 }; 105 106 } // namespace Rosen 107 } // namespace OHOS 108 109 #endif // RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H 110