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