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/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp
index 4bdf10e..352ad3f 100644
--- a/gpu/src/GrGpuGL.cpp
+++ b/gpu/src/GrGpuGL.cpp
@@ -1166,15 +1166,25 @@
     }
 }
 
-void GrGpuGL::onClear(GrColor color) {
+void GrGpuGL::onClear(const GrIRect* rect, GrColor color) {
     if (NULL == fCurrDrawState.fRenderTarget) {
         return;
     }
-    flushRenderTarget();
-    if (fHWBounds.fScissorEnabled) {
-        GR_GL(Disable(GR_GL_SCISSOR_TEST));
-        fHWBounds.fScissorEnabled = false;
+    GrIRect r;
+    if (NULL != rect) {
+        // flushScissor expects rect to be clipped to the target.
+        r = *rect;
+        GrIRect rtRect(0, 0, 
+                       fCurrDrawState.fRenderTarget->width(),
+                       fCurrDrawState.fRenderTarget->height());
+        if (r.intersectWith(rtRect)) {
+            rect = &r;
+        } else {
+            return;
+        }
     }
+    this->flushRenderTarget();
+    this->flushScissor(rect);
     GR_GL(ColorMask(GR_GL_TRUE,GR_GL_TRUE,GR_GL_TRUE,GR_GL_TRUE));
     fHWDrawState.fFlagBits &= ~kNoColorWrites_StateBit;
     GR_GL(ClearColor(GrColorUnpackR(color)/255.f,