Properties.h revision 4ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1
151769a68a5cb34e9564740c6a854fcb93018789dRomain Guy/*
251769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * Copyright (C) 2010 The Android Open Source Project
351769a68a5cb34e9564740c6a854fcb93018789dRomain Guy *
451769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * Licensed under the Apache License, Version 2.0 (the "License");
551769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * you may not use this file except in compliance with the License.
651769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * You may obtain a copy of the License at
751769a68a5cb34e9564740c6a854fcb93018789dRomain Guy *
851769a68a5cb34e9564740c6a854fcb93018789dRomain Guy *      http://www.apache.org/licenses/LICENSE-2.0
951769a68a5cb34e9564740c6a854fcb93018789dRomain Guy *
1051769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * Unless required by applicable law or agreed to in writing, software
1151769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * distributed under the License is distributed on an "AS IS" BASIS,
1251769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1351769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * See the License for the specific language governing permissions and
1451769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * limitations under the License.
1551769a68a5cb34e9564740c6a854fcb93018789dRomain Guy */
1651769a68a5cb34e9564740c6a854fcb93018789dRomain Guy
175b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#ifndef ANDROID_HWUI_PROPERTIES_H
185b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#define ANDROID_HWUI_PROPERTIES_H
1951769a68a5cb34e9564740c6a854fcb93018789dRomain Guy
20fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy#include <cutils/properties.h>
21e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy#include <stdlib.h>
22fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy
2351769a68a5cb34e9564740c6a854fcb93018789dRomain Guy/**
2451769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * This file contains the list of system properties used to configure
2551769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * the OpenGLRenderer.
2651769a68a5cb34e9564740c6a854fcb93018789dRomain Guy */
2751769a68a5cb34e9564740c6a854fcb93018789dRomain Guy
28726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy// If turned on, text is interpreted as glyphs instead of UTF-16
29726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy#define RENDER_TEXT_AS_GLYPHS 1
30726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy
3128d8ff6dbcc1b137131c70b72b4dbd211db7fbd9Romain Guy// Indicates whether to remove the biggest layers first, or the smaller ones
3228d8ff6dbcc1b137131c70b72b4dbd211db7fbd9Romain Guy#define LAYER_REMOVE_BIGGEST_FIRST 0
3328d8ff6dbcc1b137131c70b72b4dbd211db7fbd9Romain Guy
3428d8ff6dbcc1b137131c70b72b4dbd211db7fbd9Romain Guy// Textures used by layers must have dimensions multiples of this number
3528d8ff6dbcc1b137131c70b72b4dbd211db7fbd9Romain Guy#define LAYER_SIZE 64
3628d8ff6dbcc1b137131c70b72b4dbd211db7fbd9Romain Guy
37530041d3191ce817832a0108514617768e43cda6Romain Guy// Defines the size in bits of the stencil buffer
38ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy// Note: Only 1 bit is required for clipping but more bits are required
39ada4d53d50dc869b8278573ad640dc44118d3bcfRomain Guy// to properly implement the winding fill rule when rasterizing paths
40530041d3191ce817832a0108514617768e43cda6Romain Guy#define STENCIL_BUFFER_SIZE 0
41530041d3191ce817832a0108514617768e43cda6Romain Guy
42e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy/**
434ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1Romain Guy * Debug level for app developers. The value is a numeric value defined
444ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1Romain Guy * by the DebugLevel enum below.
45e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy */
464ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1Romain Guy#define PROPERTY_DEBUG "debug.hwui.level"
47e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy
48e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy/**
49e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy * Debug levels. Debug levels are used as flags.
50e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy */
51e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guyenum DebugLevel {
52e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy    kDebugDisabled = 0,
53e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy    kDebugMemory = 1,
5425dc3a7dbac2f90f5144035e9c8ed99c09cc3132Romain Guy    kDebugCaches = 2,
55042f7d64b5ccd7b5b73e7e9814a84576f04fb7d4Kenny Root    kDebugMoreCaches = kDebugMemory | kDebugCaches
56e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy};
57e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy
584ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1Romain Guy/**
594ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1Romain Guy * Used to enable/disbale layers update debugging. The accepted values are
604ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1Romain Guy * "true" and "false". The default value is "false".
614ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1Romain Guy */
624ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1Romain Guy#define PROPERTY_DEBUG_LAYERS_UPDATES "debug.hwui.show_layers_updates"
634ff0cf4b83605bff630c4e6f1fabe4f72a3f93a1Romain Guy
6451769a68a5cb34e9564740c6a854fcb93018789dRomain Guy// These properties are defined in mega-bytes
6551769a68a5cb34e9564740c6a854fcb93018789dRomain Guy#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size"
6651769a68a5cb34e9564740c6a854fcb93018789dRomain Guy#define PROPERTY_LAYER_CACHE_SIZE "ro.hwui.layer_cache_size"
6751769a68a5cb34e9564740c6a854fcb93018789dRomain Guy#define PROPERTY_GRADIENT_CACHE_SIZE "ro.hwui.gradient_cache_size"
687fbcc0492fca03857e3c45064f4aa040af817d55Romain Guy#define PROPERTY_PATH_CACHE_SIZE "ro.hwui.path_cache_size"
6901d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy#define PROPERTY_SHAPE_CACHE_SIZE "ro.hwui.shape_cache_size"
701e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy#define PROPERTY_DROP_SHADOW_CACHE_SIZE "ro.hwui.drop_shadow_cache_size"
71e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy#define PROPERTY_FBO_CACHE_SIZE "ro.hwui.fbo_cache_size"
7251769a68a5cb34e9564740c6a854fcb93018789dRomain Guy
73eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy// These properties are defined in percentage (range 0..1)
74eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy#define PROPERTY_TEXTURE_CACHE_FLUSH_RATE "ro.hwui.texture_cache_flush_rate"
75eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy
7651769a68a5cb34e9564740c6a854fcb93018789dRomain Guy// These properties are defined in pixels
7751769a68a5cb34e9564740c6a854fcb93018789dRomain Guy#define PROPERTY_TEXT_CACHE_WIDTH "ro.hwui.text_cache_width"
7851769a68a5cb34e9564740c6a854fcb93018789dRomain Guy#define PROPERTY_TEXT_CACHE_HEIGHT "ro.hwui.text_cache_height"
7951769a68a5cb34e9564740c6a854fcb93018789dRomain Guy
80b1d0a4ed21168fefcb82232c8f22cb95d60acb85Romain Guy// Indicates whether gamma correction should be applied in the shaders
816e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy// or in lookup tables. Accepted values:
826e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//
836e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//     - "lookup3", correction based on lookup tables. Gamma correction
846e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//        is different for black and white text (see thresholds below)
856e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//
866e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//     - "lookup", correction based on a single lookup table
876e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//
886e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//     - "shader3", correction applied by a GLSL shader. Gamma correction
896e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//        is different for black and white text (see thresholds below)
906e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//
916e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//     - "shader", correction applied by a GLSL shader
926e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy//
936e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy// See PROPERTY_TEXT_GAMMA, PROPERTY_TEXT_BLACK_GAMMA_THRESHOLD and
946e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy// PROPERTY_TEXT_WHITE_GAMMA_THRESHOLD for more control.
95dfab50d8b97a90dca279b119ebe439f595616ffaRomain Guy#define PROPERTY_TEXT_GAMMA_METHOD "hwui.text_gamma_correction"
96dfab50d8b97a90dca279b119ebe439f595616ffaRomain Guy#define DEFAULT_TEXT_GAMMA_METHOD "lookup"
97b1d0a4ed21168fefcb82232c8f22cb95d60acb85Romain Guy
98b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy// Gamma (>= 1.0, <= 10.0)
996e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy#define PROPERTY_TEXT_GAMMA "hwui.text_gamma"
1006e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy// Luminance threshold below which black gamma correction is applied. Range: [0..255]
1016e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy#define PROPERTY_TEXT_BLACK_GAMMA_THRESHOLD "hwui.text_gamma.black_threshold"
1026e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy// Lumincance threshold above which white gamma correction is applied. Range: [0..255]
1036e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy#define PROPERTY_TEXT_WHITE_GAMMA_THRESHOLD "hwui.text_gamma.white_threshold"
104b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy
105fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy// Converts a number of mega-bytes into bytes
10624edca8b526515979778e577191089a57f5277d7Romain Guy#define MB(s) s * 1024 * 1024
107fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy
10809b7c91de73b59aa3f679b3ae3ba299f82ec9f8aRomain Guy#define DEFAULT_TEXTURE_CACHE_SIZE 24.0f
10965b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy#define DEFAULT_LAYER_CACHE_SIZE 16.0f
1108550c4c7b5952b7a4e1e0ede95c9492d03099a13Romain Guy#define DEFAULT_PATH_CACHE_SIZE 4.0f
11101d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy#define DEFAULT_SHAPE_CACHE_SIZE 1.0f
1122728f961614a385df1f056fc24803a9f65c90fabRomain Guy#define DEFAULT_PATCH_CACHE_SIZE 512
113fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy#define DEFAULT_GRADIENT_CACHE_SIZE 0.5f
114fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy#define DEFAULT_DROP_SHADOW_CACHE_SIZE 2.0f
11509b7c91de73b59aa3f679b3ae3ba299f82ec9f8aRomain Guy#define DEFAULT_FBO_CACHE_SIZE 16
116fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy
117eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy#define DEFAULT_TEXTURE_CACHE_FLUSH_RATE 0.6f
118eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy
119b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy#define DEFAULT_TEXT_GAMMA 1.4f
120b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy#define DEFAULT_TEXT_BLACK_GAMMA_THRESHOLD 64
121b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy#define DEFAULT_TEXT_WHITE_GAMMA_THRESHOLD 192
122b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy
123e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guystatic DebugLevel readDebugLevel() {
124e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy    char property[PROPERTY_VALUE_MAX];
125e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy    if (property_get(PROPERTY_DEBUG, property, NULL) > 0) {
126e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy        return (DebugLevel) atoi(property);
127e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy    }
128e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy    return kDebugDisabled;
129e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy}
130e190aa69756aecfaffabdd4c6d32cb6b3220d842Romain Guy
1315b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#endif // ANDROID_HWUI_PROPERTIES_H
132