2010-07-23 00:28:00 -07:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#ifndef ANDROID_HWUI_PROPERTIES_H
|
|
|
|
#define ANDROID_HWUI_PROPERTIES_H
|
2010-07-23 00:28:00 -07:00
|
|
|
|
2010-08-23 21:05:08 -07:00
|
|
|
#include <cutils/properties.h>
|
2010-11-10 19:01:29 -08:00
|
|
|
#include <stdlib.h>
|
2010-08-23 21:05:08 -07:00
|
|
|
|
2010-07-23 00:28:00 -07:00
|
|
|
/**
|
|
|
|
* This file contains the list of system properties used to configure
|
|
|
|
* the OpenGLRenderer.
|
|
|
|
*/
|
|
|
|
|
2013-04-08 19:40:31 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Compile-time properties
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-06-01 14:52:00 -07:00
|
|
|
// If turned on, text is interpreted as glyphs instead of UTF-16
|
|
|
|
#define RENDER_TEXT_AS_GLYPHS 1
|
|
|
|
|
2011-08-22 14:01:34 -07:00
|
|
|
// Indicates whether to remove the biggest layers first, or the smaller ones
|
|
|
|
#define LAYER_REMOVE_BIGGEST_FIRST 0
|
|
|
|
|
|
|
|
// Textures used by layers must have dimensions multiples of this number
|
|
|
|
#define LAYER_SIZE 64
|
|
|
|
|
2013-02-12 16:08:55 -08:00
|
|
|
// Defines the size in bits of the stencil buffer for the framebuffer
|
2012-02-02 17:31:16 -08:00
|
|
|
// Note: Only 1 bit is required for clipping but more bits are required
|
2013-02-12 16:08:55 -08:00
|
|
|
// to properly implement overdraw debugging
|
2012-09-21 19:15:00 -07:00
|
|
|
#define STENCIL_BUFFER_SIZE 8
|
2012-01-25 18:56:29 -08:00
|
|
|
|
2013-04-08 19:40:31 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Debug properties
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-11-10 19:01:29 -08:00
|
|
|
/**
|
2012-08-06 14:51:10 -07:00
|
|
|
* Debug level for app developers. The value is a numeric value defined
|
|
|
|
* by the DebugLevel enum below.
|
2010-11-10 19:01:29 -08:00
|
|
|
*/
|
2012-08-06 14:51:10 -07:00
|
|
|
#define PROPERTY_DEBUG "debug.hwui.level"
|
2010-11-10 19:01:29 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Debug levels. Debug levels are used as flags.
|
|
|
|
*/
|
|
|
|
enum DebugLevel {
|
|
|
|
kDebugDisabled = 0,
|
|
|
|
kDebugMemory = 1,
|
2010-12-10 12:33:05 -08:00
|
|
|
kDebugCaches = 2,
|
2011-07-13 09:49:43 -07:00
|
|
|
kDebugMoreCaches = kDebugMemory | kDebugCaches
|
2010-11-10 19:01:29 -08:00
|
|
|
};
|
|
|
|
|
2012-08-06 14:51:10 -07:00
|
|
|
/**
|
2012-09-21 19:15:00 -07:00
|
|
|
* Used to enable/disable layers update debugging. The accepted values are
|
2012-08-06 14:51:10 -07:00
|
|
|
* "true" and "false". The default value is "false".
|
|
|
|
*/
|
|
|
|
#define PROPERTY_DEBUG_LAYERS_UPDATES "debug.hwui.show_layers_updates"
|
|
|
|
|
2012-09-21 19:15:00 -07:00
|
|
|
/**
|
|
|
|
* Used to enable/disable overdraw debugging. The accepted values are
|
2013-05-03 14:24:16 -07:00
|
|
|
* "show", "count" and "false". The default value is "false".
|
2012-09-21 19:15:00 -07:00
|
|
|
*/
|
2013-05-03 14:24:16 -07:00
|
|
|
#define PROPERTY_DEBUG_OVERDRAW "debug.hwui.overdraw"
|
2012-09-21 19:15:00 -07:00
|
|
|
|
2013-02-25 14:15:37 -08:00
|
|
|
/**
|
|
|
|
* 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".
|
|
|
|
*/
|
2013-02-25 16:21:30 -08:00
|
|
|
#define PROPERTY_DEBUG_STENCIL_CLIP "debug.hwui.show_non_rect_clip"
|
2013-02-25 14:15:37 -08:00
|
|
|
|
2013-04-08 19:40:31 -07:00
|
|
|
/**
|
|
|
|
* 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"
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Runtime configuration properties
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-09-24 11:37:12 -07:00
|
|
|
/**
|
|
|
|
* Used to enable/disable scissor optimization. The accepted values are
|
|
|
|
* "true" and "false". The default value is "false".
|
|
|
|
*
|
|
|
|
* When scissor optimization is enabled, OpenGLRenderer will attempt to
|
|
|
|
* minimize the use of scissor by selectively enabling and disabling the
|
|
|
|
* GL scissor test.
|
|
|
|
* When the optimization is disabled, OpenGLRenderer will keep the GL
|
|
|
|
* scissor test enabled and change the scissor rect as needed.
|
|
|
|
* Some GPUs (for instance the SGX 540) perform better when changing
|
|
|
|
* the scissor rect often than when enabling/disabling the scissor test
|
|
|
|
* often.
|
|
|
|
*/
|
|
|
|
#define PROPERTY_DISABLE_SCISSOR_OPTIMIZATION "ro.hwui.disable_scissor_opt"
|
|
|
|
|
2013-02-04 16:16:33 -08:00
|
|
|
/**
|
2013-04-08 19:40:31 -07:00
|
|
|
* Indicates whether PBOs can be used to back pixel buffers.
|
2013-05-09 11:50:12 -07:00
|
|
|
* Accepted values are "true" and "false". Default is true.
|
2013-02-04 16:16:33 -08:00
|
|
|
*/
|
2013-05-09 11:50:12 -07:00
|
|
|
#define PROPERTY_ENABLE_GPU_PIXEL_BUFFERS "ro.hwui.use_gpu_pixel_buffers"
|
2013-02-04 16:16:33 -08:00
|
|
|
|
2010-07-23 00:28:00 -07:00
|
|
|
// These properties are defined in mega-bytes
|
|
|
|
#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size"
|
|
|
|
#define PROPERTY_LAYER_CACHE_SIZE "ro.hwui.layer_cache_size"
|
2013-02-12 16:08:55 -08:00
|
|
|
#define PROPERTY_RENDER_BUFFER_CACHE_SIZE "ro.hwui.r_buffer_cache_size"
|
2010-07-23 00:28:00 -07:00
|
|
|
#define PROPERTY_GRADIENT_CACHE_SIZE "ro.hwui.gradient_cache_size"
|
2010-08-04 15:40:07 -07:00
|
|
|
#define PROPERTY_PATH_CACHE_SIZE "ro.hwui.path_cache_size"
|
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
|
|
|
#define PROPERTY_PATCH_CACHE_SIZE "ro.hwui.patch_cache_size"
|
2010-08-13 19:39:53 -07:00
|
|
|
#define PROPERTY_DROP_SHADOW_CACHE_SIZE "ro.hwui.drop_shadow_cache_size"
|
2010-09-24 18:39:22 -07:00
|
|
|
#define PROPERTY_FBO_CACHE_SIZE "ro.hwui.fbo_cache_size"
|
2010-07-23 00:28:00 -07:00
|
|
|
|
2011-11-04 15:12:29 -07:00
|
|
|
// These properties are defined in percentage (range 0..1)
|
2013-03-19 11:32:41 -07:00
|
|
|
#define PROPERTY_TEXTURE_CACHE_FLUSH_RATE "ro.hwui.texture_cache_flushrate"
|
2011-11-04 15:12:29 -07:00
|
|
|
|
2010-07-23 00:28:00 -07:00
|
|
|
// These properties are defined in pixels
|
2012-08-31 13:54:03 -07:00
|
|
|
#define PROPERTY_TEXT_SMALL_CACHE_WIDTH "ro.hwui.text_small_cache_width"
|
|
|
|
#define PROPERTY_TEXT_SMALL_CACHE_HEIGHT "ro.hwui.text_small_cache_height"
|
|
|
|
#define PROPERTY_TEXT_LARGE_CACHE_WIDTH "ro.hwui.text_large_cache_width"
|
|
|
|
#define PROPERTY_TEXT_LARGE_CACHE_HEIGHT "ro.hwui.text_large_cache_height"
|
2010-07-23 00:28:00 -07:00
|
|
|
|
2012-07-13 18:25:35 -07:00
|
|
|
// Indicates whether gamma correction should be applied in the shaders
|
2012-07-18 15:50:29 -07:00
|
|
|
// or in lookup tables. Accepted values:
|
|
|
|
//
|
|
|
|
// - "lookup3", correction based on lookup tables. Gamma correction
|
|
|
|
// is different for black and white text (see thresholds below)
|
|
|
|
//
|
|
|
|
// - "lookup", correction based on a single lookup table
|
|
|
|
//
|
|
|
|
// - "shader3", correction applied by a GLSL shader. Gamma correction
|
|
|
|
// is different for black and white text (see thresholds below)
|
|
|
|
//
|
|
|
|
// - "shader", correction applied by a GLSL shader
|
|
|
|
//
|
|
|
|
// See PROPERTY_TEXT_GAMMA, PROPERTY_TEXT_BLACK_GAMMA_THRESHOLD and
|
|
|
|
// PROPERTY_TEXT_WHITE_GAMMA_THRESHOLD for more control.
|
2012-07-18 17:06:37 -07:00
|
|
|
#define PROPERTY_TEXT_GAMMA_METHOD "hwui.text_gamma_correction"
|
|
|
|
#define DEFAULT_TEXT_GAMMA_METHOD "lookup"
|
2012-07-13 18:25:35 -07:00
|
|
|
|
2010-08-26 20:35:23 -07:00
|
|
|
// Gamma (>= 1.0, <= 10.0)
|
2012-07-18 15:50:29 -07:00
|
|
|
#define PROPERTY_TEXT_GAMMA "hwui.text_gamma"
|
|
|
|
// Luminance threshold below which black gamma correction is applied. Range: [0..255]
|
|
|
|
#define PROPERTY_TEXT_BLACK_GAMMA_THRESHOLD "hwui.text_gamma.black_threshold"
|
|
|
|
// Lumincance threshold above which white gamma correction is applied. Range: [0..255]
|
|
|
|
#define PROPERTY_TEXT_WHITE_GAMMA_THRESHOLD "hwui.text_gamma.white_threshold"
|
2010-08-26 20:35:23 -07:00
|
|
|
|
2013-04-08 19:40:31 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Default property values
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2010-08-23 21:05:08 -07:00
|
|
|
|
2011-02-02 20:28:09 -08:00
|
|
|
#define DEFAULT_TEXTURE_CACHE_SIZE 24.0f
|
2011-07-27 18:51:50 -07:00
|
|
|
#define DEFAULT_LAYER_CACHE_SIZE 16.0f
|
2013-02-12 16:08:55 -08:00
|
|
|
#define DEFAULT_RENDER_BUFFER_CACHE_SIZE 2.0f
|
2013-03-15 19:06:39 -07:00
|
|
|
#define DEFAULT_PATH_CACHE_SIZE 10.0f
|
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
|
|
|
#define DEFAULT_PATCH_CACHE_SIZE 128 // in kB
|
2010-08-23 21:05:08 -07:00
|
|
|
#define DEFAULT_GRADIENT_CACHE_SIZE 0.5f
|
|
|
|
#define DEFAULT_DROP_SHADOW_CACHE_SIZE 2.0f
|
2011-02-02 20:28:09 -08:00
|
|
|
#define DEFAULT_FBO_CACHE_SIZE 16
|
2010-08-23 21:05:08 -07:00
|
|
|
|
2011-11-04 15:12:29 -07:00
|
|
|
#define DEFAULT_TEXTURE_CACHE_FLUSH_RATE 0.6f
|
|
|
|
|
2010-08-26 20:35:23 -07:00
|
|
|
#define DEFAULT_TEXT_GAMMA 1.4f
|
|
|
|
#define DEFAULT_TEXT_BLACK_GAMMA_THRESHOLD 64
|
|
|
|
#define DEFAULT_TEXT_WHITE_GAMMA_THRESHOLD 192
|
|
|
|
|
2013-04-08 19:40:31 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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
|
2013-04-08 19:40:31 -07:00
|
|
|
|
2010-11-10 19:01:29 -08:00
|
|
|
static DebugLevel readDebugLevel() {
|
|
|
|
char property[PROPERTY_VALUE_MAX];
|
|
|
|
if (property_get(PROPERTY_DEBUG, property, NULL) > 0) {
|
|
|
|
return (DebugLevel) atoi(property);
|
|
|
|
}
|
|
|
|
return kDebugDisabled;
|
|
|
|
}
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#endif // ANDROID_HWUI_PROPERTIES_H
|