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