Romain Guy | dda5702 | 2010-07-06 11:39:32 -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_LAYER_H |
| 18 | #define ANDROID_HWUI_LAYER_H |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 19 | |
Derek Sollenberger | 76d3a1b | 2013-12-10 12:28:58 -0500 | [diff] [blame] | 20 | #include <cutils/compiler.h> |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 21 | #include <sys/types.h> |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 22 | #include <utils/StrongPointer.h> |
Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame] | 23 | |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 24 | #include <GLES2/gl2.h> |
| 25 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 26 | #include <ui/Region.h> |
| 27 | |
Derek Sollenberger | ca79cf6 | 2012-08-14 16:44:52 -0400 | [diff] [blame] | 28 | #include <SkPaint.h> |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 29 | #include <SkXfermode.h> |
| 30 | |
Derek Sollenberger | 76d3a1b | 2013-12-10 12:28:58 -0500 | [diff] [blame] | 31 | #include "Matrix.h" |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 32 | #include "Rect.h" |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 33 | #include "RenderBuffer.h" |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 34 | #include "Texture.h" |
Romain Guy | f219da5 | 2011-01-16 12:54:25 -0800 | [diff] [blame] | 35 | #include "Vertex.h" |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 36 | |
| 37 | namespace android { |
| 38 | namespace uirenderer { |
| 39 | |
Romain Guy | 8550c4c | 2010-10-08 15:49:53 -0700 | [diff] [blame] | 40 | /////////////////////////////////////////////////////////////////////////////// |
| 41 | // Layers |
| 42 | /////////////////////////////////////////////////////////////////////////////// |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 43 | |
Romain Guy | 2bf68f0 | 2012-03-02 13:37:47 -0800 | [diff] [blame] | 44 | // Forward declarations |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 45 | class Caches; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 46 | class RenderState; |
Romain Guy | 2bf68f0 | 2012-03-02 13:37:47 -0800 | [diff] [blame] | 47 | class OpenGLRenderer; |
John Reck | e18264b | 2014-03-12 13:56:30 -0700 | [diff] [blame] | 48 | class RenderNode; |
Romain Guy | 96885eb | 2013-03-26 15:05:58 -0700 | [diff] [blame] | 49 | class DeferredDisplayList; |
| 50 | class DeferStateStruct; |
Romain Guy | 2bf68f0 | 2012-03-02 13:37:47 -0800 | [diff] [blame] | 51 | |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 52 | /** |
Romain Guy | eb99356 | 2010-10-05 18:14:38 -0700 | [diff] [blame] | 53 | * A layer has dimensions and is backed by an OpenGL texture or FBO. |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 54 | */ |
Chris Craik | 564acf7 | 2014-01-02 16:46:18 -0800 | [diff] [blame] | 55 | class Layer { |
| 56 | public: |
Chris Craik | 8a226d2 | 2014-09-08 16:40:21 -0700 | [diff] [blame^] | 57 | enum Type { |
| 58 | kType_Texture, |
| 59 | kType_DisplayList, |
| 60 | }; |
| 61 | |
| 62 | Layer(Type type, RenderState& renderState, const uint32_t layerWidth, const uint32_t layerHeight); |
Chet Haase | d15ebf2 | 2012-09-05 11:40:29 -0700 | [diff] [blame] | 63 | ~Layer(); |
Romain Guy | 8550c4c | 2010-10-08 15:49:53 -0700 | [diff] [blame] | 64 | |
Romain Guy | 2055aba | 2013-01-18 16:42:51 -0800 | [diff] [blame] | 65 | static uint32_t computeIdealWidth(uint32_t layerWidth); |
| 66 | static uint32_t computeIdealHeight(uint32_t layerHeight); |
| 67 | |
Romain Guy | 8ce0030 | 2013-01-15 18:51:42 -0800 | [diff] [blame] | 68 | /** |
| 69 | * Calling this method will remove (either by recycling or |
| 70 | * destroying) the associated FBO, if present, and any render |
| 71 | * buffer (stencil for instance.) |
| 72 | */ |
| 73 | void removeFbo(bool flush = true); |
Dave Burke | 56257af | 2012-09-25 20:30:09 -0700 | [diff] [blame] | 74 | |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 75 | /** |
Romain Guy | 9fc2781 | 2011-04-27 14:21:41 -0700 | [diff] [blame] | 76 | * Sets this layer's region to a rectangle. Computes the appropriate |
| 77 | * texture coordinates. |
| 78 | */ |
| 79 | void setRegionAsRect() { |
| 80 | const android::Rect& bounds = region.getBounds(); |
| 81 | regionRect.set(bounds.leftTop().x, bounds.leftTop().y, |
| 82 | bounds.rightBottom().x, bounds.rightBottom().y); |
| 83 | |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 84 | const float texX = 1.0f / float(texture.width); |
| 85 | const float texY = 1.0f / float(texture.height); |
Romain Guy | 9fc2781 | 2011-04-27 14:21:41 -0700 | [diff] [blame] | 86 | const float height = layer.getHeight(); |
| 87 | texCoords.set( |
| 88 | regionRect.left * texX, (height - regionRect.top) * texY, |
| 89 | regionRect.right * texX, (height - regionRect.bottom) * texY); |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 90 | |
| 91 | regionRect.translate(layer.left, layer.top); |
| 92 | } |
| 93 | |
Chris Craik | 69e5adf | 2014-08-14 13:34:01 -0700 | [diff] [blame] | 94 | void setWindowTransform(Matrix4& windowTransform) { |
| 95 | cachedInvTransformInWindow.loadInverse(windowTransform); |
| 96 | rendererLightPosDirty = true; |
| 97 | } |
| 98 | |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 99 | void updateDeferred(RenderNode* renderNode, int left, int top, int right, int bottom); |
Romain Guy | 2bf68f0 | 2012-03-02 13:37:47 -0800 | [diff] [blame] | 100 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 101 | inline uint32_t getWidth() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 102 | return texture.width; |
| 103 | } |
| 104 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 105 | inline uint32_t getHeight() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 106 | return texture.height; |
| 107 | } |
| 108 | |
Romain Guy | 2055aba | 2013-01-18 16:42:51 -0800 | [diff] [blame] | 109 | /** |
| 110 | * Resize the layer and its texture if needed. |
| 111 | * |
| 112 | * @param width The new width of the layer |
| 113 | * @param height The new height of the layer |
| 114 | * |
| 115 | * @return True if the layer was resized or nothing happened, false if |
| 116 | * a failure occurred during the resizing operation |
| 117 | */ |
| 118 | bool resize(const uint32_t width, const uint32_t height); |
| 119 | |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 120 | void setSize(uint32_t width, uint32_t height) { |
| 121 | texture.width = width; |
| 122 | texture.height = height; |
| 123 | } |
| 124 | |
Derek Sollenberger | 674554f | 2014-02-19 16:47:32 +0000 | [diff] [blame] | 125 | ANDROID_API void setPaint(const SkPaint* paint); |
Chet Haase | d15ebf2 | 2012-09-05 11:40:29 -0700 | [diff] [blame] | 126 | |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 127 | inline void setBlend(bool blend) { |
| 128 | texture.blend = blend; |
| 129 | } |
| 130 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 131 | inline bool isBlend() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 132 | return texture.blend; |
| 133 | } |
| 134 | |
Chris Craik | 9757ac0 | 2014-02-25 18:50:17 -0800 | [diff] [blame] | 135 | inline void setForceFilter(bool forceFilter) { |
| 136 | this->forceFilter = forceFilter; |
| 137 | } |
| 138 | |
| 139 | inline bool getForceFilter() const { |
| 140 | return forceFilter; |
| 141 | } |
| 142 | |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 143 | inline void setAlpha(int alpha) { |
| 144 | this->alpha = alpha; |
| 145 | } |
| 146 | |
| 147 | inline void setAlpha(int alpha, SkXfermode::Mode mode) { |
| 148 | this->alpha = alpha; |
| 149 | this->mode = mode; |
| 150 | } |
| 151 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 152 | inline int getAlpha() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 153 | return alpha; |
| 154 | } |
| 155 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 156 | inline SkXfermode::Mode getMode() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 157 | return mode; |
| 158 | } |
| 159 | |
| 160 | inline void setEmpty(bool empty) { |
| 161 | this->empty = empty; |
| 162 | } |
| 163 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 164 | inline bool isEmpty() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 165 | return empty; |
| 166 | } |
| 167 | |
| 168 | inline void setFbo(GLuint fbo) { |
| 169 | this->fbo = fbo; |
| 170 | } |
| 171 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 172 | inline GLuint getFbo() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 173 | return fbo; |
| 174 | } |
| 175 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 176 | inline void setStencilRenderBuffer(RenderBuffer* renderBuffer) { |
| 177 | if (RenderBuffer::isStencilBuffer(renderBuffer->getFormat())) { |
| 178 | this->stencil = renderBuffer; |
| 179 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, |
| 180 | GL_RENDERBUFFER, stencil->getName()); |
| 181 | } else { |
| 182 | ALOGE("The specified render buffer is not a stencil buffer"); |
| 183 | } |
Romain Guy | 8ce0030 | 2013-01-15 18:51:42 -0800 | [diff] [blame] | 184 | } |
| 185 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 186 | inline RenderBuffer* getStencilRenderBuffer() const { |
Romain Guy | 8ce0030 | 2013-01-15 18:51:42 -0800 | [diff] [blame] | 187 | return stencil; |
| 188 | } |
| 189 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 190 | inline GLuint getTexture() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 191 | return texture.id; |
| 192 | } |
| 193 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 194 | inline GLenum getRenderTarget() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 195 | return renderTarget; |
| 196 | } |
| 197 | |
| 198 | inline void setRenderTarget(GLenum renderTarget) { |
| 199 | this->renderTarget = renderTarget; |
| 200 | } |
| 201 | |
Romain Guy | d21b6e1 | 2011-11-30 20:21:23 -0800 | [diff] [blame] | 202 | void setWrap(GLenum wrap, bool bindTexture = false, bool force = false) { |
| 203 | texture.setWrap(wrap, bindTexture, force, renderTarget); |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 204 | } |
| 205 | |
Romain Guy | d21b6e1 | 2011-11-30 20:21:23 -0800 | [diff] [blame] | 206 | void setFilter(GLenum filter, bool bindTexture = false, bool force = false) { |
| 207 | texture.setFilter(filter, bindTexture, force, renderTarget); |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 210 | inline bool isCacheable() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 211 | return cacheable; |
| 212 | } |
| 213 | |
| 214 | inline void setCacheable(bool cacheable) { |
| 215 | this->cacheable = cacheable; |
| 216 | } |
| 217 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 218 | inline bool isDirty() const { |
Romain Guy | 7c25aab | 2012-10-18 15:05:02 -0700 | [diff] [blame] | 219 | return dirty; |
| 220 | } |
| 221 | |
| 222 | inline void setDirty(bool dirty) { |
| 223 | this->dirty = dirty; |
| 224 | } |
| 225 | |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 226 | inline bool isTextureLayer() const { |
Chris Craik | 8a226d2 | 2014-09-08 16:40:21 -0700 | [diff] [blame^] | 227 | return type == kType_Texture; |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Derek Sollenberger | 76d3a1b | 2013-12-10 12:28:58 -0500 | [diff] [blame] | 230 | inline SkColorFilter* getColorFilter() const { |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 231 | return colorFilter; |
| 232 | } |
| 233 | |
Derek Sollenberger | 76d3a1b | 2013-12-10 12:28:58 -0500 | [diff] [blame] | 234 | ANDROID_API void setColorFilter(SkColorFilter* filter); |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 235 | |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 236 | inline void setConvexMask(const SkPath* convexMask) { |
| 237 | this->convexMask = convexMask; |
| 238 | } |
| 239 | |
| 240 | inline const SkPath* getConvexMask() { |
| 241 | return convexMask; |
| 242 | } |
| 243 | |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 244 | void bindStencilRenderBuffer() const; |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 245 | |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 246 | void bindTexture() const; |
| 247 | void generateTexture(); |
| 248 | void allocateTexture(); |
| 249 | void deleteTexture(); |
Romain Guy | ef09a21 | 2012-09-25 12:17:14 -0700 | [diff] [blame] | 250 | |
| 251 | /** |
| 252 | * When the caller frees the texture itself, the caller |
| 253 | * must call this method to tell this layer that it lost |
| 254 | * the texture. |
| 255 | */ |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 256 | ANDROID_API void clearTexture(); |
Romain Guy | 2055aba | 2013-01-18 16:42:51 -0800 | [diff] [blame] | 257 | |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 258 | inline mat4& getTexTransform() { |
| 259 | return texTransform; |
Romain Guy | 9fc2781 | 2011-04-27 14:21:41 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Romain Guy | 302a9df | 2011-08-16 13:55:02 -0700 | [diff] [blame] | 262 | inline mat4& getTransform() { |
| 263 | return transform; |
| 264 | } |
| 265 | |
Chris Craik | 69e5adf | 2014-08-14 13:34:01 -0700 | [diff] [blame] | 266 | void defer(const OpenGLRenderer& rootRenderer); |
Romain Guy | e93482f | 2013-06-17 13:14:51 -0700 | [diff] [blame] | 267 | void cancelDefer(); |
Romain Guy | 96885eb | 2013-03-26 15:05:58 -0700 | [diff] [blame] | 268 | void flush(); |
Chris Craik | 69e5adf | 2014-08-14 13:34:01 -0700 | [diff] [blame] | 269 | void render(const OpenGLRenderer& rootRenderer); |
Romain Guy | 96885eb | 2013-03-26 15:05:58 -0700 | [diff] [blame] | 270 | |
Romain Guy | 9fc2781 | 2011-04-27 14:21:41 -0700 | [diff] [blame] | 271 | /** |
Romain Guy | 8550c4c | 2010-10-08 15:49:53 -0700 | [diff] [blame] | 272 | * Bounds of the layer. |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 273 | */ |
| 274 | Rect layer; |
| 275 | /** |
Romain Guy | 8550c4c | 2010-10-08 15:49:53 -0700 | [diff] [blame] | 276 | * Texture coordinates of the layer. |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 277 | */ |
Romain Guy | 8550c4c | 2010-10-08 15:49:53 -0700 | [diff] [blame] | 278 | Rect texCoords; |
Romain Guy | c3fedaf | 2013-01-29 17:26:25 -0800 | [diff] [blame] | 279 | /** |
| 280 | * Clipping rectangle. |
| 281 | */ |
| 282 | Rect clipRect; |
Romain Guy | 8550c4c | 2010-10-08 15:49:53 -0700 | [diff] [blame] | 283 | |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 284 | /** |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 285 | * Dirty region indicating what parts of the layer |
| 286 | * have been drawn. |
| 287 | */ |
| 288 | Region region; |
Romain Guy | 4066767 | 2011-03-18 14:34:03 -0700 | [diff] [blame] | 289 | /** |
| 290 | * If the region is a rectangle, coordinates of the |
| 291 | * region are stored here. |
| 292 | */ |
| 293 | Rect regionRect; |
Romain Guy | 171c592 | 2011-01-06 10:04:23 -0800 | [diff] [blame] | 294 | |
| 295 | /** |
Romain Guy | f219da5 | 2011-01-16 12:54:25 -0800 | [diff] [blame] | 296 | * If the layer can be rendered as a mesh, this is non-null. |
| 297 | */ |
| 298 | TextureVertex* mesh; |
Romain Guy | f219da5 | 2011-01-16 12:54:25 -0800 | [diff] [blame] | 299 | GLsizei meshElementCount; |
Romain Guy | aa6c24c | 2011-04-28 18:40:04 -0700 | [diff] [blame] | 300 | |
Romain Guy | 2bf68f0 | 2012-03-02 13:37:47 -0800 | [diff] [blame] | 301 | /** |
| 302 | * Used for deferred updates. |
| 303 | */ |
| 304 | bool deferredUpdateScheduled; |
| 305 | OpenGLRenderer* renderer; |
Chris Craik | a7090e0 | 2014-06-20 16:01:00 -0700 | [diff] [blame] | 306 | sp<RenderNode> renderNode; |
Romain Guy | 2bf68f0 | 2012-03-02 13:37:47 -0800 | [diff] [blame] | 307 | Rect dirtyRect; |
Romain Guy | 5bb3c73 | 2012-11-29 17:52:58 -0800 | [diff] [blame] | 308 | bool debugDrawUpdate; |
Chris Craik | 34416ea | 2013-04-15 16:08:28 -0700 | [diff] [blame] | 309 | bool hasDrawnSinceUpdate; |
John Reck | 443a714 | 2014-09-04 17:40:05 -0700 | [diff] [blame] | 310 | bool wasBuildLayered; |
Romain Guy | 2bf68f0 | 2012-03-02 13:37:47 -0800 | [diff] [blame] | 311 | |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 312 | private: |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 313 | void requireRenderer(); |
Chris Craik | 69e5adf | 2014-08-14 13:34:01 -0700 | [diff] [blame] | 314 | void updateLightPosFromRenderer(const OpenGLRenderer& rootRenderer); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 315 | |
Romain Guy | 8aa195d | 2013-06-04 18:00:09 -0700 | [diff] [blame] | 316 | Caches& caches; |
| 317 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 318 | RenderState& renderState; |
| 319 | |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 320 | /** |
| 321 | * Name of the FBO used to render the layer. If the name is 0 |
| 322 | * this layer is not backed by an FBO, but a simple texture. |
| 323 | */ |
| 324 | GLuint fbo; |
| 325 | |
| 326 | /** |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 327 | * The render buffer used as the stencil buffer. |
Romain Guy | 8ce0030 | 2013-01-15 18:51:42 -0800 | [diff] [blame] | 328 | */ |
Romain Guy | 3bbacf2 | 2013-02-06 16:51:04 -0800 | [diff] [blame] | 329 | RenderBuffer* stencil; |
Romain Guy | 8ce0030 | 2013-01-15 18:51:42 -0800 | [diff] [blame] | 330 | |
| 331 | /** |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 332 | * Indicates whether this layer has been used already. |
| 333 | */ |
| 334 | bool empty; |
| 335 | |
| 336 | /** |
| 337 | * The texture backing this layer. |
| 338 | */ |
| 339 | Texture texture; |
| 340 | |
Romain Guy | aa6c24c | 2011-04-28 18:40:04 -0700 | [diff] [blame] | 341 | /** |
| 342 | * If set to true (by default), the layer can be reused. |
| 343 | */ |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 344 | bool cacheable; |
Romain Guy | aa6c24c | 2011-04-28 18:40:04 -0700 | [diff] [blame] | 345 | |
| 346 | /** |
Chris Craik | 8a226d2 | 2014-09-08 16:40:21 -0700 | [diff] [blame^] | 347 | * Denotes whether the layer is a DisplayList, or Texture layer. |
Romain Guy | aa6c24c | 2011-04-28 18:40:04 -0700 | [diff] [blame] | 348 | */ |
Chris Craik | 8a226d2 | 2014-09-08 16:40:21 -0700 | [diff] [blame^] | 349 | const Type type; |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 350 | |
| 351 | /** |
Romain Guy | 7c25aab | 2012-10-18 15:05:02 -0700 | [diff] [blame] | 352 | * When set to true, this layer is dirty and should be cleared |
| 353 | * before any rendering occurs. |
| 354 | */ |
| 355 | bool dirty; |
| 356 | |
| 357 | /** |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 358 | * Indicates the render target. |
| 359 | */ |
| 360 | GLenum renderTarget; |
| 361 | |
| 362 | /** |
| 363 | * Color filter used to draw this layer. Optional. |
| 364 | */ |
Derek Sollenberger | 76d3a1b | 2013-12-10 12:28:58 -0500 | [diff] [blame] | 365 | SkColorFilter* colorFilter; |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 366 | |
| 367 | /** |
Chris Craik | 9757ac0 | 2014-02-25 18:50:17 -0800 | [diff] [blame] | 368 | * Indicates raster data backing the layer is scaled, requiring filtration. |
| 369 | */ |
| 370 | bool forceFilter; |
| 371 | |
| 372 | /** |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 373 | * Opacity of the layer. |
| 374 | */ |
| 375 | int alpha; |
Chris Craik | 9757ac0 | 2014-02-25 18:50:17 -0800 | [diff] [blame] | 376 | |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 377 | /** |
| 378 | * Blending mode of the layer. |
| 379 | */ |
| 380 | SkXfermode::Mode mode; |
Romain Guy | aa6c24c | 2011-04-28 18:40:04 -0700 | [diff] [blame] | 381 | |
| 382 | /** |
| 383 | * Optional texture coordinates transform. |
| 384 | */ |
| 385 | mat4 texTransform; |
Romain Guy | 8f0095c | 2011-05-02 17:24:22 -0700 | [diff] [blame] | 386 | |
Romain Guy | 302a9df | 2011-08-16 13:55:02 -0700 | [diff] [blame] | 387 | /** |
| 388 | * Optional transform. |
| 389 | */ |
| 390 | mat4 transform; |
| 391 | |
Romain Guy | 96885eb | 2013-03-26 15:05:58 -0700 | [diff] [blame] | 392 | /** |
Chris Craik | 69e5adf | 2014-08-14 13:34:01 -0700 | [diff] [blame] | 393 | * Cached transform of layer in window, updated only on creation / resize |
| 394 | */ |
| 395 | mat4 cachedInvTransformInWindow; |
| 396 | bool rendererLightPosDirty; |
| 397 | |
| 398 | /** |
Romain Guy | 96885eb | 2013-03-26 15:05:58 -0700 | [diff] [blame] | 399 | * Used to defer display lists when the layer is updated with a |
| 400 | * display list. |
| 401 | */ |
| 402 | DeferredDisplayList* deferredList; |
| 403 | |
Chris Craik | 3f085429 | 2014-04-15 16:18:08 -0700 | [diff] [blame] | 404 | /** |
| 405 | * This convex path should be used to mask the layer's draw to the screen. |
| 406 | * |
| 407 | * Data not owned/managed by layer object. |
| 408 | */ |
| 409 | const SkPath* convexMask; |
| 410 | |
Romain Guy | dda5702 | 2010-07-06 11:39:32 -0700 | [diff] [blame] | 411 | }; // struct Layer |
| 412 | |
| 413 | }; // namespace uirenderer |
| 414 | }; // namespace android |
| 415 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 416 | #endif // ANDROID_HWUI_LAYER_H |