aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-11 12:53:50 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-11 12:53:50 +0000
commit8fff356c8505f2ac78e1fc9dc17c1192e3a608e4 (patch)
tree682b964feb1a980336e095deab3b0ee8cee278a5 /src/gpu
parentd82f3fae9255e852f44a4ec185df67cc200da6f8 (diff)
Made clip mask cache reuse depend on mask size/bounds (instead of render target size)
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrClipMaskManager.cpp16
-rw-r--r--src/gpu/GrClipMaskManager.h42
2 files changed, 13 insertions, 45 deletions
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index f8c43b0491..7672f5a599 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -394,12 +394,6 @@ bool GrClipMaskManager::createAlphaClipMask(GrGpu* gpu,
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 @@ bool GrClipMaskManager::createAlphaClipMask(GrGpu* gpu,
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 @@ bool GrClipMaskManager::createAlphaClipMask(GrGpu* gpu,
}
}
- 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 65205679d5..9c72552cf1 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -68,8 +68,9 @@ public:
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 @@ public:
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 @@ public:
GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
- back->fLastWidth = width;
- back->fLastHeight = height;
back->fLastClip = clip;
SkSafeRef(mask);
back->fLastMask.reset(mask);
@@ -127,30 +125,6 @@ public:
}
}
- 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 @@ private:
}
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