Added getConservativeBound helper function to GrClipData

http://codereview.appspot.com/6454054/



git-svn-id: http://skia.googlecode.com/svn/trunk@4798 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 988cfa7..13d6155 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -512,10 +512,7 @@
     int rtHeight = drawState.getRenderTarget()->height();
 
     GrIRect clip;
-
-    const GrClipData* clipData = target->getClip();
-    GrRect conservativeBounds = clipData->fClipStack->getConservativeBounds();
-    conservativeBounds.roundOut(&clip);
+    target->getClip()->getConservativeBounds(drawState.getRenderTarget(), &clip);
 
     GrVertexLayout layout = GrDrawTarget::kEdge_VertexLayoutBit;
     GrMatrix viewM = drawState.getViewMatrix();
diff --git a/src/gpu/GrClip.cpp b/src/gpu/GrClip.cpp
index ace765f..d75dd26 100644
--- a/src/gpu/GrClip.cpp
+++ b/src/gpu/GrClip.cpp
@@ -9,6 +9,8 @@
 
 
 #include "GrClip.h"
+#include "GrSurface.h"
+#include "GrRect.h"
 
 GrClip::GrClip() 
     : fRequiresAA(false) {
@@ -247,3 +249,14 @@
         fCurIndex = fStack->getElementCount()-1;
     }
 }
+
+///////////////////////////////////////////////////////////////////////////////
+
+void GrClipData::getConservativeBounds(const GrSurface* surface,
+                                       GrIRect* result,
+                                       bool* isIntersectionOfRects) const {
+
+    const GrRect& conservativeBounds = fClipStack->getConservativeBounds();
+    conservativeBounds.roundOut(result);
+}
+
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index a3c8537..ea5a2cd 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -147,16 +147,9 @@
     GrAssert(NULL != rt);
 
     GrIRect bounds;
-    GrIRect rtRect;
-    rtRect.setLTRB(0, 0, rt->width(), rt->height());
+    bool isIntersectionOfRects = false;
 
-
-    GrRect conservativeBounds = clipDataIn->fClipStack->getConservativeBounds();
-
-    conservativeBounds.roundOut(&bounds);
-    if (!bounds.intersect(rtRect)) {
-        bounds.setEmpty();
-    }
+    clipDataIn->getConservativeBounds(rt, &bounds, &isIntersectionOfRects);
     if (bounds.isEmpty()) {
         return false;
     }
@@ -542,22 +535,10 @@
     GrRenderTarget* rt = origDrawState->getRenderTarget();
     GrAssert(NULL != rt);
 
-    GrRect rtRect;
-    rtRect.setLTRB(0, 0,
-                    GrIntToScalar(rt->width()), GrIntToScalar(rt->height()));
-
     // unlike the stencil path the alpha path is not bound to the size of the
     // render target - determine the minimum size required for the mask
-    GrRect bounds = clipDataIn.fClipStack->getConservativeBounds();
-
-    if (!bounds.intersect(rtRect)) {
-        // the mask will be empty in this case
-        GrAssert(false);
-        bounds.setEmpty();
-    }
-
     GrIRect intBounds;
-    bounds.roundOut(&intBounds);
+    clipDataIn.getConservativeBounds(rt, &intBounds);
 
     // need to outset a pixel since the standard bounding box computation
     // path doesn't leave any room for antialiasing (esp. w.r.t. rects)
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 0bf1cab..5b570b4 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -46,10 +46,7 @@
     }
     *pathBounds = GrIRect::MakeWH(rt->width(), rt->height());
 
-    const GrClipData* clipData = target->getClip();
-
-    SkRect conservativeBounds = clipData->fClipStack->getConservativeBounds();
-    conservativeBounds.roundOut(clipBounds);
+    target->getClip()->getConservativeBounds(rt, clipBounds);
     if (!pathBounds->intersect(*clipBounds)) {
         return false;
     }
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index b7ae6c7..d874672 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -436,8 +436,7 @@
     GrIRect* rect = NULL;
     GrIRect clipBounds;
     if (drawState.isClipState()) {
-        GrRect conservativeBounds = fClip->fClipStack->getConservativeBounds();
-        conservativeBounds.roundOut(&clipBounds);
+        fClip->getConservativeBounds(drawState.getRenderTarget(), &clipBounds);
         rect = &clipBounds;
     }
     // This must come after textures are flushed because a texture may need