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