@@ -1730,35 +1730,22 @@ status_t OpenGLRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
17301730
17311731status_t OpenGLRenderer::drawBitmapMesh (SkBitmap* bitmap, int meshWidth, int meshHeight,
17321732 float * vertices, int * colors, SkPaint* paint) {
1733- // TODO: Do a quickReject
17341733 if (!vertices || mSnapshot ->isIgnored ()) {
17351734 return DrawGlInfo::kStatusDone ;
17361735 }
17371736
1738- mCaches .activeTexture (0 );
1739- Texture* texture = mCaches .textureCache .get (bitmap);
1740- if (!texture) return DrawGlInfo::kStatusDone ;
1741- const AutoTexture autoCleanup (texture);
1742-
1743- texture->setWrap (GL_CLAMP_TO_EDGE, true );
1744- texture->setFilter (FILTER (paint), true );
1745-
1746- int alpha;
1747- SkXfermode::Mode mode;
1748- getAlphaAndMode (paint, &alpha, &mode);
1749-
1750- const uint32_t count = meshWidth * meshHeight * 6 ;
1751-
1737+ // TODO: We should compute the bounding box when recording the display list
17521738 float left = FLT_MAX;
17531739 float top = FLT_MAX;
17541740 float right = FLT_MIN;
17551741 float bottom = FLT_MIN;
17561742
1757- const bool hasActiveLayer = hasLayer () ;
1743+ const uint32_t count = meshWidth * meshHeight * 6 ;
17581744
17591745 // TODO: Support the colors array
17601746 TextureVertex mesh[count];
17611747 TextureVertex* vertex = mesh;
1748+
17621749 for (int32_t y = 0 ; y < meshHeight; y++) {
17631750 for (int32_t x = 0 ; x < meshWidth; x++) {
17641751 uint32_t i = (y * (meshWidth + 1 ) + x) * 2 ;
@@ -1785,17 +1772,31 @@ status_t OpenGLRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int mes
17851772 TextureVertex::set (vertex++, vertices[cx], vertices[cy], u2, v1);
17861773 TextureVertex::set (vertex++, vertices[dx], vertices[dy], u2, v2);
17871774
1788- if (hasActiveLayer) {
1789- // TODO: This could be optimized to avoid unnecessary ops
1790- left = fminf (left, fminf (vertices[ax], fminf (vertices[bx], vertices[cx])));
1791- top = fminf (top, fminf (vertices[ay], fminf (vertices[by], vertices[cy])));
1792- right = fmaxf (right, fmaxf (vertices[ax], fmaxf (vertices[bx], vertices[cx])));
1793- bottom = fmaxf (bottom, fmaxf (vertices[ay], fmaxf (vertices[by], vertices[cy])));
1794- }
1775+ // TODO: This could be optimized to avoid unnecessary ops
1776+ left = fminf (left, fminf (vertices[ax], fminf (vertices[bx], vertices[cx])));
1777+ top = fminf (top, fminf (vertices[ay], fminf (vertices[by], vertices[cy])));
1778+ right = fmaxf (right, fmaxf (vertices[ax], fmaxf (vertices[bx], vertices[cx])));
1779+ bottom = fmaxf (bottom, fmaxf (vertices[ay], fmaxf (vertices[by], vertices[cy])));
17951780 }
17961781 }
17971782
1798- if (hasActiveLayer) {
1783+ if (quickReject (left, top, right, bottom)) {
1784+ return DrawGlInfo::kStatusDone ;
1785+ }
1786+
1787+ mCaches .activeTexture (0 );
1788+ Texture* texture = mCaches .textureCache .get (bitmap);
1789+ if (!texture) return DrawGlInfo::kStatusDone ;
1790+ const AutoTexture autoCleanup (texture);
1791+
1792+ texture->setWrap (GL_CLAMP_TO_EDGE, true );
1793+ texture->setFilter (FILTER (paint), true );
1794+
1795+ int alpha;
1796+ SkXfermode::Mode mode;
1797+ getAlphaAndMode (paint, &alpha, &mode);
1798+
1799+ if (hasLayer ()) {
17991800 dirtyLayer (left, top, right, bottom, *mSnapshot ->transform );
18001801 }
18011802
0 commit comments