Properties.h revision 6b50780363d3bb8db600c770183fa07677509ae8
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
24 * the OpenGLRenderer.
25 */
26
27namespace android {
28namespace uirenderer {
29
30///////////////////////////////////////////////////////////////////////////////
31// Compile-time properties
32///////////////////////////////////////////////////////////////////////////////
33
34// If turned on, text is interpreted as glyphs instead of UTF-16
35#define RENDER_TEXT_AS_GLYPHS 1
36
37// Textures used by layers must have dimensions multiples of this number
38#define LAYER_SIZE 64
39
40// Defines the size in bits of the stencil buffer for the framebuffer
41// Note: Only 1 bit is required for clipping but more bits are required
42// to properly implement overdraw debugging
43#define STENCIL_BUFFER_SIZE 8
44
45///////////////////////////////////////////////////////////////////////////////
46// Debug properties
47///////////////////////////////////////////////////////////////////////////////
48
49/**
50 * Debug level for app developers. The value is a numeric value defined
51 * by the DebugLevel enum below.
52 */
53#define PROPERTY_DEBUG "debug.hwui.level"
54
55/**
56 * Debug levels. Debug levels are used as flags.
57 */
58enum DebugLevel {
59    kDebugDisabled = 0,
60    kDebugMemory = 1,
61    kDebugCaches = 2,
62    kDebugMoreCaches = kDebugMemory | kDebugCaches
63};
64
65/**
66 * Used to enable/disable layers update debugging. The accepted values are
67 * "true" and "false". The default value is "false".
68 */
69#define PROPERTY_DEBUG_LAYERS_UPDATES "debug.hwui.show_layers_updates"
70
71/**
72 * Used to enable/disable overdraw debugging.
73 *
74 * The accepted values are
75 * "show", to show overdraw
76 * "show_deuteranomaly", to show overdraw if you suffer from Deuteranomaly
77 * "count", to show an overdraw counter
78 * "false", to disable overdraw debugging
79 *
80 * The default value is "false".
81 */
82#define PROPERTY_DEBUG_OVERDRAW "debug.hwui.overdraw"
83
84/**
85 *  System property used to enable or disable hardware rendering profiling.
86 * The default value of this property is assumed to be false.
87 *
88 * When profiling is enabled, the adb shell dumpsys gfxinfo command will
89 * output extra information about the time taken to execute by the last
90 * frames.
91 *
92 * Possible values:
93 * "true", to enable profiling
94 * "visual_bars", to enable profiling and visualize the results on screen
95 * "false", to disable profiling
96 */
97#define PROPERTY_PROFILE "debug.hwui.profile"
98#define PROPERTY_PROFILE_VISUALIZE_BARS "visual_bars"
99
100/**
101 * Used to enable/disable non-rectangular clipping debugging.
102 *
103 * The accepted values are:
104 * "highlight", drawing commands clipped by the stencil will
105 *              be colored differently
106 * "region", renders the clipping region on screen whenever
107 *           the stencil is set
108 * "hide", don't show the clip
109 *
110 * The default value is "hide".
111 */
112#define PROPERTY_DEBUG_STENCIL_CLIP "debug.hwui.show_non_rect_clip"
113
114/**
115 * Turn on to draw dirty regions every other frame.
116 *
117 * Possible values:
118 * "true", to enable dirty regions debugging
119 * "false", to disable dirty regions debugging
120 */
121#define PROPERTY_DEBUG_SHOW_DIRTY_REGIONS "debug.hwui.show_dirty_regions"
122
123/**
124 * Disables draw operation deferral if set to "true", forcing draw
125 * commands to be issued to OpenGL in order, and processed in sequence
126 * with state-manipulation canvas commands.
127 */
128#define PROPERTY_DISABLE_DRAW_DEFER "debug.hwui.disable_draw_defer"
129
130/**
131 * Used to disable draw operation reordering when deferring draw operations
132 * Has no effect if PROPERTY_DISABLE_DRAW_DEFER is set to "true"
133 */
134#define PROPERTY_DISABLE_DRAW_REORDER "debug.hwui.disable_draw_reorder"
135
136/**
137 * Setting this property will enable or disable the dropping of frames with
138 * empty damage. Default is "true".
139 */
140#define PROPERTY_SKIP_EMPTY_DAMAGE "debug.hwui.skip_empty_damage"
141
142/**
143 * Controls whether or not HWUI will use the EGL_EXT_buffer_age extension
144 * to do partial invalidates. Setting this to "false" will fall back to
145 * using BUFFER_PRESERVED instead
146 * Default is "true"
147 */
148#define PROPERTY_USE_BUFFER_AGE "debug.hwui.use_buffer_age"
149
150/**
151 * Setting this to "false" will force HWUI to always do full-redraws of the surface.
152 * This will disable the use of EGL_EXT_buffer_age and BUFFER_PRESERVED.
153 * Default is "true"
154 */
155#define PROPERTY_ENABLE_PARTIAL_UPDATES "debug.hwui.enable_partial_updates"
156
157///////////////////////////////////////////////////////////////////////////////
158// Runtime configuration properties
159///////////////////////////////////////////////////////////////////////////////
160
161/**
162 * Used to enable/disable scissor optimization. The accepted values are
163 * "true" and "false". The default value is "false".
164 *
165 * When scissor optimization is enabled, OpenGLRenderer will attempt to
166 * minimize the use of scissor by selectively enabling and disabling the
167 * GL scissor test.
168 * When the optimization is disabled, OpenGLRenderer will keep the GL
169 * scissor test enabled and change the scissor rect as needed.
170 * Some GPUs (for instance the SGX 540) perform better when changing
171 * the scissor rect often than when enabling/disabling the scissor test
172 * often.
173 */
174#define PROPERTY_DISABLE_SCISSOR_OPTIMIZATION "ro.hwui.disable_scissor_opt"
175
176/**
177 * Indicates whether PBOs can be used to back pixel buffers.
178 * Accepted values are "true" and "false". Default is true.
179 */
180#define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "ro.hwui.use_gpu_pixel_buffers"
181
182// These properties are defined in mega-bytes
183#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size"
184#define PROPERTY_LAYER_CACHE_SIZE "ro.hwui.layer_cache_size"
185#define PROPERTY_RENDER_BUFFER_CACHE_SIZE "ro.hwui.r_buffer_cache_size"
186#define PROPERTY_GRADIENT_CACHE_SIZE "ro.hwui.gradient_cache_size"
187#define PROPERTY_PATH_CACHE_SIZE "ro.hwui.path_cache_size"
188#define PROPERTY_VERTEX_CACHE_SIZE "ro.hwui.vertex_cache_size"
189#define PROPERTY_PATCH_CACHE_SIZE "ro.hwui.patch_cache_size"
190#define PROPERTY_DROP_SHADOW_CACHE_SIZE "ro.hwui.drop_shadow_cache_size"
191#define PROPERTY_FBO_CACHE_SIZE "ro.hwui.fbo_cache_size"
192
193// These properties are defined in percentage (range 0..1)
194#define PROPERTY_TEXTURE_CACHE_FLUSH_RATE "ro.hwui.texture_cache_flushrate"
195
196// These properties are defined in pixels
197#define PROPERTY_TEXT_SMALL_CACHE_WIDTH "ro.hwui.text_small_cache_width"
198#define PROPERTY_TEXT_SMALL_CACHE_HEIGHT "ro.hwui.text_small_cache_height"
199#define PROPERTY_TEXT_LARGE_CACHE_WIDTH "ro.hwui.text_large_cache_width"
200#define PROPERTY_TEXT_LARGE_CACHE_HEIGHT "ro.hwui.text_large_cache_height"
201
202// Gamma (>= 1.0, <= 10.0)
203#define PROPERTY_TEXT_GAMMA "hwui.text_gamma"
204
205///////////////////////////////////////////////////////////////////////////////
206// Default property values
207///////////////////////////////////////////////////////////////////////////////
208
209#define DEFAULT_TEXTURE_CACHE_SIZE 24.0f
210#define DEFAULT_LAYER_CACHE_SIZE 16.0f
211#define DEFAULT_RENDER_BUFFER_CACHE_SIZE 2.0f
212#define DEFAULT_PATH_CACHE_SIZE 4.0f
213#define DEFAULT_VERTEX_CACHE_SIZE 1.0f
214#define DEFAULT_PATCH_CACHE_SIZE 128.0f // in kB
215#define DEFAULT_GRADIENT_CACHE_SIZE 0.5f
216#define DEFAULT_DROP_SHADOW_CACHE_SIZE 2.0f
217#define DEFAULT_FBO_CACHE_SIZE 0
218
219#define DEFAULT_TEXTURE_CACHE_FLUSH_RATE 0.6f
220
221#define DEFAULT_TEXT_GAMMA 1.4f
222
223///////////////////////////////////////////////////////////////////////////////
224// Misc
225///////////////////////////////////////////////////////////////////////////////
226
227// Converts a number of mega-bytes into bytes
228#define MB(s) s * 1024 * 1024
229// Converts a number of kilo-bytes into bytes
230#define KB(s) s * 1024
231
232enum class ProfileType {
233    None,
234    Console,
235    Bars
236};
237
238enum class OverdrawColorSet {
239    Default = 0,
240    Deuteranomaly
241};
242
243enum class StencilClipDebug {
244    Hide,
245    ShowHighlight,
246    ShowRegion
247};
248
249/**
250 * Renderthread-only singleton which manages several static rendering properties. Most of these
251 * are driven by system properties which are queried once at initialization, and again if init()
252 * is called.
253 */
254class Properties {
255public:
256    static bool load();
257
258    static bool drawDeferDisabled;
259    static bool drawReorderDisabled;
260    static bool debugLayersUpdates;
261    static bool debugOverdraw;
262    static bool showDirtyRegions;
263    // TODO: Remove after stabilization period
264    static bool skipEmptyFrames;
265    static bool useBufferAge;
266    static bool enablePartialUpdates;
267
268    static float textGamma;
269
270    static DebugLevel debugLevel;
271    static OverdrawColorSet overdrawColorSet;
272    static StencilClipDebug debugStencilClip;
273
274    // Override the value for a subset of properties in this class
275    static void overrideProperty(const char* name, const char* value);
276
277    static float overrideLightRadius;
278    static float overrideLightPosY;
279    static float overrideLightPosZ;
280    static float overrideAmbientRatio;
281    static int overrideAmbientShadowStrength;
282    static int overrideSpotShadowStrength;
283
284    static ProfileType getProfileType();
285
286private:
287    static ProfileType sProfileType;
288    static bool sDisableProfileBars;
289
290}; // class Caches
291
292}; // namespace uirenderer
293}; // namespace android
294
295#endif // ANDROID_HWUI_PROPERTIES_H
296