Home | History | Annotate | Download | only in hwui
      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 
     17 #ifndef ANDROID_HWUI_OPENGL_RENDERER_H
     18 #define ANDROID_HWUI_OPENGL_RENDERER_H
     19 
     20 #include <GLES2/gl2.h>
     21 #include <GLES2/gl2ext.h>
     22 
     23 #include <SkBitmap.h>
     24 #include <SkMatrix.h>
     25 #include <SkPaint.h>
     26 #include <SkRegion.h>
     27 #include <SkShader.h>
     28 #include <SkXfermode.h>
     29 
     30 #include <utils/Functor.h>
     31 #include <utils/RefBase.h>
     32 #include <utils/SortedVector.h>
     33 #include <utils/Vector.h>
     34 
     35 #include <cutils/compiler.h>
     36 
     37 #include "Debug.h"
     38 #include "Extensions.h"
     39 #include "Matrix.h"
     40 #include "Program.h"
     41 #include "Rect.h"
     42 #include "Snapshot.h"
     43 #include "Vertex.h"
     44 #include "SkiaShader.h"
     45 #include "SkiaColorFilter.h"
     46 #include "Caches.h"
     47 
     48 namespace android {
     49 namespace uirenderer {
     50 
     51 ///////////////////////////////////////////////////////////////////////////////
     52 // Renderer
     53 ///////////////////////////////////////////////////////////////////////////////
     54 
     55 class DisplayList;
     56 
     57 /**
     58  * OpenGL renderer used to draw accelerated 2D graphics. The API is a
     59  * simplified version of Skia's Canvas API.
     60  */
     61 class OpenGLRenderer {
     62 public:
     63     ANDROID_API OpenGLRenderer();
     64     virtual ~OpenGLRenderer();
     65 
     66     virtual bool isDeferred();
     67 
     68     virtual void setViewport(int width, int height);
     69 
     70     ANDROID_API int prepare(bool opaque);
     71     virtual int prepareDirty(float left, float top, float right, float bottom, bool opaque);
     72     virtual void finish();
     73 
     74     // These two calls must not be recorded in display lists
     75     virtual void interrupt();
     76     virtual void resume();
     77 
     78     ANDROID_API status_t invokeFunctors(Rect& dirty);
     79     ANDROID_API void detachFunctor(Functor* functor);
     80     ANDROID_API void attachFunctor(Functor* functor);
     81     virtual status_t callDrawGLFunction(Functor* functor, Rect& dirty);
     82 
     83     ANDROID_API int getSaveCount() const;
     84     virtual int save(int flags);
     85     virtual void restore();
     86     virtual void restoreToCount(int saveCount);
     87 
     88     virtual int saveLayer(float left, float top, float right, float bottom,
     89             SkPaint* p, int flags);
     90     virtual int saveLayerAlpha(float left, float top, float right, float bottom,
     91             int alpha, int flags);
     92 
     93     void setAlpha(float alpha) {
     94         mSnapshot->alpha = alpha;
     95     }
     96 
     97     virtual void translate(float dx, float dy);
     98     virtual void rotate(float degrees);
     99     virtual void scale(float sx, float sy);
    100     virtual void skew(float sx, float sy);
    101 
    102     ANDROID_API void getMatrix(SkMatrix* matrix);
    103     virtual void setMatrix(SkMatrix* matrix);
    104     virtual void concatMatrix(SkMatrix* matrix);
    105 
    106     ANDROID_API const Rect& getClipBounds();
    107     ANDROID_API bool quickReject(float left, float top, float right, float bottom);
    108     virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
    109     virtual Rect* getClipRect();
    110 
    111     virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags,
    112             uint32_t level = 0);
    113     virtual void outputDisplayList(DisplayList* displayList, uint32_t level = 0);
    114     virtual status_t drawLayer(Layer* layer, float x, float y, SkPaint* paint);
    115     virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
    116     virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
    117     virtual status_t drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
    118             float srcRight, float srcBottom, float dstLeft, float dstTop,
    119             float dstRight, float dstBottom, SkPaint* paint);
    120     virtual status_t drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint);
    121     virtual status_t drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
    122             float* vertices, int* colors, SkPaint* paint);
    123     virtual status_t drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
    124             const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
    125             float left, float top, float right, float bottom, SkPaint* paint);
    126     virtual status_t drawColor(int color, SkXfermode::Mode mode);
    127     virtual status_t drawRect(float left, float top, float right, float bottom, SkPaint* paint);
    128     virtual status_t drawRoundRect(float left, float top, float right, float bottom,
    129             float rx, float ry, SkPaint* paint);
    130     virtual status_t drawCircle(float x, float y, float radius, SkPaint* paint);
    131     virtual status_t drawOval(float left, float top, float right, float bottom, SkPaint* paint);
    132     virtual status_t drawArc(float left, float top, float right, float bottom,
    133             float startAngle, float sweepAngle, bool useCenter, SkPaint* paint);
    134     virtual status_t drawPath(SkPath* path, SkPaint* paint);
    135     virtual status_t drawLines(float* points, int count, SkPaint* paint);
    136     virtual status_t drawPoints(float* points, int count, SkPaint* paint);
    137     virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y,
    138             SkPaint* paint, float length = -1.0f);
    139     virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
    140             float hOffset, float vOffset, SkPaint* paint);
    141     virtual status_t drawPosText(const char* text, int bytesCount, int count,
    142             const float* positions, SkPaint* paint);
    143 
    144     virtual void resetShader();
    145     virtual void setupShader(SkiaShader* shader);
    146 
    147     virtual void resetColorFilter();
    148     virtual void setupColorFilter(SkiaColorFilter* filter);
    149 
    150     virtual void resetShadow();
    151     virtual void setupShadow(float radius, float dx, float dy, int color);
    152 
    153     virtual void resetPaintFilter();
    154     virtual void setupPaintFilter(int clearBits, int setBits);
    155 
    156     SkPaint* filterPaint(SkPaint* paint);
    157 
    158     ANDROID_API static uint32_t getStencilSize();
    159 
    160     void startMark(const char* name) const;
    161     void endMark() const;
    162 
    163 protected:
    164     /**
    165      * Compose the layer defined in the current snapshot with the layer
    166      * defined by the previous snapshot.
    167      *
    168      * The current snapshot *must* be a layer (flag kFlagIsLayer set.)
    169      *
    170      * @param curent The current snapshot containing the layer to compose
    171      * @param previous The previous snapshot to compose the current layer with
    172      */
    173     virtual void composeLayer(sp<Snapshot> current, sp<Snapshot> previous);
    174 
    175     /**
    176      * Marks the specified region as dirty at the specified bounds.
    177      */
    178     void dirtyLayerUnchecked(Rect& bounds, Region* region);
    179 
    180     /**
    181      * Returns the current snapshot.
    182      */
    183     sp<Snapshot> getSnapshot() {
    184         return mSnapshot;
    185     }
    186 
    187     /**
    188      * Returns the region of the current layer.
    189      */
    190     virtual Region* getRegion() {
    191         return mSnapshot->region;
    192     }
    193 
    194     /**
    195      * Indicates whether rendering is currently targeted at a layer.
    196      */
    197     virtual bool hasLayer() {
    198         return (mSnapshot->flags & Snapshot::kFlagFboTarget) && mSnapshot->region;
    199     }
    200 
    201     /**
    202      * Returns the name of the FBO this renderer is rendering into.
    203      */
    204     virtual GLint getTargetFbo() {
    205         return 0;
    206     }
    207 
    208     /**
    209      * Renders the specified layer as a textured quad.
    210      *
    211      * @param layer The layer to render
    212      * @param rect The bounds of the layer
    213      */
    214     void drawTextureLayer(Layer* layer, const Rect& rect);
    215 
    216 private:
    217     /**
    218      * Ensures the state of the renderer is the same as the state of
    219      * the GL context.
    220      */
    221     void syncState();
    222 
    223     /**
    224      * Saves the current state of the renderer as a new snapshot.
    225      * The new snapshot is saved in mSnapshot and the previous snapshot
    226      * is linked from mSnapshot->previous.
    227      *
    228      * @param flags The save flags; see SkCanvas for more information
    229      *
    230      * @return The new save count. This value can be passed to #restoreToCount()
    231      */
    232     int saveSnapshot(int flags);
    233 
    234     /**
    235      * Restores the current snapshot; mSnapshot becomes mSnapshot->previous.
    236      *
    237      * @return True if the clip was modified.
    238      */
    239     bool restoreSnapshot();
    240 
    241     /**
    242      * Sets the clipping rectangle using glScissor. The clip is defined by
    243      * the current snapshot's clipRect member.
    244      */
    245     void setScissorFromClip();
    246 
    247     /**
    248      * Creates a new layer stored in the specified snapshot.
    249      *
    250      * @param snapshot The snapshot associated with the new layer
    251      * @param left The left coordinate of the layer
    252      * @param top The top coordinate of the layer
    253      * @param right The right coordinate of the layer
    254      * @param bottom The bottom coordinate of the layer
    255      * @param alpha The translucency of the layer
    256      * @param mode The blending mode of the layer
    257      * @param flags The layer save flags
    258      * @param previousFbo The name of the current framebuffer
    259      *
    260      * @return True if the layer was successfully created, false otherwise
    261      */
    262     bool createLayer(sp<Snapshot> snapshot, float left, float top, float right, float bottom,
    263             int alpha, SkXfermode::Mode mode, int flags, GLuint previousFbo);
    264 
    265     /**
    266      * Creates a new layer stored in the specified snapshot as an FBO.
    267      *
    268      * @param layer The layer to store as an FBO
    269      * @param snapshot The snapshot associated with the new layer
    270      * @param bounds The bounds of the layer
    271      * @param previousFbo The name of the current framebuffer
    272      */
    273     bool createFboLayer(Layer* layer, Rect& bounds, sp<Snapshot> snapshot,
    274             GLuint previousFbo);
    275 
    276     /**
    277      * Compose the specified layer as a region.
    278      *
    279      * @param layer The layer to compose
    280      * @param rect The layer's bounds
    281      */
    282     void composeLayerRegion(Layer* layer, const Rect& rect);
    283 
    284     /**
    285      * Compose the specified layer as a simple rectangle.
    286      *
    287      * @param layer The layer to compose
    288      * @param rect The layer's bounds
    289      * @param swap If true, the source and destination are swapped
    290      */
    291     void composeLayerRect(Layer* layer, const Rect& rect, bool swap = false);
    292 
    293     /**
    294      * Clears all the regions corresponding to the current list of layers.
    295      * This method MUST be invoked before any drawing operation.
    296      */
    297     void clearLayerRegions();
    298 
    299     /**
    300      * Mark the layer as dirty at the specified coordinates. The coordinates
    301      * are transformed with the supplied matrix.
    302      */
    303     void dirtyLayer(const float left, const float top,
    304             const float right, const float bottom, const mat4 transform);
    305 
    306     /**
    307      * Mark the layer as dirty at the specified coordinates.
    308      */
    309     void dirtyLayer(const float left, const float top,
    310             const float right, const float bottom);
    311 
    312     /**
    313      * Draws a colored rectangle with the specified color. The specified coordinates
    314      * are transformed by the current snapshot's transform matrix.
    315      *
    316      * @param left The left coordinate of the rectangle
    317      * @param top The top coordinate of the rectangle
    318      * @param right The right coordinate of the rectangle
    319      * @param bottom The bottom coordinate of the rectangle
    320      * @param color The rectangle's ARGB color, defined as a packed 32 bits word
    321      * @param mode The Skia xfermode to use
    322      * @param ignoreTransform True if the current transform should be ignored
    323      * @param ignoreBlending True if the blending is set by the caller
    324      */
    325     void drawColorRect(float left, float top, float right, float bottom,
    326             int color, SkXfermode::Mode mode, bool ignoreTransform = false);
    327 
    328     /**
    329      * Draws the shape represented by the specified path texture.
    330      * This method invokes drawPathTexture() but takes into account
    331      * the extra left/top offset and the texture offset to correctly
    332      * position the final shape.
    333      *
    334      * @param left The left coordinate of the shape to render
    335      * @param top The top coordinate of the shape to render
    336      * @param texture The texture reprsenting the shape
    337      * @param paint The paint to draw the shape with
    338      */
    339     status_t drawShape(float left, float top, const PathTexture* texture, SkPaint* paint);
    340 
    341     /**
    342      * Renders the rect defined by the specified bounds as a shape.
    343      * This will render the rect using a path texture, which is used to render
    344      * rects with stroke effects.
    345      *
    346      * @param left The left coordinate of the rect to draw
    347      * @param top The top coordinate of the rect to draw
    348      * @param right The right coordinate of the rect to draw
    349      * @param bottom The bottom coordinate of the rect to draw
    350      * @param p The paint to draw the rect with
    351      */
    352     status_t drawRectAsShape(float left, float top, float right, float bottom, SkPaint* p);
    353 
    354     /**
    355      * Draws the specified texture as an alpha bitmap. Alpha bitmaps obey
    356      * different compositing rules.
    357      *
    358      * @param texture The texture to draw with
    359      * @param left The x coordinate of the bitmap
    360      * @param top The y coordinate of the bitmap
    361      * @param paint The paint to render with
    362      */
    363     void drawAlphaBitmap(Texture* texture, float left, float top, SkPaint* paint);
    364 
    365     /**
    366      * Renders the rect defined by the specified bounds as an anti-aliased rect.
    367      *
    368      * @param left The left coordinate of the rect to draw
    369      * @param top The top coordinate of the rect to draw
    370      * @param right The right coordinate of the rect to draw
    371      * @param bottom The bottom coordinate of the rect to draw
    372      * @param color The color of the rect
    373      * @param mode The blending mode to draw the rect
    374      */
    375     void drawAARect(float left, float top, float right, float bottom,
    376             int color, SkXfermode::Mode mode);
    377 
    378     /**
    379      * Draws a textured rectangle with the specified texture. The specified coordinates
    380      * are transformed by the current snapshot's transform matrix.
    381      *
    382      * @param left The left coordinate of the rectangle
    383      * @param top The top coordinate of the rectangle
    384      * @param right The right coordinate of the rectangle
    385      * @param bottom The bottom coordinate of the rectangle
    386      * @param texture The texture name to map onto the rectangle
    387      * @param alpha An additional translucency parameter, between 0.0f and 1.0f
    388      * @param mode The blending mode
    389      * @param blend True if the texture contains an alpha channel
    390      */
    391     void drawTextureRect(float left, float top, float right, float bottom, GLuint texture,
    392             float alpha, SkXfermode::Mode mode, bool blend);
    393 
    394     /**
    395      * Draws a textured rectangle with the specified texture. The specified coordinates
    396      * are transformed by the current snapshot's transform matrix.
    397      *
    398      * @param left The left coordinate of the rectangle
    399      * @param top The top coordinate of the rectangle
    400      * @param right The right coordinate of the rectangle
    401      * @param bottom The bottom coordinate of the rectangle
    402      * @param texture The texture to use
    403      * @param paint The paint containing the alpha, blending mode, etc.
    404      */
    405     void drawTextureRect(float left, float top, float right, float bottom,
    406             Texture* texture, SkPaint* paint);
    407 
    408     /**
    409      * Draws a textured mesh with the specified texture. If the indices are omitted,
    410      * the mesh is drawn as a simple quad. The mesh pointers become offsets when a
    411      * VBO is bound.
    412      *
    413      * @param left The left coordinate of the rectangle
    414      * @param top The top coordinate of the rectangle
    415      * @param right The right coordinate of the rectangle
    416      * @param bottom The bottom coordinate of the rectangle
    417      * @param texture The texture name to map onto the rectangle
    418      * @param alpha An additional translucency parameter, between 0.0f and 1.0f
    419      * @param mode The blending mode
    420      * @param blend True if the texture contains an alpha channel
    421      * @param vertices The vertices that define the mesh
    422      * @param texCoords The texture coordinates of each vertex
    423      * @param elementsCount The number of elements in the mesh, required by indices
    424      * @param swapSrcDst Whether or not the src and dst blending operations should be swapped
    425      * @param ignoreTransform True if the current transform should be ignored
    426      * @param vbo The VBO used to draw the mesh
    427      * @param ignoreScale True if the model view matrix should not be scaled
    428      * @param dirty True if calling this method should dirty the current layer
    429      */
    430     void drawTextureMesh(float left, float top, float right, float bottom, GLuint texture,
    431             float alpha, SkXfermode::Mode mode, bool blend,
    432             GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
    433             bool swapSrcDst = false, bool ignoreTransform = false, GLuint vbo = 0,
    434             bool ignoreScale = false, bool dirty = true);
    435 
    436     /**
    437      * Draws text underline and strike-through if needed.
    438      *
    439      * @param text The text to decor
    440      * @param bytesCount The number of bytes in the text
    441      * @param length The length in pixels of the text, can be <= 0.0f to force a measurement
    442      * @param x The x coordinate where the text will be drawn
    443      * @param y The y coordinate where the text will be drawn
    444      * @param paint The paint to draw the text with
    445      */
    446     void drawTextDecorations(const char* text, int bytesCount, float length,
    447             float x, float y, SkPaint* paint);
    448 
    449     /**
    450      * Draws a path texture. Path textures are alpha8 bitmaps that need special
    451      * compositing to apply colors/filters/etc.
    452      *
    453      * @param texture The texture to render
    454      * @param x The x coordinate where the texture will be drawn
    455      * @param y The y coordinate where the texture will be drawn
    456      * @param paint The paint to draw the texture with
    457      */
    458     void drawPathTexture(const PathTexture* texture, float x, float y, SkPaint* paint);
    459 
    460     /**
    461      * Resets the texture coordinates stored in mMeshVertices. Setting the values
    462      * back to default is achieved by calling:
    463      *
    464      * resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f);
    465      *
    466      * @param u1 The left coordinate of the texture
    467      * @param v1 The bottom coordinate of the texture
    468      * @param u2 The right coordinate of the texture
    469      * @param v2 The top coordinate of the texture
    470      */
    471     void resetDrawTextureTexCoords(float u1, float v1, float u2, float v2);
    472 
    473     /**
    474      * Gets the alpha and xfermode out of a paint object. If the paint is null
    475      * alpha will be 255 and the xfermode will be SRC_OVER.
    476      *
    477      * @param paint The paint to extract values from
    478      * @param alpha Where to store the resulting alpha
    479      * @param mode Where to store the resulting xfermode
    480      */
    481     inline void getAlphaAndMode(SkPaint* paint, int* alpha, SkXfermode::Mode* mode);
    482 
    483     /**
    484      * Binds the specified texture. The texture unit must have been selected
    485      * prior to calling this method.
    486      */
    487     inline void bindTexture(GLuint texture) {
    488         glBindTexture(GL_TEXTURE_2D, texture);
    489     }
    490 
    491     /**
    492      * Binds the specified EGLImage texture. The texture unit must have been selected
    493      * prior to calling this method.
    494      */
    495     inline void bindExternalTexture(GLuint texture) {
    496         glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture);
    497     }
    498 
    499     /**
    500      * Enable or disable blending as necessary. This function sets the appropriate
    501      * blend function based on the specified xfermode.
    502      */
    503     inline void chooseBlending(bool blend, SkXfermode::Mode mode, ProgramDescription& description,
    504             bool swapSrcDst = false);
    505 
    506     /**
    507      * Safely retrieves the mode from the specified xfermode. If the specified
    508      * xfermode is null, the mode is assumed to be SkXfermode::kSrcOver_Mode.
    509      */
    510     inline SkXfermode::Mode getXfermode(SkXfermode* mode);
    511 
    512     /**
    513      * Use the specified program with the current GL context. If the program is already
    514      * in use, it will not be bound again. If it is not in use, the current program is
    515      * marked unused and the specified program becomes used and becomes the new
    516      * current program.
    517      *
    518      * @param program The program to use
    519      *
    520      * @return true If the specified program was already in use, false otherwise.
    521      */
    522     inline bool useProgram(Program* program);
    523 
    524     /**
    525      * Invoked before any drawing operation. This sets required state.
    526      */
    527     void setupDraw(bool clear = true);
    528     /**
    529      * Various methods to setup OpenGL rendering.
    530      */
    531     void setupDrawWithTexture(bool isAlpha8 = false);
    532     void setupDrawWithExternalTexture();
    533     void setupDrawNoTexture();
    534     void setupDrawAALine();
    535     void setupDrawPoint(float pointSize);
    536     void setupDrawColor(int color);
    537     void setupDrawColor(int color, int alpha);
    538     void setupDrawColor(float r, float g, float b, float a);
    539     void setupDrawAlpha8Color(int color, int alpha);
    540     void setupDrawAlpha8Color(float r, float g, float b, float a);
    541     void setupDrawShader();
    542     void setupDrawColorFilter();
    543     void setupDrawBlending(SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
    544             bool swapSrcDst = false);
    545     void setupDrawBlending(bool blend = true, SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
    546             bool swapSrcDst = false);
    547     void setupDrawProgram();
    548     void setupDrawDirtyRegionsDisabled();
    549     void setupDrawModelViewIdentity(bool offset = false);
    550     void setupDrawModelView(float left, float top, float right, float bottom,
    551             bool ignoreTransform = false, bool ignoreModelView = false);
    552     void setupDrawModelViewTranslate(float left, float top, float right, float bottom,
    553             bool ignoreTransform = false);
    554     void setupDrawPointUniforms();
    555     void setupDrawColorUniforms();
    556     void setupDrawPureColorUniforms();
    557     void setupDrawShaderIdentityUniforms();
    558     void setupDrawShaderUniforms(bool ignoreTransform = false);
    559     void setupDrawColorFilterUniforms();
    560     void setupDrawSimpleMesh();
    561     void setupDrawTexture(GLuint texture);
    562     void setupDrawExternalTexture(GLuint texture);
    563     void setupDrawTextureTransform();
    564     void setupDrawTextureTransformUniforms(mat4& transform);
    565     void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords = NULL, GLuint vbo = 0);
    566     void setupDrawMeshIndices(GLvoid* vertices, GLvoid* texCoords);
    567     void setupDrawVertices(GLvoid* vertices);
    568     void setupDrawAALine(GLvoid* vertices, GLvoid* distanceCoords, GLvoid* lengthCoords,
    569             float strokeWidth, int& widthSlot, int& lengthSlot);
    570     void finishDrawAALine(const int widthSlot, const int lengthSlot);
    571     void finishDrawTexture();
    572     void accountForClear(SkXfermode::Mode mode);
    573 
    574     void drawRegionRects(const Region& region);
    575 
    576     /**
    577      * Should be invoked every time the glScissor is modified.
    578      */
    579     inline void dirtyClip() {
    580         mDirtyClip = true;
    581     }
    582 
    583     // Dimensions of the drawing surface
    584     int mWidth, mHeight;
    585 
    586     // Matrix used for ortho projection in shaders
    587     mat4 mOrthoMatrix;
    588 
    589     // Model-view matrix used to position/size objects
    590     mat4 mModelView;
    591 
    592     // Number of saved states
    593     int mSaveCount;
    594     // Base state
    595     sp<Snapshot> mFirstSnapshot;
    596     // Current state
    597     sp<Snapshot> mSnapshot;
    598 
    599     // Shaders
    600     SkiaShader* mShader;
    601 
    602     // Color filters
    603     SkiaColorFilter* mColorFilter;
    604 
    605     // Used to draw textured quads
    606     TextureVertex mMeshVertices[4];
    607 
    608     // Drop shadow
    609     bool mHasShadow;
    610     float mShadowRadius;
    611     float mShadowDx;
    612     float mShadowDy;
    613     int mShadowColor;
    614 
    615     // Draw filters
    616     bool mHasDrawFilter;
    617     int mPaintFilterClearBits;
    618     int mPaintFilterSetBits;
    619     SkPaint mFilteredPaint;
    620 
    621     // Various caches
    622     Caches& mCaches;
    623 
    624     // List of rectangles to clear after saveLayer() is invoked
    625     Vector<Rect*> mLayers;
    626     // List of functors to invoke after a frame is drawn
    627     SortedVector<Functor*> mFunctors;
    628 
    629     // Indentity matrix
    630     const mat4 mIdentity;
    631 
    632     // Indicates whether the clip must be restored
    633     bool mDirtyClip;
    634 
    635     // The following fields are used to setup drawing
    636     // Used to describe the shaders to generate
    637     ProgramDescription mDescription;
    638     // Color description
    639     bool mColorSet;
    640     float mColorA, mColorR, mColorG, mColorB;
    641     // Indicates that the shader should get a color
    642     bool mSetShaderColor;
    643     // Current texture unit
    644     GLuint mTextureUnit;
    645     // Track dirty regions, true by default
    646     bool mTrackDirtyRegions;
    647 
    648     friend class DisplayListRenderer;
    649 
    650 }; // class OpenGLRenderer
    651 
    652 }; // namespace uirenderer
    653 }; // namespace android
    654 
    655 #endif // ANDROID_HWUI_OPENGL_RENDERER_H
    656