| 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 | * Property for globally GL drawing state. Can be overridden per process with |
| 192 | * setDrawingEnabled. |
| 193 | */ |
| 194 | #define PROPERTY_DRAWING_ENABLED "debug.hwui.drawing_enabled" |
| 195 | |
| 196 | /////////////////////////////////////////////////////////////////////////////// |
| 197 | // Misc |
| 198 | /////////////////////////////////////////////////////////////////////////////// |
| 199 | |
| 200 | // Converts a number of mega-bytes into bytes |
| 201 | #define MB(s) ((s)*1024 * 1024) |
| 202 | // Converts a number of kilo-bytes into bytes |
| 203 | #define KB(s) ((s)*1024) |
| 204 | |
| 205 | enum class ProfileType { None, Console, Bars }; |
| 206 | |
| 207 | enum class OverdrawColorSet { Default = 0, Deuteranomaly }; |
| 208 | |
| 209 | enum class RenderPipelineType { SkiaGL, SkiaVulkan, NotInitialized = 128 }; |
| 210 | |
| 211 | enum class StretchEffectBehavior { |
| 212 | ShaderHWUI, // Stretch shader in HWUI only, matrix scale in SF |
| 213 | Shader, // Stretch shader in both HWUI and SF |
| 214 | UniformScale // Uniform scale stretch everywhere |
| 215 | }; |
| 216 | |
| 217 | enum class DrawingEnabled { NotInitialized, On, Off }; |
| 218 | |
| 219 | /** |
| 220 | * Renderthread-only singleton which manages several static rendering properties. Most of these |
| 221 | * are driven by system properties which are queried once at initialization, and again if init() |
| 222 | * is called. |
| 223 | */ |
| 224 | class Properties { |
| 225 | public: |
| 226 | static bool load(); |
| 227 | |
| 228 | static bool debugLayersUpdates; |
| 229 | static bool debugOverdraw; |
| 230 | static bool showDirtyRegions; |
| 231 | // TODO: Remove after stabilization period |
| 232 | static bool skipEmptyFrames; |
| 233 | static bool useBufferAge; |
| 234 | static bool enablePartialUpdates; |
| 235 | static bool enableRenderEffectCache; |
| 236 | |
| 237 | // TODO: Move somewhere else? |
| 238 | static constexpr float textGamma = 1.45f; |
| 239 | |
| 240 | static DebugLevel debugLevel; |
| 241 | static OverdrawColorSet overdrawColorSet; |
| 242 | |
| 243 | // Override the value for a subset of properties in this class |
| 244 | static void overrideProperty(const char* name, const char* value); |
| 245 | |
| 246 | static float overrideLightRadius; |
| 247 | static float overrideLightPosY; |
| 248 | static float overrideLightPosZ; |
| 249 | static float overrideAmbientRatio; |
| 250 | static int overrideAmbientShadowStrength; |
| 251 | static int overrideSpotShadowStrength; |
| 252 | |
| 253 | static ProfileType getProfileType(); |
| 254 | static RenderPipelineType peekRenderPipelineType(); |
| 255 | static RenderPipelineType getRenderPipelineType(); |
| 256 | |
| 257 | static bool enableHighContrastText; |
| 258 | |
| 259 | // Should be used only by test apps |
| 260 | static bool waitForGpuCompletion; |
| 261 | static bool forceDrawFrame; |
| 262 | |
| 263 | // Should only be set by automated tests to try and filter out |
| 264 | // any overhead they add |
| 265 | static bool filterOutTestOverhead; |
| 266 | |
| 267 | // Workaround a device lockup in edge cases by switching to async mode |
| 268 | // instead of the default vsync (b/38372997). Only system_server should hit this. |
| 269 | // Any existing RenderProxy & Surface combination will be unaffected, only things |
| 270 | // created after changing this. |
| 271 | static bool disableVsync; |
| 272 | |
| 273 | static bool skpCaptureEnabled; |
| 274 | |
| 275 | // For experimentation b/68769804 |
| 276 | static bool enableRTAnimations; |
| 277 | |
| 278 | // Used for testing only to change the render pipeline. |
| 279 | static void overrideRenderPipelineType(RenderPipelineType, bool inUnitTest = false); |
| 280 | |
| 281 | static bool runningInEmulator; |
| 282 | |
| 283 | static bool debuggingEnabled; |
| 284 | static bool isolatedProcess; |
| 285 | |
| 286 | static int contextPriority; |
| 287 | |
| 288 | static float defaultSdrWhitePoint; |
| 289 | |
| 290 | static bool useHintManager; |
| 291 | static int targetCpuTimePercentage; |
| 292 | |
| 293 | static bool enableWebViewOverlays; |
| 294 | |
| 295 | static StretchEffectBehavior getStretchEffectBehavior() { |
| 296 | return stretchEffectBehavior; |
| 297 | } |
| 298 | |
| 299 | static void setIsHighEndGfx(bool isHighEndGfx) { |
| 300 | stretchEffectBehavior = isHighEndGfx ? |
| 301 | StretchEffectBehavior::ShaderHWUI : |
| 302 | StretchEffectBehavior::UniformScale; |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * Used for testing. Typical configuration of stretch behavior is done |
| 307 | * through setIsHighEndGfx |
| 308 | */ |
| 309 | static void setStretchEffectBehavior(StretchEffectBehavior behavior) { |
| 310 | stretchEffectBehavior = behavior; |
| 311 | } |
| 312 | |
| 313 | // Represents if drawing is enabled. Should only be Off in headless testing environments |
| 314 | static DrawingEnabled drawingEnabled; |
| 315 | static bool isDrawingEnabled(); |
| 316 | static void setDrawingEnabled(bool enable); |
| 317 | |
| 318 | private: |
| 319 | static StretchEffectBehavior stretchEffectBehavior; |
| 320 | static ProfileType sProfileType; |
| 321 | static bool sDisableProfileBars; |
| 322 | static RenderPipelineType sRenderPipelineType; |
| 323 | }; // class Caches |
| 324 | |
| 325 | } // namespace uirenderer |
| 326 | } // namespace android |
| 327 | |
| 328 | #endif // ANDROID_HWUI_PROPERTIES_H |