aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrClipMaskCache.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrClipMaskCache.h')
-rw-r--r--src/gpu/GrClipMaskCache.h48
1 files changed, 23 insertions, 25 deletions
diff --git a/src/gpu/GrClipMaskCache.h b/src/gpu/GrClipMaskCache.h
index 6722d70362..9a091c4b3a 100644
--- a/src/gpu/GrClipMaskCache.h
+++ b/src/gpu/GrClipMaskCache.h
@@ -31,18 +31,22 @@ public:
}
}
- bool canReuse(const SkClipStack& clip, const GrIRect& devBounds) {
+ bool canReuse(int32_t clipGenID, const SkIRect& bounds) {
- if (fStack.empty()) {
- GrAssert(false);
+ SkASSERT(clipGenID != SkClipStack::kWideOpenGenID);
+ SkASSERT(clipGenID != SkClipStack::kEmptyGenID);
+
+ if (SkClipStack::kInvalidGenID == clipGenID) {
return false;
}
GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
+ // We could reuse the mask if bounds is a subset of last bounds. We'd have to communicate
+ // an offset to the caller.
if (back->fLastMask.texture() &&
- back->fLastBound == devBounds &&
- clip == back->fLastClip) {
+ back->fLastBound == bounds &&
+ back->fLastClipGenID == clipGenID) {
return true;
}
@@ -79,17 +83,13 @@ public:
}
}
- void getLastClip(SkClipStack* clip) const {
+ int32_t getLastClipGenID() const {
if (fStack.empty()) {
- GrAssert(false);
- clip->reset();
- return;
+ return SkClipStack::kInvalidGenID;
}
- GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
-
- *clip = back->fLastClip;
+ return ((GrClipStackFrame*) fStack.back())->fLastClipGenID;
}
GrTexture* getLastMask() {
@@ -116,7 +116,7 @@ public:
return back->fLastMask.texture();
}
- void acquireMask(const SkClipStack& clip,
+ void acquireMask(int32_t clipGenID,
const GrTextureDesc& desc,
const GrIRect& bound) {
@@ -127,7 +127,7 @@ public:
GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
- back->acquireMask(fContext, clip, desc, bound);
+ back->acquireMask(fContext, clipGenID, desc, bound);
}
int getLastMaskWidth() const {
@@ -193,20 +193,19 @@ public:
}
}
-protected:
private:
struct GrClipStackFrame {
GrClipStackFrame() {
- reset();
+ this->reset();
}
void acquireMask(GrContext* context,
- const SkClipStack& clip,
+ int32_t clipGenID,
const GrTextureDesc& desc,
const GrIRect& bound) {
- fLastClip = clip;
+ fLastClipGenID = clipGenID;
fLastMask.set(context, desc);
@@ -214,7 +213,7 @@ private:
}
void reset () {
- fLastClip.reset();
+ fLastClipGenID = SkClipStack::kInvalidGenID;
GrTextureDesc desc;
@@ -222,13 +221,12 @@ private:
fLastBound.setEmpty();
}
- SkClipStack fLastClip;
- // The mask's width & height values are used in setupDrawStateAAClip to
- // correctly scale the uvs for geometry drawn with this mask
+ int32_t fLastClipGenID;
+ // The mask's width & height values are used by GrClipMaskManager to correctly scale the
+ // texture coords for the geometry drawn with this mask.
GrAutoScratchTexture fLastMask;
- // fLastBound stores the bounding box of the clip mask in canvas
- // space. The left and top fields are used to offset the uvs for
- // geometry drawn with this mask (in setupDrawStateAAClip)
+ // fLastBound stores the bounding box of the clip mask in clip-stack space. This rect is
+ // used by GrClipMaskManager to position a rect and compute texture coords for the mask.
GrIRect fLastBound;
};