Added cache to gpu AA clipping
http://codereview.appspot.com/6160046/
git-svn-id: http://skia.googlecode.com/svn/trunk@3828 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index a1ac0ab..ce0f620 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -15,7 +15,6 @@
//#define GR_AA_CLIP 1
-
////////////////////////////////////////////////////////////////////////////////
void ScissoringSettings::setupScissoring(GrGpu* gpu) {
if (!fEnableScissoring) {
@@ -366,10 +365,17 @@
GrRenderTarget* rt = origDrawState->getRenderTarget();
GrAssert(NULL != rt);
+ if (fAACache.canReuse(clipIn, rt->width(), rt->height())) {
+ *result = fAACache.getLastMask();
+ *resultBounds = fAACache.getLastBound();
+ return true;
+ }
+
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;
@@ -411,8 +417,9 @@
GrTexture* accum = gpu->createTexture(desc, NULL, 0);
GrTexture* temp = gpu->createTexture(desc, NULL, 0);
if (NULL == accum || NULL == temp) {
- // TODO: free up accum & temp here!
fClipMaskInAlpha = false;
+ SkSafeUnref(accum);
+ SkSafeUnref(temp);
return false;
}
@@ -505,8 +512,11 @@
}
}
+ fAACache.set(clipIn, rt->width(), rt->height(), accum, bounds);
*result = accum;
*resultBounds = bounds;
+ SkSafeUnref(accum); // fAACache still has a ref to accum
+ SkSafeUnref(temp);
return true;
}