1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_HWUI_PROPERTIES_H 18 #define ANDROID_HWUI_PROPERTIES_H 19 20 #include <cutils/compiler.h> 21 22 /** 23 * This file contains the list of system properties used to configure libhwui. 24 */ 25 26 namespace android { 27 namespace uirenderer { 28 29 /////////////////////////////////////////////////////////////////////////////// 30 // Compile-time properties 31 /////////////////////////////////////////////////////////////////////////////// 32 33 // Textures used by layers must have dimensions multiples of this number 34 #define LAYER_SIZE 64 35 36 // Defines the size in bits of the stencil buffer for the framebuffer 37 // Note: Only 1 bit is required for clipping but more bits are required 38 // to properly implement overdraw debugging 39 #define STENCIL_BUFFER_SIZE 8 40 41 /////////////////////////////////////////////////////////////////////////////// 42 // Debug properties 43 /////////////////////////////////////////////////////////////////////////////// 44 45 /** 46 * Debug level for app developers. The value is a numeric value defined 47 * by the DebugLevel enum below. 48 */ 49 #define PROPERTY_DEBUG "debug.hwui.level" 50 51 /** 52 * Debug levels. Debug levels are used as flags. 53 */ 54 enum DebugLevel { 55 kDebugDisabled = 0, 56 kDebugMemory = 1, 57 kDebugCaches = 2, 58 kDebugMoreCaches = kDebugMemory | kDebugCaches 59 }; 60 61 /** 62 * Used to enable/disable layers update debugging. The accepted values are 63 * "true" and "false". The default value is "false". 64 */ 65 #define PROPERTY_DEBUG_LAYERS_UPDATES "debug.hwui.show_layers_updates" 66 67 /** 68 * Used to enable/disable overdraw debugging. 69 * 70 * The accepted values are 71 * "show", to show overdraw 72 * "show_deuteranomaly", to show overdraw if you suffer from Deuteranomaly 73 * "count", to show an overdraw counter 74 * "false", to disable overdraw debugging 75 * 76 * The default value is "false". 77 */ 78 #define PROPERTY_DEBUG_OVERDRAW "debug.hwui.overdraw" 79 80 /** 81 * System property used to enable or disable hardware rendering profiling. 82 * The default value of this property is assumed to be false. 83 * 84 * When profiling is enabled, the adb shell dumpsys gfxinfo command will 85 * output extra information about the time taken to execute by the last 86 * frames. 87 * 88 * Possible values: 89 * "true", to enable profiling 90 * "visual_bars", to enable profiling and visualize the results on screen 91 * "false", to disable profiling 92 */ 93 #define PROPERTY_PROFILE "debug.hwui.profile" 94 #define PROPERTY_PROFILE_VISUALIZE_BARS "visual_bars" 95 96 /** 97 * Turn on to draw dirty regions every other frame. 98 * 99 * Possible values: 100 * "true", to enable dirty regions debugging 101 * "false", to disable dirty regions debugging 102 */ 103 #define PROPERTY_DEBUG_SHOW_DIRTY_REGIONS "debug.hwui.show_dirty_regions" 104 105 /** 106 * Setting this property will enable or disable the dropping of frames with 107 * empty damage. Default is "true". 108 */ 109 #define PROPERTY_SKIP_EMPTY_DAMAGE "debug.hwui.skip_empty_damage" 110 111 /** 112 * Controls whether or not HWUI will use the EGL_EXT_buffer_age extension 113 * to do partial invalidates. Setting this to "false" will fall back to 114 * using BUFFER_PRESERVED instead 115 * Default is "true" 116 */ 117 #define PROPERTY_USE_BUFFER_AGE "debug.hwui.use_buffer_age" 118 119 /** 120 * Setting this to "false" will force HWUI to always do full-redraws of the surface. 121 * This will disable the use of EGL_EXT_buffer_age and BUFFER_PRESERVED. 122 * Default is "true" 123 */ 124 #define PROPERTY_ENABLE_PARTIAL_UPDATES "debug.hwui.use_partial_updates" 125 126 #define PROPERTY_FILTER_TEST_OVERHEAD "debug.hwui.filter_test_overhead" 127 128 /** 129 * Indicates whether PBOs can be used to back pixel buffers. 130 * Accepted values are "true" and "false". Default is true. 131 */ 132 #define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "debug.hwui.use_gpu_pixel_buffers" 133 134 /** 135 * Allows to set rendering pipeline mode to OpenGL (default), Skia OpenGL 136 * or Vulkan. 137 */ 138 #define PROPERTY_RENDERER "debug.hwui.renderer" 139 140 /** 141 * Allows to collect a recording of Skia drawing commands. 142 */ 143 #define PROPERTY_CAPTURE_SKP_ENABLED "debug.hwui.capture_skp_enabled" 144 145 /** 146 * Allows to record Skia drawing commands with systrace. 147 */ 148 #define PROPERTY_SKIA_ATRACE_ENABLED "debug.hwui.skia_atrace_enabled" 149 150 /** 151 * Defines how many frames in a sequence to capture. 152 */ 153 #define PROPERTY_CAPTURE_SKP_FRAMES "debug.hwui.capture_skp_frames" 154 155 /** 156 * File name and location, where a SKP recording will be saved. 157 */ 158 #define PROPERTY_CAPTURE_SKP_FILENAME "debug.hwui.skp_filename" 159 160 /** 161 * Controls whether HWUI will send timing hints to HintManager for 162 * better CPU scheduling. Accepted values are "true" and "false". 163 */ 164 #define PROPERTY_USE_HINT_MANAGER "debug.hwui.use_hint_manager" 165 166 /** 167 * Percentage of frame time that's used for CPU work. The rest is 168 * reserved for GPU work. This is used with use_hint_manager to 169 * provide timing hints to HintManager. Accepted values are 170 * integer from 1-100. 171 */ 172 #define PROPERTY_TARGET_CPU_TIME_PERCENTAGE "debug.hwui.target_cpu_time_percent" 173 174 /** 175 * Property for whether this is running in the emulator. 176 */ 177 #define PROPERTY_IS_EMULATOR "ro.boot.qemu" 178 179 /** 180 * Turns on the Skia GPU option "reduceOpsTaskSplitting" which improves GPU 181 * efficiency but may increase VRAM consumption. Default is "true". 182 */ 183 #define PROPERTY_REDUCE_OPS_TASK_SPLITTING "renderthread.skia.reduceopstasksplitting" 184 185 /** 186 * Enable WebView Overlays feature. 187 */ 188 #define PROPERTY_WEBVIEW_OVERLAYS_ENABLED "debug.hwui.webview_overlays_enabled" 189 190 /////////////////////////////////////////////////////////////////////////////// 191 // Misc 192 /////////////////////////////////////////////////////////////////////////////// 193 194 // Converts a number of mega-bytes into bytes 195 #define MB(s) ((s)*1024 * 1024) 196 // Converts a number of kilo-bytes into bytes 197 #define KB(s) ((s)*1024) 198 199 enum class ProfileType { None, Console, Bars }; 200 201 enum class OverdrawColorSet { Default = 0, Deuteranomaly }; 202 203 enum class RenderPipelineType { SkiaGL, SkiaVulkan, NotInitialized = 128 }; 204 205 enum class StretchEffectBehavior { 206 ShaderHWUI, // Stretch shader in HWUI only, matrix scale in SF 207 Shader, // Stretch shader in both HWUI and SF 208 UniformScale // Uniform scale stretch everywhere 209 }; 210 211 /** 212 * Renderthread-only singleton which manages several static rendering properties. Most of these 213 * are driven by system properties which are queried once at initialization, and again if init() 214 * is called. 215 */ 216 class Properties { 217 public: 218 static bool load(); 219 220 static bool debugLayersUpdates; 221 static bool debugOverdraw; 222 static bool showDirtyRegions; 223 // TODO: Remove after stabilization period 224 static bool skipEmptyFrames; 225 static bool useBufferAge; 226 static bool enablePartialUpdates; 227 static bool enableRenderEffectCache; 228 229 // TODO: Move somewhere else? 230 static constexpr float textGamma = 1.45f; 231 232 static DebugLevel debugLevel; 233 static OverdrawColorSet overdrawColorSet; 234 235 // Override the value for a subset of properties in this class 236 static void overrideProperty(const char* name, const char* value); 237 238 static float overrideLightRadius; 239 static float overrideLightPosY; 240 static float overrideLightPosZ; 241 static float overrideAmbientRatio; 242 static int overrideAmbientShadowStrength; 243 static int overrideSpotShadowStrength; 244 245 static ProfileType getProfileType(); 246 static RenderPipelineType peekRenderPipelineType(); 247 static RenderPipelineType getRenderPipelineType(); 248 249 static bool enableHighContrastText; 250 251 // Should be used only by test apps 252 static bool waitForGpuCompletion; 253 static bool forceDrawFrame; 254 255 // Should only be set by automated tests to try and filter out 256 // any overhead they add 257 static bool filterOutTestOverhead; 258 259 // Workaround a device lockup in edge cases by switching to async mode 260 // instead of the default vsync (b/38372997). Only system_server should hit this. 261 // Any existing RenderProxy & Surface combination will be unaffected, only things 262 // created after changing this. 263 static bool disableVsync; 264 265 static bool skpCaptureEnabled; 266 267 // For experimentation b/68769804 268 static bool enableRTAnimations; 269 270 // Used for testing only to change the render pipeline. 271 static void overrideRenderPipelineType(RenderPipelineType, bool inUnitTest = false); 272 273 static bool runningInEmulator; 274 275 static bool debuggingEnabled; 276 static bool isolatedProcess; 277 278 static int contextPriority; 279 280 static float defaultSdrWhitePoint; 281 282 static bool useHintManager; 283 static int targetCpuTimePercentage; 284 285 static bool enableWebViewOverlays; 286 getStretchEffectBehavior()287 static StretchEffectBehavior getStretchEffectBehavior() { 288 return stretchEffectBehavior; 289 } 290 setIsHighEndGfx(bool isHighEndGfx)291 static void setIsHighEndGfx(bool isHighEndGfx) { 292 stretchEffectBehavior = isHighEndGfx ? 293 StretchEffectBehavior::ShaderHWUI : 294 StretchEffectBehavior::UniformScale; 295 } 296 297 /** 298 * Used for testing. Typical configuration of stretch behavior is done 299 * through setIsHighEndGfx 300 */ setStretchEffectBehavior(StretchEffectBehavior behavior)301 static void setStretchEffectBehavior(StretchEffectBehavior behavior) { 302 stretchEffectBehavior = behavior; 303 } 304 305 private: 306 static StretchEffectBehavior stretchEffectBehavior; 307 static ProfileType sProfileType; 308 static bool sDisableProfileBars; 309 static RenderPipelineType sRenderPipelineType; 310 }; // class Caches 311 312 } // namespace uirenderer 313 } // namespace android 314 315 #endif // ANDROID_HWUI_PROPERTIES_H 316