Moved paint color to vertex colors for batched rects
https://codereview.appspot.com/6620045/
git-svn-id: http://skia.googlecode.com/svn/trunk@5830 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index c69675f..c3c1e89 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -91,6 +91,11 @@
bool appendToPreviousDraw = false;
GrVertexLayout layout = GetRectVertexLayout(srcRects);
+
+ // When we batch rects we store the color at each vertex in order
+ // to allow batching when only the draw color is changing (the usual case)
+ layout |= kColor_VertexLayoutBit;
+
AutoReleaseGeometry geo(this, layout, 4, 0);
if (!geo.succeeded()) {
GrPrintf("Failed to get space for vertices!\n");
@@ -99,7 +104,7 @@
GrMatrix combinedMatrix = drawState->getViewMatrix();
// We go to device space so that matrix changes allow us to concat
// rect draws. When the caller has provided explicit source rects
- // then we don't want to modify the sampler matrices. Otherwise we do
+ // then we don't want to modify the sampler matrices. Otherwise
// we have to account for the view matrix change in the sampler
// matrices.
uint32_t explicitCoordMask = 0;
@@ -118,7 +123,13 @@
combinedMatrix.preConcat(*matrix);
}
- SetRectVertices(rect, &combinedMatrix, srcRects, srcMatrices, layout, geo.vertices());
+ SetRectVertices(rect, &combinedMatrix, srcRects, srcMatrices,
+ this->getDrawState().getColor(), layout, geo.vertices());
+
+ // Now that the paint's color is stored in the vertices set it to
+ // white so that the following code can batch all the rects regardless
+ // of paint color
+ AutoColorRestore acr(this, SK_ColorWHITE);
// we don't want to miss an opportunity to batch rects together
// simply because the clip has changed if the clip doesn't affect