Fixed two bugs in SW-only clip mask generation

http://codereview.appspot.com/6306086/



git-svn-id: http://skia.googlecode.com/svn/trunk@4290 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 132d2ed..7807324 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -233,12 +233,25 @@
     return this->onCreatePath(path);
 }
 
-void GrGpu::clear(const GrIRect* rect, GrColor color) {
+void GrGpu::clear(const GrIRect* rect, 
+                  GrColor color, 
+                  GrRenderTarget* renderTarget) {
+    GrRenderTarget* oldRT = NULL;
+    if (NULL != renderTarget && 
+        renderTarget != this->drawState()->getRenderTarget()) {
+        oldRT = this->drawState()->getRenderTarget();
+        this->drawState()->setRenderTarget(renderTarget);
+    }
+
     if (NULL == this->getDrawState().getRenderTarget()) {
         return;
     }
     this->handleDirtyContext();
     this->onClear(rect, color);
+
+    if (NULL != oldRT) {
+        this->drawState()->setRenderTarget(oldRT);
+    }
 }
 
 void GrGpu::forceRenderTargetFlush() {