Properties.h revision 938e884a1fcc385dba5a41475aad76d8b7189609
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#include <cutils/properties.h> 22 23/** 24 * This file contains the list of system properties used to configure libhwui. 25 */ 26 27namespace android { 28namespace uirenderer { 29 30/////////////////////////////////////////////////////////////////////////////// 31// Compile-time properties 32/////////////////////////////////////////////////////////////////////////////// 33 34// Textures used by layers must have dimensions multiples of this number 35#define LAYER_SIZE 64 36 37// Defines the size in bits of the stencil buffer for the framebuffer 38// Note: Only 1 bit is required for clipping but more bits are required 39// to properly implement overdraw debugging 40#define STENCIL_BUFFER_SIZE 8 41 42/////////////////////////////////////////////////////////////////////////////// 43// Debug properties 44/////////////////////////////////////////////////////////////////////////////// 45 46/** 47 * Debug level for app developers. The value is a numeric value defined 48 * by the DebugLevel enum below. 49 */ 50#define PROPERTY_DEBUG "debug.hwui.level" 51 52/** 53 * Debug levels. Debug levels are used as flags. 54 */ 55enum DebugLevel { 56 kDebugDisabled = 0, 57 kDebugMemory = 1, 58 kDebugCaches = 2, 59 kDebugMoreCaches = kDebugMemory | kDebugCaches 60}; 61 62/** 63 * Used to enable/disable layers update debugging. The accepted values are 64 * "true" and "false". The default value is "false". 65 */ 66#define PROPERTY_DEBUG_LAYERS_UPDATES "debug.hwui.show_layers_updates" 67 68/** 69 * Used to enable/disable overdraw debugging. 70 * 71 * The accepted values are 72 * "show", to show overdraw 73 * "show_deuteranomaly", to show overdraw if you suffer from Deuteranomaly 74 * "count", to show an overdraw counter 75 * "false", to disable overdraw debugging 76 * 77 * The default value is "false". 78 */ 79#define PROPERTY_DEBUG_OVERDRAW "debug.hwui.overdraw" 80 81/** 82 * System property used to enable or disable hardware rendering profiling. 83 * The default value of this property is assumed to be false. 84 * 85 * When profiling is enabled, the adb shell dumpsys gfxinfo command will 86 * output extra information about the time taken to execute by the last 87 * frames. 88 * 89 * Possible values: 90 * "true", to enable profiling 91 * "visual_bars", to enable profiling and visualize the results on screen 92 * "false", to disable profiling 93 */ 94#define PROPERTY_PROFILE "debug.hwui.profile" 95#define PROPERTY_PROFILE_VISUALIZE_BARS "visual_bars" 96 97/** 98 * Used to enable/disable non-rectangular clipping debugging. 99 * 100 * The accepted values are: 101 * "highlight", drawing commands clipped by the stencil will 102 * be colored differently 103 * "region", renders the clipping region on screen whenever 104 * the stencil is set 105 * "hide", don't show the clip 106 * 107 * The default value is "hide". 108 */ 109#define PROPERTY_DEBUG_STENCIL_CLIP "debug.hwui.show_non_rect_clip" 110 111/** 112 * Turn on to draw dirty regions every other frame. 113 * 114 * Possible values: 115 * "true", to enable dirty regions debugging 116 * "false", to disable dirty regions debugging 117 */ 118#define PROPERTY_DEBUG_SHOW_DIRTY_REGIONS "debug.hwui.show_dirty_regions" 119 120/** 121 * Disables draw operation deferral if set to "true", forcing draw 122 * commands to be issued to OpenGL in order, and processed in sequence 123 * with state-manipulation canvas commands. 124 */ 125#define PROPERTY_DISABLE_DRAW_DEFER "debug.hwui.disable_draw_defer" 126 127/** 128 * Used to disable draw operation reordering when deferring draw operations 129 * Has no effect if PROPERTY_DISABLE_DRAW_DEFER is set to "true" 130 */ 131#define PROPERTY_DISABLE_DRAW_REORDER "debug.hwui.disable_draw_reorder" 132 133/** 134 * Setting this property will enable or disable the dropping of frames with 135 * empty damage. Default is "true". 136 */ 137#define PROPERTY_SKIP_EMPTY_DAMAGE "debug.hwui.skip_empty_damage" 138 139/** 140 * Controls whether or not HWUI will use the EGL_EXT_buffer_age extension 141 * to do partial invalidates. Setting this to "false" will fall back to 142 * using BUFFER_PRESERVED instead 143 * Default is "true" 144 */ 145#define PROPERTY_USE_BUFFER_AGE "debug.hwui.use_buffer_age" 146 147/** 148 * Setting this to "false" will force HWUI to always do full-redraws of the surface. 149 * This will disable the use of EGL_EXT_buffer_age and BUFFER_PRESERVED. 150 * Default is "true" 151 */ 152#define PROPERTY_ENABLE_PARTIAL_UPDATES "debug.hwui.use_partial_updates" 153 154#define PROPERTY_FILTER_TEST_OVERHEAD "debug.hwui.filter_test_overhead" 155 156/** 157 * Indicates whether PBOs can be used to back pixel buffers. 158 * Accepted values are "true" and "false". Default is true. 159 */ 160#define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "debug.hwui.use_gpu_pixel_buffers" 161 162/** 163 * Allows to set rendering pipeline mode to OpenGL (default), Skia OpenGL 164 * or Vulkan. 165 */ 166#define PROPERTY_RENDERER "debug.hwui.renderer" 167 168/////////////////////////////////////////////////////////////////////////////// 169// Misc 170/////////////////////////////////////////////////////////////////////////////// 171 172// Converts a number of mega-bytes into bytes 173#define MB(s) ((s) * 1024 * 1024) 174// Converts a number of kilo-bytes into bytes 175#define KB(s) ((s) * 1024) 176 177enum class ProfileType { 178 None, 179 Console, 180 Bars 181}; 182 183enum class OverdrawColorSet { 184 Default = 0, 185 Deuteranomaly 186}; 187 188enum class StencilClipDebug { 189 Hide, 190 ShowHighlight, 191 ShowRegion 192}; 193 194enum class RenderPipelineType { 195 OpenGL = 0, 196 SkiaGL, 197 SkiaVulkan, 198 NotInitialized = 128 199}; 200 201/** 202 * Renderthread-only singleton which manages several static rendering properties. Most of these 203 * are driven by system properties which are queried once at initialization, and again if init() 204 * is called. 205 */ 206class Properties { 207public: 208 static bool load(); 209 210 static bool drawDeferDisabled; 211 static bool drawReorderDisabled; 212 static bool debugLayersUpdates; 213 static bool debugOverdraw; 214 static bool showDirtyRegions; 215 // TODO: Remove after stabilization period 216 static bool skipEmptyFrames; 217 static bool useBufferAge; 218 static bool enablePartialUpdates; 219 220 // TODO: Move somewhere else? 221 static constexpr float textGamma = 1.45f; 222 223 static DebugLevel debugLevel; 224 static OverdrawColorSet overdrawColorSet; 225 static StencilClipDebug debugStencilClip; 226 227 // Override the value for a subset of properties in this class 228 static void overrideProperty(const char* name, const char* value); 229 230 static float overrideLightRadius; 231 static float overrideLightPosY; 232 static float overrideLightPosZ; 233 static float overrideAmbientRatio; 234 static int overrideAmbientShadowStrength; 235 static int overrideSpotShadowStrength; 236 237 static ProfileType getProfileType(); 238 static RenderPipelineType getRenderPipelineType(); 239 static bool isSkiaEnabled(); 240 241 ANDROID_API static bool enableHighContrastText; 242 243 // Should be used only by test apps 244 static bool waitForGpuCompletion; 245 static bool forceDrawFrame; 246 247 // Should only be set by automated tests to try and filter out 248 // any overhead they add 249 static bool filterOutTestOverhead; 250 251 // Workaround a device lockup in edge cases by switching to async mode 252 // instead of the default vsync (b/38372997). Only system_server should hit this. 253 // Any existing RenderProxy & Surface combination will be unaffected, only things 254 // created after changing this. 255 static bool disableVsync; 256 257 // Used for testing only to change the render pipeline. 258#ifdef HWUI_GLES_WRAP_ENABLED 259 static void overrideRenderPipelineType(RenderPipelineType); 260#endif 261 262private: 263 static ProfileType sProfileType; 264 static bool sDisableProfileBars; 265 static RenderPipelineType sRenderPipelineType; 266}; // class Caches 267 268}; // namespace uirenderer 269}; // namespace android 270 271#endif // ANDROID_HWUI_PROPERTIES_H 272