Make Gr clear take a rect for a partial-clear
Review URL: http://codereview.appspot.com/4442093/
git-svn-id: http://skia.googlecode.com/svn/trunk@1203 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrInOrderDrawBuffer.cpp b/gpu/src/GrInOrderDrawBuffer.cpp
index 7b769fe..2ea12e1 100644
--- a/gpu/src/GrInOrderDrawBuffer.cpp
+++ b/gpu/src/GrInOrderDrawBuffer.cpp
@@ -150,7 +150,12 @@
GrAssert(0 == lastDraw.fIndexCount % 6);
GrAssert(0 == lastDraw.fStartIndex);
- appendToPreviousDraw = lastDraw.fVertexBuffer == fCurrPoolVertexBuffer &&
+ bool clearSinceLastDraw =
+ fClears.count() &&
+ fClears.back().fBeforeDrawIdx == fDraws.count();
+
+ appendToPreviousDraw = !clearSinceLastDraw &&
+ lastDraw.fVertexBuffer == fCurrPoolVertexBuffer &&
(fCurrQuad * 4 + lastDraw.fStartVertex) == fCurrPoolStartVertex;
if (appendToPreviousDraw) {
lastDraw.fVertexCount += 4;
@@ -288,14 +293,21 @@
draw.fIndexBuffer = NULL;
}
-void GrInOrderDrawBuffer::clear(GrColor color) {
+void GrInOrderDrawBuffer::clear(const GrIRect* rect, GrColor color) {
+ GrIRect r;
+ if (NULL == rect) {
+ // We could do something smart and remove previous draws and clears to
+ // the current render target. If we get that smart we have to make sure
+ // those draws aren't read before this clear (render-to-texture).
+ r.setLTRB(0, 0,
+ this->getRenderTarget()->width(),
+ this->getRenderTarget()->height());
+ rect = &r;
+ }
Clear& clr = fClears.push_back();
clr.fColor = color;
clr.fBeforeDrawIdx = fDraws.count();
-
- // We could do something smart and remove previous draws and clears to the
- // current render target. If we get that smart we have to make sure those
- // draws aren't read before this clear (render-to-texture).
+ clr.fRect = *rect;
}
void GrInOrderDrawBuffer::reset() {
@@ -354,7 +366,7 @@
for (int i = 0; i < numDraws; ++i) {
while (currClear < fClears.count() &&
i == fClears[currClear].fBeforeDrawIdx) {
- target->clear(fClears[currClear].fColor);
+ target->clear(&fClears[currClear].fRect, fClears[currClear].fColor);
++currClear;
}
@@ -388,7 +400,7 @@
}
while (currClear < fClears.count()) {
GrAssert(fDraws.count() == fClears[currClear].fBeforeDrawIdx);
- target->clear(fClears[currClear].fColor);
+ target->clear(&fClears[currClear].fRect, fClears[currClear].fColor);
++currClear;
}
}