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