Made clip mask cache reuse depend on mask size/bounds (instead of render target size)

http://codereview.appspot.com/6190067/



git-svn-id: http://skia.googlecode.com/svn/trunk@3903 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index f8c43b0..7672f5a 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -394,12 +394,6 @@
     GrRenderTarget* rt = origDrawState->getRenderTarget();
     GrAssert(NULL != rt);
 
-    if (fAACache.canReuse(clipIn, rt->width(), rt->height())) {
-        *result = fAACache.getLastMask();
-        fAACache.getLastBound(resultBounds);
-        return true;
-    }
-
     GrRect rtRect;
     rtRect.setLTRB(0, 0,
                     GrIntToScalar(rt->width()), GrIntToScalar(rt->height()));
@@ -432,6 +426,14 @@
     GrAssert(SkScalarIsInt(bounds.width()));
     GrAssert(SkScalarIsInt(bounds.height()));
 
+    if (fAACache.canReuse(clipIn, 
+                          SkScalarCeilToInt(bounds.width()),
+                          SkScalarCeilToInt(bounds.height()))) {
+        *result = fAACache.getLastMask();
+        fAACache.getLastBound(resultBounds);
+        return true;
+    }
+
     const GrTextureDesc desc = {
         kRenderTarget_GrTextureFlagBit|kNoStencil_GrTextureFlagBit,
         SkScalarCeilToInt(bounds.width()),
@@ -548,7 +550,7 @@
         }
     }
 
-    fAACache.set(clipIn, rt->width(), rt->height(), accum, bounds);
+    fAACache.set(clipIn, accum, bounds);
     *result = accum;
     *resultBounds = bounds;
     SkSafeUnref(accum);     // fAACache still has a ref to accum
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h
index 6520567..9c72552 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -68,8 +68,9 @@
 
         GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
 
-        if (back->fLastWidth >= width &&
-            back->fLastHeight >= height &&
+        if (back->fLastMask &&
+            back->fLastMask->width() >= width &&
+            back->fLastMask->height() >= height &&
             clip == back->fLastClip) {
             return true;
         }
@@ -77,8 +78,7 @@
         return false;
     }
 
-    void set(const GrClip& clip, int width, int height, 
-             GrTexture* mask, const GrRect& bound) {
+    void set(const GrClip& clip, GrTexture* mask, const GrRect& bound) {
 
         if (fStack.empty()) {
             GrAssert(false);
@@ -87,8 +87,6 @@
 
         GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
 
-        back->fLastWidth = width;
-        back->fLastHeight = height;
         back->fLastClip = clip;
         SkSafeRef(mask);
         back->fLastMask.reset(mask);
@@ -127,30 +125,6 @@
         }
     }
 
-    int getLastWidth() const {
-
-        if (fStack.empty()) {
-            GrAssert(false);
-            return -1;
-        }
-
-        GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
-
-        return back->fLastWidth;
-    }
-
-    int getLastHeight() const {
-
-        if (fStack.empty()) {
-            GrAssert(false);
-            return -1;
-        }
-
-        GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
-
-        return back->fLastHeight;
-    }
-
     void getLastClip(GrClip* clip) const {
 
         if (fStack.empty()) {
@@ -254,19 +228,11 @@
         }
 
         void reset () {
-            fLastWidth = -1;
-            fLastHeight = -1;
             fLastClip.setEmpty();
             fLastMask.reset(NULL);
             fLastBound.setEmpty();
         }
 
-        // fLastWidth & fLastHeight store the render target size used when
-        // creating the mask. They factor into the reuse decision (in canReuse)
-        // TODO: We should probably use the mask's width & height rather than
-        // the render target's width & height for reuse decisions
-        int                     fLastWidth;
-        int                     fLastHeight;
         GrClip                  fLastClip;
         // The mask's width & height values are used in setupDrawStateAAClip to 
         // correctly scale the uvs for geometry drawn with this mask