Glop support for indexed quads

bug:19014311
Change-Id: If35a873421b41cc4508b0d8ac1b4d900c9bb3717
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 5a0cc1e..61cd16f 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1581,7 +1581,12 @@
         setStencilFromClip();
     }
     mRenderState.render(glop);
-    dirtyLayer(glop.bounds.left, glop.bounds.top, glop.bounds.right, glop.bounds.bottom);
+
+    if (!mRenderState.stencil().isWriteEnabled()) {
+        // TODO: specify more clearly when a draw should dirty the layer.
+        // is writing to the stencil the only time we should ignore this?
+        dirtyLayer(glop.bounds.left, glop.bounds.top, glop.bounds.right, glop.bounds.bottom);
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -2353,13 +2358,12 @@
         aBuilder.setMeshVertexBuffer(vertexBuffer, shadowInterp)
                 .setTransform(currentSnapshot()->getOrthoMatrix(), *currentTransform(), fudgeOffset)
                 .setModelViewOffsetRect(translateX, translateY, vertexBuffer.getBounds())
-                .setPaint(paint, currentSnapshot()->alpha)
+                .setPaint(*paint, currentSnapshot()->alpha)
                 .build();
         renderGlop(glop);
         return;
     }
 
-
     const VertexBuffer::MeshFeatureFlags meshFeatureFlags = vertexBuffer.getMeshFeatureFlags();
     Rect bounds(vertexBuffer.getBounds());
     bounds.translate(translateX, translateY);
@@ -3218,12 +3222,6 @@
         return;
     }
 
-    int color = paint->getColor();
-    // If a shader is set, preserve only the alpha
-    if (getShader(paint)) {
-        color |= 0x00ffffff;
-    }
-
     float left = FLT_MAX;
     float top = FLT_MAX;
     float right = FLT_MIN;
@@ -3253,6 +3251,25 @@
         return;
     }
 
+    if (!paint->getShader() && !currentSnapshot()->roundRectClipState) {
+        const Matrix4& transform = ignoreTransform ? Matrix4::identity() : *currentTransform();
+        Glop glop;
+        GlopBuilder aBuilder(mRenderState, mCaches, &glop);
+        aBuilder.setMeshIndexedQuads(&mesh[0], count / 4)
+                .setTransform(currentSnapshot()->getOrthoMatrix(), transform, false)
+                .setModelViewOffsetRect(0, 0, Rect(left, top, right, bottom))
+                .setPaint(*paint, currentSnapshot()->alpha)
+                .build();
+        renderGlop(glop);
+        return;
+    }
+
+    int color = paint->getColor();
+    // If a shader is set, preserve only the alpha
+    if (getShader(paint)) {
+        color |= 0x00ffffff;
+    }
+
     setupDraw();
     setupDrawNoTexture();
     setupDrawColor(color, ((color >> 24) & 0xFF) * currentSnapshot()->alpha);
@@ -3286,7 +3303,7 @@
         aBuilder.setMeshUnitQuad()
                 .setTransform(currentSnapshot()->getOrthoMatrix(), transform, false)
                 .setModelViewMapUnitToRect(Rect(left, top, right, bottom))
-                .setPaint(paint, currentSnapshot()->alpha)
+                .setPaint(*paint, currentSnapshot()->alpha)
                 .build();
         renderGlop(glop);
         return;