Properties.h revision 4badfe6d3beda8e1e358334e32a95e00be39f031
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/properties.h> 21 22/** 23 * This file contains the list of system properties used to configure libhwui. 24 */ 25 26namespace android { 27namespace 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 */ 54enum 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 * Used to enable/disable non-rectangular clipping debugging. 98 * 99 * The accepted values are: 100 * "highlight", drawing commands clipped by the stencil will 101 * be colored differently 102 * "region", renders the clipping region on screen whenever 103 * the stencil is set 104 * "hide", don't show the clip 105 * 106 * The default value is "hide". 107 */ 108#define PROPERTY_DEBUG_STENCIL_CLIP "debug.hwui.show_non_rect_clip" 109 110/** 111 * Turn on to draw dirty regions every other frame. 112 * 113 * Possible values: 114 * "true", to enable dirty regions debugging 115 * "false", to disable dirty regions debugging 116 */ 117#define PROPERTY_DEBUG_SHOW_DIRTY_REGIONS "debug.hwui.show_dirty_regions" 118 119/** 120 * Disables draw operation deferral if set to "true", forcing draw 121 * commands to be issued to OpenGL in order, and processed in sequence 122 * with state-manipulation canvas commands. 123 */ 124#define PROPERTY_DISABLE_DRAW_DEFER "debug.hwui.disable_draw_defer" 125 126/** 127 * Used to disable draw operation reordering when deferring draw operations 128 * Has no effect if PROPERTY_DISABLE_DRAW_DEFER is set to "true" 129 */ 130#define PROPERTY_DISABLE_DRAW_REORDER "debug.hwui.disable_draw_reorder" 131 132/** 133 * Setting this property will enable or disable the dropping of frames with 134 * empty damage. Default is "true". 135 */ 136#define PROPERTY_SKIP_EMPTY_DAMAGE "debug.hwui.skip_empty_damage" 137 138/** 139 * Controls whether or not HWUI will use the EGL_EXT_buffer_age extension 140 * to do partial invalidates. Setting this to "false" will fall back to 141 * using BUFFER_PRESERVED instead 142 * Default is "true" 143 */ 144#define PROPERTY_USE_BUFFER_AGE "debug.hwui.use_buffer_age" 145 146/** 147 * Setting this to "false" will force HWUI to always do full-redraws of the surface. 148 * This will disable the use of EGL_EXT_buffer_age and BUFFER_PRESERVED. 149 * Default is "true" 150 */ 151#define PROPERTY_ENABLE_PARTIAL_UPDATES "debug.hwui.use_partial_updates" 152 153#define PROPERTY_FILTER_TEST_OVERHEAD "debug.hwui.filter_test_overhead" 154 155/** 156 * Allows to set rendering pipeline mode to OpenGL (default), Skia OpenGL 157 * or Vulkan. 158 */ 159#define PROPERTY_RENDERER "debug.hwui.renderer" 160 161/////////////////////////////////////////////////////////////////////////////// 162// Runtime configuration properties 163/////////////////////////////////////////////////////////////////////////////// 164 165/** 166 * Used to enable/disable scissor optimization. The accepted values are 167 * "true" and "false". The default value is "false". 168 * 169 * When scissor optimization is enabled, libhwui will attempt to 170 * minimize the use of scissor by selectively enabling and disabling the 171 * GL scissor test. 172 * When the optimization is disabled, OpenGLRenderer will keep the GL 173 * scissor test enabled and change the scissor rect as needed. 174 * Some GPUs (for instance the SGX 540) perform better when changing 175 * the scissor rect often than when enabling/disabling the scissor test 176 * often. 177 */ 178#define PROPERTY_DISABLE_SCISSOR_OPTIMIZATION "ro.hwui.disable_scissor_opt" 179 180/** 181 * Indicates whether PBOs can be used to back pixel buffers. 182 * Accepted values are "true" and "false". Default is true. 183 */ 184#define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "ro.hwui.use_gpu_pixel_buffers" 185 186// These properties are defined in mega-bytes 187#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size" 188#define PROPERTY_LAYER_CACHE_SIZE "ro.hwui.layer_cache_size" 189#define PROPERTY_RENDER_BUFFER_CACHE_SIZE "ro.hwui.r_buffer_cache_size" 190#define PROPERTY_GRADIENT_CACHE_SIZE "ro.hwui.gradient_cache_size" 191#define PROPERTY_PATH_CACHE_SIZE "ro.hwui.path_cache_size" 192#define PROPERTY_VERTEX_CACHE_SIZE "ro.hwui.vertex_cache_size" 193#define PROPERTY_PATCH_CACHE_SIZE "ro.hwui.patch_cache_size" 194#define PROPERTY_DROP_SHADOW_CACHE_SIZE "ro.hwui.drop_shadow_cache_size" 195#define PROPERTY_FBO_CACHE_SIZE "ro.hwui.fbo_cache_size" 196 197// These properties are defined in percentage (range 0..1) 198#define PROPERTY_TEXTURE_CACHE_FLUSH_RATE "ro.hwui.texture_cache_flushrate" 199 200// These properties are defined in pixels 201#define PROPERTY_TEXT_SMALL_CACHE_WIDTH "ro.hwui.text_small_cache_width" 202#define PROPERTY_TEXT_SMALL_CACHE_HEIGHT "ro.hwui.text_small_cache_height" 203#define PROPERTY_TEXT_LARGE_CACHE_WIDTH "ro.hwui.text_large_cache_width" 204#define PROPERTY_TEXT_LARGE_CACHE_HEIGHT "ro.hwui.text_large_cache_height" 205 206// Gamma (>= 1.0, <= 3.0) 207#define PROPERTY_TEXT_GAMMA "hwui.text_gamma" 208 209/////////////////////////////////////////////////////////////////////////////// 210// Default property values 211/////////////////////////////////////////////////////////////////////////////// 212 213#define DEFAULT_TEXTURE_CACHE_SIZE 24.0f 214#define DEFAULT_LAYER_CACHE_SIZE 16.0f 215#define DEFAULT_RENDER_BUFFER_CACHE_SIZE 2.0f 216#define DEFAULT_PATH_CACHE_SIZE 4.0f 217#define DEFAULT_VERTEX_CACHE_SIZE 1.0f 218#define DEFAULT_PATCH_CACHE_SIZE 128.0f // in kB 219#define DEFAULT_GRADIENT_CACHE_SIZE 0.5f 220#define DEFAULT_DROP_SHADOW_CACHE_SIZE 2.0f 221#define DEFAULT_FBO_CACHE_SIZE 0 222 223#define DEFAULT_TEXTURE_CACHE_FLUSH_RATE 0.6f 224 225#define DEFAULT_TEXT_GAMMA 1.45f // Match design tools 226 227// cap to 256 to limite paths in the path cache 228#define DEFAULT_PATH_TEXTURE_CAP 256 229 230/////////////////////////////////////////////////////////////////////////////// 231// Misc 232/////////////////////////////////////////////////////////////////////////////// 233 234// Converts a number of mega-bytes into bytes 235#define MB(s) ((s) * 1024 * 1024) 236// Converts a number of kilo-bytes into bytes 237#define KB(s) ((s) * 1024) 238 239enum class ProfileType { 240 None, 241 Console, 242 Bars 243}; 244 245enum class OverdrawColorSet { 246 Default = 0, 247 Deuteranomaly 248}; 249 250enum class StencilClipDebug { 251 Hide, 252 ShowHighlight, 253 ShowRegion 254}; 255 256enum class RenderPipelineType { 257 OpenGL = 0, 258 SkiaGL, 259 SkiaVulkan, 260 NotInitialized = 128 261}; 262 263/** 264 * Renderthread-only singleton which manages several static rendering properties. Most of these 265 * are driven by system properties which are queried once at initialization, and again if init() 266 * is called. 267 */ 268class Properties { 269public: 270 static bool load(); 271 272 static bool drawDeferDisabled; 273 static bool drawReorderDisabled; 274 static bool debugLayersUpdates; 275 static bool debugOverdraw; 276 static bool showDirtyRegions; 277 // TODO: Remove after stabilization period 278 static bool skipEmptyFrames; 279 static bool useBufferAge; 280 static bool enablePartialUpdates; 281 282 static float textGamma; 283 284 static int fboCacheSize; 285 static int gradientCacheSize; 286 static int layerPoolSize; 287 static int patchCacheSize; 288 static int pathCacheSize; 289 static int renderBufferCacheSize; 290 static int tessellationCacheSize; 291 static int textDropShadowCacheSize; 292 static int textureCacheSize; 293 static float textureCacheFlushRate; 294 295 static DebugLevel debugLevel; 296 static OverdrawColorSet overdrawColorSet; 297 static StencilClipDebug debugStencilClip; 298 299 // Override the value for a subset of properties in this class 300 static void overrideProperty(const char* name, const char* value); 301 302 static float overrideLightRadius; 303 static float overrideLightPosY; 304 static float overrideLightPosZ; 305 static float overrideAmbientRatio; 306 static int overrideAmbientShadowStrength; 307 static int overrideSpotShadowStrength; 308 309 static ProfileType getProfileType(); 310 static RenderPipelineType getRenderPipelineType(); 311 static bool isSkiaEnabled(); 312 313 // Should be used only by test apps 314 static bool waitForGpuCompletion; 315 static bool forceDrawFrame; 316 317 // Should only be set by automated tests to try and filter out 318 // any overhead they add 319 static bool filterOutTestOverhead; 320 321 // Used for testing only to change the render pipeline. 322#ifdef HWUI_GLES_WRAP_ENABLED 323 static void overrideRenderPipelineType(RenderPipelineType); 324#endif 325 326private: 327 static ProfileType sProfileType; 328 static bool sDisableProfileBars; 329 static RenderPipelineType sRenderPipelineType; 330}; // class Caches 331 332}; // namespace uirenderer 333}; // namespace android 334 335#endif // ANDROID_HWUI_PROPERTIES_H 336