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