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  * Property for whether this is running in the emulator.
162  */
163 #define PROPERTY_QEMU_KERNEL "ro.kernel.qemu"
164 
165 #define PROPERTY_RENDERAHEAD "debug.hwui.render_ahead"
166 
167 ///////////////////////////////////////////////////////////////////////////////
168 // Misc
169 ///////////////////////////////////////////////////////////////////////////////
170 
171 // Converts a number of mega-bytes into bytes
172 #define MB(s) ((s)*1024 * 1024)
173 // Converts a number of kilo-bytes into bytes
174 #define KB(s) ((s)*1024)
175 
176 enum class ProfileType { None, Console, Bars };
177 
178 enum class OverdrawColorSet { Default = 0, Deuteranomaly };
179 
180 enum class RenderPipelineType { SkiaGL, SkiaVulkan, NotInitialized = 128 };
181 
182 /**
183  * Renderthread-only singleton which manages several static rendering properties. Most of these
184  * are driven by system properties which are queried once at initialization, and again if init()
185  * is called.
186  */
187 class Properties {
188 public:
189     static bool load();
190 
191     static bool debugLayersUpdates;
192     static bool debugOverdraw;
193     static bool showDirtyRegions;
194     // TODO: Remove after stabilization period
195     static bool skipEmptyFrames;
196     static bool useBufferAge;
197     static bool enablePartialUpdates;
198 
199     // TODO: Move somewhere else?
200     static constexpr float textGamma = 1.45f;
201 
202     static DebugLevel debugLevel;
203     static OverdrawColorSet overdrawColorSet;
204 
205     // Override the value for a subset of properties in this class
206     static void overrideProperty(const char* name, const char* value);
207 
208     static float overrideLightRadius;
209     static float overrideLightPosY;
210     static float overrideLightPosZ;
211     static float overrideAmbientRatio;
212     static int overrideAmbientShadowStrength;
213     static int overrideSpotShadowStrength;
214 
215     static ProfileType getProfileType();
216     ANDROID_API static RenderPipelineType peekRenderPipelineType();
217     ANDROID_API static RenderPipelineType getRenderPipelineType();
218 
219     ANDROID_API static bool enableHighContrastText;
220 
221     // Should be used only by test apps
222     static bool waitForGpuCompletion;
223     static bool forceDrawFrame;
224 
225     // Should only be set by automated tests to try and filter out
226     // any overhead they add
227     static bool filterOutTestOverhead;
228 
229     // Workaround a device lockup in edge cases by switching to async mode
230     // instead of the default vsync (b/38372997). Only system_server should hit this.
231     // Any existing RenderProxy & Surface combination will be unaffected, only things
232     // created after changing this.
233     static bool disableVsync;
234 
235     static bool skpCaptureEnabled;
236 
237     // For experimentation b/68769804
238     ANDROID_API static bool enableRTAnimations;
239 
240     // Used for testing only to change the render pipeline.
241     static void overrideRenderPipelineType(RenderPipelineType);
242 
243     static bool runningInEmulator;
244 
245     ANDROID_API static bool debuggingEnabled;
246     ANDROID_API static bool isolatedProcess;
247 
248     ANDROID_API static int contextPriority;
249 
250     static int defaultRenderAhead;
251 
252 private:
253     static ProfileType sProfileType;
254     static bool sDisableProfileBars;
255     static RenderPipelineType sRenderPipelineType;
256 };  // class Caches
257 
258 }  // namespace uirenderer
259 }  // namespace android
260 
261 #endif  // ANDROID_HWUI_PROPERTIES_H
262