269 lines
8.0 KiB
C
Raw Normal View History

/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_HWUI_PROPERTIES_H
#define ANDROID_HWUI_PROPERTIES_H
#include <cutils/properties.h>
/**
* This file contains the list of system properties used to configure libhwui.
*/
namespace android {
namespace uirenderer {
///////////////////////////////////////////////////////////////////////////////
// Compile-time properties
///////////////////////////////////////////////////////////////////////////////
// Textures used by layers must have dimensions multiples of this number
#define LAYER_SIZE 64
// Defines the size in bits of the stencil buffer for the framebuffer
// Note: Only 1 bit is required for clipping but more bits are required
// to properly implement overdraw debugging
#define STENCIL_BUFFER_SIZE 8
///////////////////////////////////////////////////////////////////////////////
// Debug properties
///////////////////////////////////////////////////////////////////////////////
/**
* Debug level for app developers. The value is a numeric value defined
* by the DebugLevel enum below.
*/
#define PROPERTY_DEBUG "debug.hwui.level"
/**
* Debug levels. Debug levels are used as flags.
*/
enum DebugLevel {
kDebugDisabled = 0,
kDebugMemory = 1,
kDebugCaches = 2,
kDebugMoreCaches = kDebugMemory | kDebugCaches
};
/**
* Used to enable/disable layers update debugging. The accepted values are
* "true" and "false". The default value is "false".
*/
#define PROPERTY_DEBUG_LAYERS_UPDATES "debug.hwui.show_layers_updates"
/**
* Used to enable/disable overdraw debugging.
*
* The accepted values are
* "show", to show overdraw
* "show_deuteranomaly", to show overdraw if you suffer from Deuteranomaly
* "count", to show an overdraw counter
* "false", to disable overdraw debugging
*
* The default value is "false".
*/
#define PROPERTY_DEBUG_OVERDRAW "debug.hwui.overdraw"
/**
* System property used to enable or disable hardware rendering profiling.
* The default value of this property is assumed to be false.
*
* When profiling is enabled, the adb shell dumpsys gfxinfo command will
* output extra information about the time taken to execute by the last
* frames.
*
* Possible values:
* "true", to enable profiling
* "visual_bars", to enable profiling and visualize the results on screen
* "false", to disable profiling
*/
#define PROPERTY_PROFILE "debug.hwui.profile"
#define PROPERTY_PROFILE_VISUALIZE_BARS "visual_bars"
/**
* Used to enable/disable non-rectangular clipping debugging.
*
* The accepted values are:
* "highlight", drawing commands clipped by the stencil will
* be colored differently
* "region", renders the clipping region on screen whenever
* the stencil is set
* "hide", don't show the clip
*
* The default value is "hide".
*/
#define PROPERTY_DEBUG_STENCIL_CLIP "debug.hwui.show_non_rect_clip"
/**
* Turn on to draw dirty regions every other frame.
*
* Possible values:
* "true", to enable dirty regions debugging
* "false", to disable dirty regions debugging
*/
#define PROPERTY_DEBUG_SHOW_DIRTY_REGIONS "debug.hwui.show_dirty_regions"
/**
* Disables draw operation deferral if set to "true", forcing draw
* commands to be issued to OpenGL in order, and processed in sequence
* with state-manipulation canvas commands.
*/
#define PROPERTY_DISABLE_DRAW_DEFER "debug.hwui.disable_draw_defer"
/**
* Used to disable draw operation reordering when deferring draw operations
* Has no effect if PROPERTY_DISABLE_DRAW_DEFER is set to "true"
*/
#define PROPERTY_DISABLE_DRAW_REORDER "debug.hwui.disable_draw_reorder"
/**
* Setting this property will enable or disable the dropping of frames with
* empty damage. Default is "true".
*/
#define PROPERTY_SKIP_EMPTY_DAMAGE "debug.hwui.skip_empty_damage"
/**
* Controls whether or not HWUI will use the EGL_EXT_buffer_age extension
* to do partial invalidates. Setting this to "false" will fall back to
* using BUFFER_PRESERVED instead
* Default is "true"
*/
#define PROPERTY_USE_BUFFER_AGE "debug.hwui.use_buffer_age"
/**
* Setting this to "false" will force HWUI to always do full-redraws of the surface.
* This will disable the use of EGL_EXT_buffer_age and BUFFER_PRESERVED.
* Default is "true"
*/
#define PROPERTY_ENABLE_PARTIAL_UPDATES "debug.hwui.use_partial_updates"
#define PROPERTY_FILTER_TEST_OVERHEAD "debug.hwui.filter_test_overhead"
/**
* Indicates whether PBOs can be used to back pixel buffers.
* Accepted values are "true" and "false". Default is true.
*/
#define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "debug.hwui.use_gpu_pixel_buffers"
/**
* Allows to set rendering pipeline mode to OpenGL (default), Skia OpenGL
* or Vulkan.
*/
#define PROPERTY_RENDERER "debug.hwui.renderer"
///////////////////////////////////////////////////////////////////////////////
// Misc
///////////////////////////////////////////////////////////////////////////////
// Converts a number of mega-bytes into bytes
#define MB(s) ((s) * 1024 * 1024)
Pack preloaded framework assets in a texture atlas When the Android runtime starts, the system preloads a series of assets in the Zygote process. These assets are shared across all processes. Unfortunately, each one of these assets is later uploaded in its own OpenGL texture, once per process. This wastes memory and generates unnecessary OpenGL state changes. This CL introduces an asset server that provides an atlas to all processes. Note: bitmaps used by skia shaders are *not* sampled from the atlas. It's an uncommon use case and would require extra texture transforms in the GL shaders. WHAT IS THE ASSETS ATLAS The "assets atlas" is a single, shareable graphic buffer that contains all the system's preloaded bitmap drawables (this includes 9-patches.) The atlas is made of two distinct objects: the graphic buffer that contains the actual pixels and the map which indicates where each preloaded bitmap can be found in the atlas (essentially a pair of x and y coordinates.) HOW IS THE ASSETS ATLAS GENERATED Because we need to support a wide variety of devices and because it is easy to change the list of preloaded drawables, the atlas is generated at runtime, during the startup phase of the system process. There are several steps that lead to the atlas generation: 1. If the device is booting for the first time, or if the device was updated, we need to find the best atlas configuration. To do so, the atlas service tries a number of width, height and algorithm variations that allows us to pack as many assets as possible while using as little memory as possible. Once a best configuration is found, it gets written to disk in /data/system/framework_atlas 2. Given a best configuration (algorithm variant, dimensions and number of bitmaps that can be packed in the atlas), the atlas service packs all the preloaded bitmaps into a single graphic buffer object. 3. The packing is done using Skia in a temporary native bitmap. The Skia bitmap is then copied into the graphic buffer using OpenGL ES to benefit from texture swizzling. HOW PROCESSES USE THE ATLAS Whenever a process' hardware renderer initializes its EGL context, it queries the atlas service for the graphic buffer and the map. It is important to remember that both the context and the map will be valid for the lifetime of the hardware renderer (if the system process goes down, all apps get killed as well.) Every time the hardware renderer needs to render a bitmap, it first checks whether the bitmap can be found in the assets atlas. When the bitmap is part of the atlas, texture coordinates are remapped appropriately before rendering. Change-Id: I8eaecf53e7f6a33d90da3d0047c5ceec89ea3af0
2013-04-17 18:54:38 -07:00
// Converts a number of kilo-bytes into bytes
#define KB(s) ((s) * 1024)
enum class ProfileType {
None,
Console,
Bars
};
enum class OverdrawColorSet {
Default = 0,
Deuteranomaly
};
enum class StencilClipDebug {
Hide,
ShowHighlight,
ShowRegion
};
enum class RenderPipelineType {
OpenGL = 0,
SkiaGL,
SkiaVulkan,
NotInitialized = 128
};
/**
* Renderthread-only singleton which manages several static rendering properties. Most of these
* are driven by system properties which are queried once at initialization, and again if init()
* is called.
*/
class Properties {
public:
static bool load();
static bool drawDeferDisabled;
static bool drawReorderDisabled;
static bool debugLayersUpdates;
static bool debugOverdraw;
static bool showDirtyRegions;
// TODO: Remove after stabilization period
static bool skipEmptyFrames;
static bool useBufferAge;
static bool enablePartialUpdates;
// TODO: Move somewhere else?
static constexpr float textGamma = 1.45f;
static DebugLevel debugLevel;
static OverdrawColorSet overdrawColorSet;
static StencilClipDebug debugStencilClip;
// Override the value for a subset of properties in this class
static void overrideProperty(const char* name, const char* value);
static float overrideLightRadius;
static float overrideLightPosY;
static float overrideLightPosZ;
static float overrideAmbientRatio;
static int overrideAmbientShadowStrength;
static int overrideSpotShadowStrength;
static ProfileType getProfileType();
static RenderPipelineType getRenderPipelineType();
static bool isSkiaEnabled();
// Should be used only by test apps
static bool waitForGpuCompletion;
static bool forceDrawFrame;
// Should only be set by automated tests to try and filter out
// any overhead they add
static bool filterOutTestOverhead;
// Workaround a device lockup in edge cases by switching to async mode
// instead of the default vsync (b/38372997). Only system_server should hit this.
// Any existing RenderProxy & Surface combination will be unaffected, only things
// created after changing this.
static bool disableVsync;
// Used for testing only to change the render pipeline.
#ifdef HWUI_GLES_WRAP_ENABLED
static void overrideRenderPipelineType(RenderPipelineType);
#endif
private:
static ProfileType sProfileType;
static bool sDisableProfileBars;
static RenderPipelineType sRenderPipelineType;
}; // class Caches
}; // namespace uirenderer
}; // namespace android
#endif // ANDROID_HWUI_PROPERTIES_H