3b748a44c6
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
95 lines
2.8 KiB
C
95 lines
2.8 KiB
C
/*
|
|
* 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_DEBUG_H
|
|
#define ANDROID_HWUI_DEBUG_H
|
|
|
|
// Turn on to check for OpenGL errors on each frame
|
|
#define DEBUG_OPENGL 1
|
|
|
|
// Turn on to display informations about the GPU
|
|
#define DEBUG_EXTENSIONS 0
|
|
|
|
// Turn on to enable initialization information
|
|
#define DEBUG_INIT 0
|
|
|
|
// Turn on to enable memory usage summary on each frame
|
|
#define DEBUG_MEMORY_USAGE 0
|
|
|
|
// Turn on to enable debugging of cache flushes
|
|
#define DEBUG_CACHE_FLUSH 0
|
|
|
|
// Turn on to enable layers debugging when rendered as regions
|
|
#define DEBUG_LAYERS_AS_REGIONS 0
|
|
|
|
// Turn on to enable debugging when the clip is not a rect
|
|
#define DEBUG_CLIP_REGIONS 0
|
|
|
|
// Turn on to display debug info about vertex/fragment shaders
|
|
#define DEBUG_PROGRAMS 0
|
|
|
|
// Turn on to display info about layers
|
|
#define DEBUG_LAYERS 0
|
|
|
|
// Turn on to display info about render buffers
|
|
#define DEBUG_RENDER_BUFFERS 0
|
|
|
|
// Turn on to make stencil operations easier to debug
|
|
// (writes 255 instead of 1 in the buffer, forces 8 bit stencil)
|
|
#define DEBUG_STENCIL 0
|
|
|
|
// Turn on to display debug info about 9patch objects
|
|
#define DEBUG_PATCHES 0
|
|
// Turn on to display vertex and tex coords data about 9patch objects
|
|
// This flag requires DEBUG_PATCHES to be turned on
|
|
#define DEBUG_PATCHES_VERTICES 0
|
|
// Turn on to display vertex and tex coords data used by empty quads
|
|
// in 9patch objects
|
|
// This flag requires DEBUG_PATCHES to be turned on
|
|
#define DEBUG_PATCHES_EMPTY_VERTICES 0
|
|
|
|
// Turn on to display debug info about shapes
|
|
#define DEBUG_PATHS 0
|
|
|
|
// Turn on to display debug info about textures
|
|
#define DEBUG_TEXTURES 0
|
|
|
|
// Turn on to display debug info about the layer renderer
|
|
#define DEBUG_LAYER_RENDERER 0
|
|
|
|
// Turn on to enable additional debugging in the font renderers
|
|
#define DEBUG_FONT_RENDERER 0
|
|
|
|
// Turn on to log draw operation batching and deferral information
|
|
#define DEBUG_DEFER 0
|
|
|
|
// Turn on to dump display list state
|
|
#define DEBUG_DISPLAY_LIST 0
|
|
|
|
// Turn on to insert an event marker for each display list op
|
|
#define DEBUG_DISPLAY_LIST_OPS_AS_EVENTS 0
|
|
|
|
// Turn on to highlight drawing batches and merged batches with different colors
|
|
#define DEBUG_MERGE_BEHAVIOR 0
|
|
|
|
#if DEBUG_INIT
|
|
#define INIT_LOGD(...) ALOGD(__VA_ARGS__)
|
|
#else
|
|
#define INIT_LOGD(...)
|
|
#endif
|
|
|
|
#endif // ANDROID_HWUI_DEBUG_H
|