aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-26 18:52:16 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-26 18:52:16 +0000
commitbeb1af78d016d2700c350487a383c6bcfa7e2e20 (patch)
tree0e114092e2335fd699ba53687b8a79f0f932d9b2 /include/gpu
parentcc6493bbef7c9c2adf4b1ed8701e2ed015ae745d (diff)
Altered Ganesh's clip stack plumbing to pass down new GrClipData class
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/GrClip.h35
-rw-r--r--include/gpu/GrContext.h20
-rw-r--r--include/gpu/SkGpuDevice.h2
3 files changed, 49 insertions, 8 deletions
diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h
index c8020150c1..a017fe3def 100644
--- a/include/gpu/GrClip.h
+++ b/include/gpu/GrClip.h
@@ -208,5 +208,40 @@ private:
};
SkSTArray<kPreAllocElements, Element> fList;
};
+
+/**
+ * GrClipData encapsulates the information required to construct the clip
+ * masks. 'fOrigin' is only non-zero when saveLayer has been called
+ * with an offset bounding box. The clips in 'fClipStack' are in
+ * device coordinates (i.e., they have been translated by -fOrigin w.r.t.
+ * the canvas' device coordinates).
+ */
+class GrClipData : public SkNoncopyable {
+public:
+ const GrClip* fClipStack;
+ SkIPoint fOrigin;
+
+ GrClipData()
+ : fClipStack(NULL) {
+ fOrigin.setZero();
+ }
+
+ bool operator==(const GrClipData& other) const {
+ if (fOrigin != other.fOrigin) {
+ return false;
+ }
+
+ if (NULL != fClipStack && NULL != other.fClipStack) {
+ return *fClipStack == *other.fClipStack;
+ }
+
+ return fClipStack == other.fClipStack;
+ }
+
+ bool operator!=(const GrClipData& other) const {
+ return !(*this == other);
+ }
+};
+
#endif
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index e0f5827139..2f05458c44 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -329,13 +329,13 @@ public:
* Gets the current clip.
* @return the current clip.
*/
- const GrClip& getClip() const;
+ const GrClipData* getClip() const;
/**
* Sets the clip.
- * @param clip the clip to set.
+ * @param clipData the clip to set.
*/
- void setClip(const GrClip& clip);
+ void setClip(const GrClipData* clipData);
///////////////////////////////////////////////////////////////////////////
// Draws
@@ -694,9 +694,11 @@ public:
public:
AutoClip(GrContext* context, const GrRect& newClipRect)
: fContext(context)
- , fNewClip(newClipRect) {
+ , fNewClipStack(newClipRect) {
+ fNewClipData.fClipStack = &fNewClipStack;
+
fOldClip = fContext->getClip();
- fContext->setClip(fNewClip);
+ fContext->setClip(&fNewClipData);
}
~AutoClip() {
@@ -705,9 +707,11 @@ public:
}
}
private:
- GrContext* fContext;
- GrClip fOldClip;
- GrClip fNewClip;
+ GrContext* fContext;
+ const GrClipData* fOldClip;
+
+ GrClip fNewClipStack;
+ GrClipData fNewClipData;
};
///////////////////////////////////////////////////////////////////////////
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index 4a628135d6..f576ae499b 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -132,6 +132,8 @@ private:
// the clip stack - on loan to us from SkCanvas so it can be NULL.
const SkClipStack* fClipStack;
+ GrClip fGrClip;
+ GrClipData fClipData;
// state for our offscreen render-target
TexCache fCache;