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/include/GrContext.h b/gpu/include/GrContext.h
index 3112112..214fc05 100644
--- a/gpu/include/GrContext.h
+++ b/gpu/include/GrContext.h
@@ -282,9 +282,11 @@
// Draws
/**
- * Clear the entire render target, ignoring any clips
+ * Clear the entire or rect of the render target, ignoring any clips.
+ * @param rect the rect to clear or the whole thing if rect is NULL.
+ * @param color the color to clear to.
*/
- void clear(GrColor color);
+ void clear(const GrIRect* rect, GrColor color);
/**
* Draw everywhere (respecting the clip) with the paint.
diff --git a/gpu/include/GrDrawTarget.h b/gpu/include/GrDrawTarget.h
index cb36d3c..c971e71 100644
--- a/gpu/include/GrDrawTarget.h
+++ b/gpu/include/GrDrawTarget.h
@@ -731,10 +731,11 @@
}
/**
- * Clear the entire render target. Ignores the clip an all other draw state
- * (blend mode, stages, etc).
+ * Clear the render target. Ignores the clip and all other draw state
+ * (blend mode, stages, etc). Clears the whole thing if rect is NULL,
+ * otherwise just the rect.
*/
- virtual void clear(GrColor color) = 0;
+ virtual void clear(const GrIRect* rect, GrColor color) = 0;
///////////////////////////////////////////////////////////////////////////
diff --git a/gpu/include/GrGpu.h b/gpu/include/GrGpu.h
index 19f3746..590712b 100644
--- a/gpu/include/GrGpu.h
+++ b/gpu/include/GrGpu.h
@@ -263,7 +263,7 @@
virtual void drawNonIndexed(GrPrimitiveType type,
int startVertex,
int vertexCount);
- virtual void clear(GrColor color);
+ virtual void clear(const GrIRect* rect, GrColor color);
/**
* Installs a path renderer that will be used to draw paths that are
@@ -444,8 +444,9 @@
virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size,
bool dynamic) = 0;
- // overridden by API-specific derivated class to perform the clear.
- virtual void onClear(GrColor color) = 0;
+ // overridden by API-specific derivated class to perform the clear and
+ // clearRect. NULL rect means clear whole target.
+ virtual void onClear(const GrIRect* rect, GrColor color) = 0;
// overridden by API-specific derived class to perform the draw call.
virtual void onDrawIndexed(GrPrimitiveType type,
diff --git a/gpu/include/GrInOrderDrawBuffer.h b/gpu/include/GrInOrderDrawBuffer.h
index 03a2f2d..b26cd72 100644
--- a/gpu/include/GrInOrderDrawBuffer.h
+++ b/gpu/include/GrInOrderDrawBuffer.h
@@ -100,7 +100,7 @@
int* vertexCount,
int* indexCount) const;
- virtual void clear(GrColor color);
+ virtual void clear(const GrIRect* rect, GrColor color);
private:
@@ -119,6 +119,7 @@
struct Clear {
int fBeforeDrawIdx;
+ GrIRect fRect;
GrColor fColor;
};
diff --git a/gpu/include/GrRect.h b/gpu/include/GrRect.h
index a9ff6ec..b85574a 100644
--- a/gpu/include/GrRect.h
+++ b/gpu/include/GrRect.h
@@ -76,19 +76,22 @@
/**
* Sets this rect to the intersection with a clip rect. If there is no
- * intersection then this rect will be made empty.
+ * intersection then this rect will be made empty and the function will
+ * return false.
*/
- void intersectWith(const GrIRect& clipRect) {
+ bool intersectWith(const GrIRect& clipRect) {
if (fRight < clipRect.fLeft ||
fLeft > clipRect.fRight ||
fBottom < clipRect.fTop ||
fTop > clipRect.fBottom) {
this->setEmpty();
+ return false;
} else {
fLeft = GrMax(fLeft, clipRect.fLeft);
fRight = GrMin(fRight, clipRect.fRight);
fTop = GrMax(fTop, clipRect.fTop);
fBottom = GrMin(fBottom, clipRect.fBottom);
+ return true;
}
}