Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 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 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_HWUI_CACHES_H |
| 18 | #define ANDROID_HWUI_CACHES_H |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 19 | |
Romain Guy | a2341a9 | 2010-09-08 18:04:33 -0700 | [diff] [blame] | 20 | #ifndef LOG_TAG |
| 21 | #define LOG_TAG "OpenGLRenderer" |
| 22 | #endif |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 23 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 24 | #include <GLES3/gl3.h> |
| 25 | |
| 26 | #include <utils/KeyedVector.h> |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 27 | #include <utils/Singleton.h> |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 28 | #include <utils/Vector.h> |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 29 | |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 30 | #include <cutils/compiler.h> |
| 31 | |
Romain Guy | 5dc7fa7 | 2013-03-11 20:48:31 -0700 | [diff] [blame] | 32 | #include "thread/TaskProcessor.h" |
| 33 | #include "thread/TaskManager.h" |
| 34 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 35 | #include "AssetAtlas.h" |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 36 | #include "FontRenderer.h" |
| 37 | #include "GammaFontRenderer.h" |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 38 | #include "TextureCache.h" |
| 39 | #include "LayerCache.h" |
Romain Guy | 8d4aeb7 | 2013-02-12 16:08:55 -0800 | [diff] [blame] | 40 | #include "RenderBufferCache.h" |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 41 | #include "GradientCache.h" |
| 42 | #include "PatchCache.h" |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 43 | #include "ProgramCache.h" |
Romain Guy | ff26a0c | 2011-01-20 11:35:46 -0800 | [diff] [blame] | 44 | #include "PathCache.h" |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 45 | #include "TextDropShadowCache.h" |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 46 | #include "FboCache.h" |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 47 | #include "ResourceCache.h" |
Romain Guy | 0baaac5 | 2012-08-31 20:31:01 -0700 | [diff] [blame] | 48 | #include "Stencil.h" |
Romain Guy | 211efea | 2012-07-31 21:16:07 -0700 | [diff] [blame] | 49 | #include "Dither.h" |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 50 | |
| 51 | namespace android { |
| 52 | namespace uirenderer { |
| 53 | |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 54 | /////////////////////////////////////////////////////////////////////////////// |
| 55 | // Globals |
| 56 | /////////////////////////////////////////////////////////////////////////////// |
| 57 | |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 58 | // GL ES 2.0 defines that at least 16 texture units must be supported |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 59 | #define REQUIRED_TEXTURE_UNITS_COUNT 3 |
| 60 | |
Romain Guy | 31e08e9 | 2013-06-18 15:53:53 -0700 | [diff] [blame] | 61 | // Maximum number of quads that pre-allocated meshes can draw |
| 62 | static const uint32_t gMaxNumberOfQuads = 2048; |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 63 | |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 64 | // Generates simple and textured vertices |
| 65 | #define FV(x, y, u, v) { { x, y }, { u, v } } |
| 66 | |
| 67 | // This array is never used directly but used as a memcpy source in the |
| 68 | // OpenGLRenderer constructor |
| 69 | static const TextureVertex gMeshVertices[] = { |
| 70 | FV(0.0f, 0.0f, 0.0f, 0.0f), |
| 71 | FV(1.0f, 0.0f, 1.0f, 0.0f), |
| 72 | FV(0.0f, 1.0f, 0.0f, 1.0f), |
| 73 | FV(1.0f, 1.0f, 1.0f, 1.0f) |
| 74 | }; |
| 75 | static const GLsizei gMeshStride = sizeof(TextureVertex); |
Chet Haase | 5b0200b | 2011-04-13 17:58:08 -0700 | [diff] [blame] | 76 | static const GLsizei gVertexStride = sizeof(Vertex); |
| 77 | static const GLsizei gAlphaVertexStride = sizeof(AlphaVertex); |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 78 | static const GLsizei gMeshTextureOffset = 2 * sizeof(float); |
Chris Craik | 6ebdc11 | 2012-08-31 18:24:33 -0700 | [diff] [blame] | 79 | static const GLsizei gVertexAlphaOffset = 2 * sizeof(float); |
Chet Haase | 99585ad | 2011-05-02 15:00:16 -0700 | [diff] [blame] | 80 | static const GLsizei gVertexAAWidthOffset = 2 * sizeof(float); |
| 81 | static const GLsizei gVertexAALengthOffset = 3 * sizeof(float); |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 82 | static const GLsizei gMeshCount = 4; |
| 83 | |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 84 | // Must define as many texture units as specified by REQUIRED_TEXTURE_UNITS_COUNT |
Romain Guy | a1d3c91 | 2011-12-13 14:55:06 -0800 | [diff] [blame] | 85 | static const GLenum gTextureUnits[] = { |
| 86 | GL_TEXTURE0, |
| 87 | GL_TEXTURE1, |
| 88 | GL_TEXTURE2 |
| 89 | }; |
| 90 | |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 91 | /////////////////////////////////////////////////////////////////////////////// |
| 92 | // Debug |
| 93 | /////////////////////////////////////////////////////////////////////////////// |
| 94 | |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 95 | struct CacheLogger { |
| 96 | CacheLogger() { |
Romain Guy | d6b2a00 | 2011-06-17 17:45:59 -0700 | [diff] [blame] | 97 | INIT_LOGD("Creating OpenGL renderer caches"); |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 98 | } |
| 99 | }; // struct CacheLogger |
| 100 | |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 101 | /////////////////////////////////////////////////////////////////////////////// |
| 102 | // Caches |
| 103 | /////////////////////////////////////////////////////////////////////////////// |
| 104 | |
Romain Guy | bb0acdf | 2012-03-05 13:44:35 -0800 | [diff] [blame] | 105 | class DisplayList; |
| 106 | |
Romain Guy | 7953745 | 2011-10-12 13:48:51 -0700 | [diff] [blame] | 107 | class ANDROID_API Caches: public Singleton<Caches> { |
Chet Haase | dd78cca | 2010-10-22 18:59:26 -0700 | [diff] [blame] | 108 | Caches(); |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 109 | |
| 110 | friend class Singleton<Caches>; |
| 111 | |
Romain Guy | e190aa6 | 2010-11-10 19:01:29 -0800 | [diff] [blame] | 112 | CacheLogger mLogger; |
Romain Guy | 9bca479 | 2010-10-25 18:42:25 -0700 | [diff] [blame] | 113 | |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 114 | public: |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 115 | enum FlushMode { |
Romain Guy | 6d7475d | 2011-07-27 16:28:21 -0700 | [diff] [blame] | 116 | kFlushMode_Layers = 0, |
| 117 | kFlushMode_Moderate, |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 118 | kFlushMode_Full |
| 119 | }; |
| 120 | |
| 121 | /** |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 122 | * Initialize caches. |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 123 | */ |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 124 | bool init(); |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 125 | |
| 126 | /** |
Romain Guy | 5bb3c73 | 2012-11-29 17:52:58 -0800 | [diff] [blame] | 127 | * Initialize global system properties. |
| 128 | */ |
| 129 | bool initProperties(); |
| 130 | |
| 131 | /** |
Romain Guy | bdf7609 | 2011-07-18 15:00:43 -0700 | [diff] [blame] | 132 | * Flush the cache. |
| 133 | * |
| 134 | * @param mode Indicates how much of the cache should be flushed |
| 135 | */ |
| 136 | void flush(FlushMode mode); |
| 137 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 138 | /** |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 139 | * Destroys all resources associated with this cache. This should |
| 140 | * be called after a flush(kFlushMode_Full). |
| 141 | */ |
| 142 | void terminate(); |
| 143 | |
| 144 | /** |
Romain Guy | e190aa6 | 2010-11-10 19:01:29 -0800 | [diff] [blame] | 145 | * Indicates whether the renderer is in debug mode. |
| 146 | * This debug mode provides limited information to app developers. |
| 147 | */ |
| 148 | DebugLevel getDebugLevel() const { |
| 149 | return mDebugLevel; |
| 150 | } |
| 151 | |
| 152 | /** |
Romain Guy | 627c6fd | 2013-08-21 11:53:18 -0700 | [diff] [blame] | 153 | * Returns a non-premultiplied ARGB color for the specified |
| 154 | * amount of overdraw (1 for 1x, 2 for 2x, etc.) |
| 155 | */ |
| 156 | uint32_t getOverdrawColor(uint32_t amount) const; |
| 157 | |
| 158 | /** |
Romain Guy | fe48f65 | 2010-11-11 15:36:56 -0800 | [diff] [blame] | 159 | * Call this on each frame to ensure that garbage is deleted from |
| 160 | * GPU memory. |
| 161 | */ |
| 162 | void clearGarbage(); |
| 163 | |
| 164 | /** |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 165 | * Can be used to delete a layer from a non EGL thread. |
Romain Guy | 57066eb | 2011-01-12 12:53:32 -0800 | [diff] [blame] | 166 | */ |
Romain Guy | ada830f | 2011-01-13 12:13:20 -0800 | [diff] [blame] | 167 | void deleteLayerDeferred(Layer* layer); |
Romain Guy | 57066eb | 2011-01-12 12:53:32 -0800 | [diff] [blame] | 168 | |
Romain Guy | bb0acdf | 2012-03-05 13:44:35 -0800 | [diff] [blame] | 169 | /* |
| 170 | * Can be used to delete a display list from a non EGL thread. |
| 171 | */ |
| 172 | void deleteDisplayListDeferred(DisplayList* layer); |
| 173 | |
Romain Guy | 57066eb | 2011-01-12 12:53:32 -0800 | [diff] [blame] | 174 | /** |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 175 | * Binds the VBO used to render simple textured quads. |
| 176 | */ |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 177 | bool bindMeshBuffer(); |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 178 | |
| 179 | /** |
| 180 | * Binds the specified VBO if needed. |
| 181 | */ |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 182 | bool bindMeshBuffer(const GLuint buffer); |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 183 | |
| 184 | /** |
| 185 | * Unbinds the VBO used to render simple textured quads. |
| 186 | */ |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 187 | bool unbindMeshBuffer(); |
| 188 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 189 | /** |
| 190 | * Binds a global indices buffer that can draw up to |
Romain Guy | 31e08e9 | 2013-06-18 15:53:53 -0700 | [diff] [blame] | 191 | * gMaxNumberOfQuads quads. |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 192 | */ |
| 193 | bool bindIndicesBuffer(); |
Romain Guy | 15bc643 | 2011-12-13 13:11:32 -0800 | [diff] [blame] | 194 | bool bindIndicesBuffer(const GLuint buffer); |
| 195 | bool unbindIndicesBuffer(); |
| 196 | |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 197 | /** |
Romain Guy | cf51a41 | 2013-04-08 19:40:31 -0700 | [diff] [blame] | 198 | * Binds the specified buffer as the current GL unpack pixel buffer. |
| 199 | */ |
| 200 | bool bindPixelBuffer(const GLuint buffer); |
| 201 | |
| 202 | /** |
| 203 | * Resets the current unpack pixel buffer to 0 (default value.) |
| 204 | */ |
| 205 | bool unbindPixelBuffer(); |
| 206 | |
| 207 | /** |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 208 | * Binds an attrib to the specified float vertex pointer. |
| 209 | * Assumes a stride of gMeshStride and a size of 2. |
| 210 | */ |
Chris Craik | cb4d600 | 2012-09-25 12:00:29 -0700 | [diff] [blame] | 211 | void bindPositionVertexPointer(bool force, GLvoid* vertices, GLsizei stride = gMeshStride); |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 212 | |
| 213 | /** |
| 214 | * Binds an attrib to the specified float vertex pointer. |
| 215 | * Assumes a stride of gMeshStride and a size of 2. |
| 216 | */ |
Romain Guy | ff316ec | 2013-02-13 18:39:43 -0800 | [diff] [blame] | 217 | void bindTexCoordsVertexPointer(bool force, GLvoid* vertices, GLsizei stride = gMeshStride); |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 218 | |
| 219 | /** |
| 220 | * Resets the vertex pointers. |
| 221 | */ |
| 222 | void resetVertexPointers(); |
| 223 | void resetTexCoordsVertexPointer(); |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 224 | |
Romain Guy | 15bc643 | 2011-12-13 13:11:32 -0800 | [diff] [blame] | 225 | void enableTexCoordsVertexArray(); |
Romain Guy | ff316ec | 2013-02-13 18:39:43 -0800 | [diff] [blame] | 226 | void disableTexCoordsVertexArray(); |
Romain Guy | 15bc643 | 2011-12-13 13:11:32 -0800 | [diff] [blame] | 227 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 228 | /** |
Romain Guy | a1d3c91 | 2011-12-13 14:55:06 -0800 | [diff] [blame] | 229 | * Activate the specified texture unit. The texture unit must |
| 230 | * be specified using an integer number (0 for GL_TEXTURE0 etc.) |
| 231 | */ |
| 232 | void activeTexture(GLuint textureUnit); |
| 233 | |
| 234 | /** |
Chris Craik | 9ab2d18 | 2013-07-22 16:16:06 -0700 | [diff] [blame] | 235 | * Invalidate the cached value of the active texture unit. |
| 236 | */ |
| 237 | void resetActiveTexture(); |
| 238 | |
| 239 | /** |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 240 | * Binds the specified texture as a GL_TEXTURE_2D texture. |
Romain Guy | be1b127 | 2013-06-06 14:02:54 -0700 | [diff] [blame] | 241 | * All texture bindings must be performed with this method or |
| 242 | * bindTexture(GLenum, GLuint). |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 243 | */ |
| 244 | void bindTexture(GLuint texture); |
| 245 | |
| 246 | /** |
Romain Guy | be1b127 | 2013-06-06 14:02:54 -0700 | [diff] [blame] | 247 | * Binds the specified texture with the specified render target. |
| 248 | * All texture bindings must be performed with this method or |
| 249 | * bindTexture(GLuint). |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 250 | */ |
| 251 | void bindTexture(GLenum target, GLuint texture); |
| 252 | |
| 253 | /** |
Romain Guy | be1b127 | 2013-06-06 14:02:54 -0700 | [diff] [blame] | 254 | * Deletes the specified texture and clears it from the cache |
| 255 | * of bound textures. |
| 256 | * All textures must be deleted using this method. |
| 257 | */ |
| 258 | void deleteTexture(GLuint texture); |
| 259 | |
| 260 | /** |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 261 | * Signals that the cache of bound textures should be cleared. |
| 262 | * Other users of the context may have altered which textures are bound. |
| 263 | */ |
| 264 | void resetBoundTextures(); |
| 265 | |
| 266 | /** |
jiayuanr | 4a473c7d | 2014-06-10 17:41:49 +0800 | [diff] [blame^] | 267 | * Clear the cache of bound textures. |
| 268 | */ |
| 269 | void unbindTexture(GLuint texture); |
| 270 | |
| 271 | /** |
Romain Guy | 8f85e80 | 2011-12-14 19:23:32 -0800 | [diff] [blame] | 272 | * Sets the scissor for the current surface. |
| 273 | */ |
Romain Guy | 8a4ac61 | 2012-07-17 17:32:48 -0700 | [diff] [blame] | 274 | bool setScissor(GLint x, GLint y, GLint width, GLint height); |
Romain Guy | 8f85e80 | 2011-12-14 19:23:32 -0800 | [diff] [blame] | 275 | |
| 276 | /** |
Romain Guy | 82bc7a7 | 2012-01-03 14:13:39 -0800 | [diff] [blame] | 277 | * Resets the scissor state. |
| 278 | */ |
| 279 | void resetScissor(); |
| 280 | |
Romain Guy | 8a4ac61 | 2012-07-17 17:32:48 -0700 | [diff] [blame] | 281 | bool enableScissor(); |
| 282 | bool disableScissor(); |
Romain Guy | 586cae3 | 2012-07-13 15:28:31 -0700 | [diff] [blame] | 283 | void setScissorEnabled(bool enabled); |
| 284 | |
Romain Guy | ef35927 | 2013-01-31 19:07:29 -0800 | [diff] [blame] | 285 | void startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool discard); |
Romain Guy | 85ef80d | 2012-09-13 20:26:50 -0700 | [diff] [blame] | 286 | void endTiling(); |
| 287 | |
Romain Guy | 82bc7a7 | 2012-01-03 14:13:39 -0800 | [diff] [blame] | 288 | /** |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 289 | * Returns the mesh used to draw regions. Calling this method will |
| 290 | * bind a VBO of type GL_ELEMENT_ARRAY_BUFFER that contains the |
| 291 | * indices for the region mesh. |
| 292 | */ |
| 293 | TextureVertex* getRegionMesh(); |
| 294 | |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 295 | /** |
| 296 | * Displays the memory usage of each cache and the total sum. |
| 297 | */ |
| 298 | void dumpMemoryUsage(); |
Chet Haase | 9c1e23b | 2011-03-24 10:51:31 -0700 | [diff] [blame] | 299 | void dumpMemoryUsage(String8& log); |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 300 | |
Romain Guy | 54c1a64 | 2012-09-27 17:55:46 -0700 | [diff] [blame] | 301 | bool hasRegisteredFunctors(); |
| 302 | void registerFunctors(uint32_t functorCount); |
| 303 | void unregisterFunctors(uint32_t functorCount); |
| 304 | |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 305 | bool blend; |
| 306 | GLenum lastSrcMode; |
| 307 | GLenum lastDstMode; |
| 308 | Program* currentProgram; |
Romain Guy | 586cae3 | 2012-07-13 15:28:31 -0700 | [diff] [blame] | 309 | bool scissorEnabled; |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 310 | |
Romain Guy | 0f66753 | 2013-03-01 14:31:04 -0800 | [diff] [blame] | 311 | bool drawDeferDisabled; |
| 312 | bool drawReorderDisabled; |
| 313 | |
Romain Guy | 746b740 | 2010-10-26 16:27:31 -0700 | [diff] [blame] | 314 | // VBO to draw with |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 315 | GLuint meshBuffer; |
Romain Guy | 03750a0 | 2010-10-18 14:06:08 -0700 | [diff] [blame] | 316 | |
Romain Guy | 746b740 | 2010-10-26 16:27:31 -0700 | [diff] [blame] | 317 | // Misc |
| 318 | GLint maxTextureSize; |
Romain Guy | 3ff0bfd | 2013-02-25 14:15:37 -0800 | [diff] [blame] | 319 | |
| 320 | // Debugging |
Romain Guy | 4ff0cf4 | 2012-08-06 14:51:10 -0700 | [diff] [blame] | 321 | bool debugLayersUpdates; |
Romain Guy | 7c450aa | 2012-09-21 19:15:00 -0700 | [diff] [blame] | 322 | bool debugOverdraw; |
Romain Guy | 746b740 | 2010-10-26 16:27:31 -0700 | [diff] [blame] | 323 | |
Romain Guy | 3ff0bfd | 2013-02-25 14:15:37 -0800 | [diff] [blame] | 324 | enum StencilClipDebug { |
| 325 | kStencilHide, |
| 326 | kStencilShowHighlight, |
| 327 | kStencilShowRegion |
| 328 | }; |
| 329 | StencilClipDebug debugStencilClip; |
| 330 | |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 331 | TextureCache textureCache; |
| 332 | LayerCache layerCache; |
Romain Guy | 8d4aeb7 | 2013-02-12 16:08:55 -0800 | [diff] [blame] | 333 | RenderBufferCache renderBufferCache; |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 334 | GradientCache gradientCache; |
| 335 | ProgramCache programCache; |
| 336 | PathCache pathCache; |
| 337 | PatchCache patchCache; |
| 338 | TextDropShadowCache dropShadowCache; |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 339 | FboCache fboCache; |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 340 | ResourceCache resourceCache; |
Romain Guy | 29d8997 | 2010-09-22 16:10:57 -0700 | [diff] [blame] | 341 | |
Romain Guy | b1d0a4e | 2012-07-13 18:25:35 -0700 | [diff] [blame] | 342 | GammaFontRenderer* fontRenderer; |
| 343 | |
Romain Guy | 5dc7fa7 | 2013-03-11 20:48:31 -0700 | [diff] [blame] | 344 | TaskManager tasks; |
| 345 | |
Romain Guy | 0baaac5 | 2012-08-31 20:31:01 -0700 | [diff] [blame] | 346 | Dither dither; |
Romain Guy | 0baaac5 | 2012-08-31 20:31:01 -0700 | [diff] [blame] | 347 | Stencil stencil; |
Romain Guy | 0baaac5 | 2012-08-31 20:31:01 -0700 | [diff] [blame] | 348 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 349 | AssetAtlas assetAtlas; |
| 350 | |
Romain Guy | f9f0016 | 2013-05-09 11:50:12 -0700 | [diff] [blame] | 351 | bool gpuPixelBuffersEnabled; |
| 352 | |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 353 | // Debug methods |
Romain Guy | 13631f3 | 2012-01-30 17:41:55 -0800 | [diff] [blame] | 354 | PFNGLINSERTEVENTMARKEREXTPROC eventMark; |
| 355 | PFNGLPUSHGROUPMARKEREXTPROC startMark; |
| 356 | PFNGLPOPGROUPMARKEREXTPROC endMark; |
| 357 | |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 358 | PFNGLLABELOBJECTEXTPROC setLabel; |
| 359 | PFNGLGETOBJECTLABELEXTPROC getLabel; |
| 360 | |
Romain Guy | e190aa6 | 2010-11-10 19:01:29 -0800 | [diff] [blame] | 361 | private: |
Romain Guy | 627c6fd | 2013-08-21 11:53:18 -0700 | [diff] [blame] | 362 | enum OverdrawColorSet { |
| 363 | kColorSet_Default = 0, |
| 364 | kColorSet_Deuteranomaly |
| 365 | }; |
| 366 | |
Romain Guy | b1d0a4e | 2012-07-13 18:25:35 -0700 | [diff] [blame] | 367 | void initFont(); |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 368 | void initExtensions(); |
| 369 | void initConstraints(); |
Romain Guy | f9f0016 | 2013-05-09 11:50:12 -0700 | [diff] [blame] | 370 | void initStaticProperties(); |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 371 | |
| 372 | static void eventMarkNull(GLsizei length, const GLchar* marker) { } |
| 373 | static void startMarkNull(GLsizei length, const GLchar* marker) { } |
Romain Guy | 13631f3 | 2012-01-30 17:41:55 -0800 | [diff] [blame] | 374 | static void endMarkNull() { } |
| 375 | |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 376 | static void setLabelNull(GLenum type, uint object, GLsizei length, |
| 377 | const char* label) { } |
| 378 | static void getLabelNull(GLenum type, uint object, GLsizei bufferSize, |
| 379 | GLsizei* length, char* label) { |
| 380 | if (length) *length = 0; |
| 381 | if (label) *label = '\0'; |
| 382 | } |
| 383 | |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 384 | GLuint mCurrentBuffer; |
Romain Guy | 15bc643 | 2011-12-13 13:11:32 -0800 | [diff] [blame] | 385 | GLuint mCurrentIndicesBuffer; |
Romain Guy | cf51a41 | 2013-04-08 19:40:31 -0700 | [diff] [blame] | 386 | GLuint mCurrentPixelBuffer; |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 387 | void* mCurrentPositionPointer; |
Chris Craik | 16b897c | 2012-09-27 13:10:56 -0700 | [diff] [blame] | 388 | GLsizei mCurrentPositionStride; |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 389 | void* mCurrentTexCoordsPointer; |
Romain Guy | ff316ec | 2013-02-13 18:39:43 -0800 | [diff] [blame] | 390 | GLsizei mCurrentTexCoordsStride; |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 391 | |
Romain Guy | 15bc643 | 2011-12-13 13:11:32 -0800 | [diff] [blame] | 392 | bool mTexCoordsArrayEnabled; |
| 393 | |
Romain Guy | a1d3c91 | 2011-12-13 14:55:06 -0800 | [diff] [blame] | 394 | GLuint mTextureUnit; |
| 395 | |
Romain Guy | 8f85e80 | 2011-12-14 19:23:32 -0800 | [diff] [blame] | 396 | GLint mScissorX; |
| 397 | GLint mScissorY; |
| 398 | GLint mScissorWidth; |
| 399 | GLint mScissorHeight; |
| 400 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 401 | Extensions& mExtensions; |
| 402 | |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 403 | // Used to render layers |
| 404 | TextureVertex* mRegionMesh; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 405 | |
| 406 | // Global index buffer |
| 407 | GLuint mMeshIndices; |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 408 | |
| 409 | mutable Mutex mGarbageLock; |
| 410 | Vector<Layer*> mLayerGarbage; |
Romain Guy | bb0acdf | 2012-03-05 13:44:35 -0800 | [diff] [blame] | 411 | Vector<DisplayList*> mDisplayListGarbage; |
Romain Guy | f3a910b4 | 2011-12-12 20:35:21 -0800 | [diff] [blame] | 412 | |
Romain Guy | e190aa6 | 2010-11-10 19:01:29 -0800 | [diff] [blame] | 413 | DebugLevel mDebugLevel; |
Romain Guy | 8ff6b9e | 2011-11-09 20:10:18 -0800 | [diff] [blame] | 414 | bool mInitialized; |
Romain Guy | 54c1a64 | 2012-09-27 17:55:46 -0700 | [diff] [blame] | 415 | |
| 416 | uint32_t mFunctorsCount; |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 417 | |
| 418 | GLuint mBoundTextures[REQUIRED_TEXTURE_UNITS_COUNT]; |
Romain Guy | 627c6fd | 2013-08-21 11:53:18 -0700 | [diff] [blame] | 419 | |
| 420 | OverdrawColorSet mOverdrawDebugColorSet; |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 421 | }; // class Caches |
| 422 | |
| 423 | }; // namespace uirenderer |
Romain Guy | fb8b763 | 2010-08-23 21:05:08 -0700 | [diff] [blame] | 424 | }; // namespace android |
| 425 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 426 | #endif // ANDROID_HWUI_CACHES_H |