Index: include/gpu/GrClip.h |
diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h |
index 54c038cabb5762a60fb6d4fc02b559fa7d0d175e..462209bdeb471ea42d61ccf8dc2a97a913de8ce1 100644 |
--- a/include/gpu/GrClip.h |
+++ b/include/gpu/GrClip.h |
@@ -28,10 +28,17 @@ public: |
GrClip() : fClipType(kWideOpen_ClipType) { |
fOrigin.setZero(); |
} |
+ |
GrClip(const SkIRect& rect) : fClipType(kIRect_ClipType) { |
fOrigin.setZero(); |
fClip.fIRect = rect; |
} |
+ |
+ GrClip(const SkRect& rect) : fClipType(kRect_ClipType) { |
+ fOrigin.setZero(); |
+ fClip.fRect = rect; |
+ } |
+ |
~GrClip() { this->reset(); } |
const GrClip& operator=(const GrClip& other) { |
@@ -51,6 +58,10 @@ public: |
fClip.fIRect = other.irect(); |
fOrigin.setZero(); |
break; |
+ case kRect_ClipType: |
+ fClip.fRect = other.rect(); |
+ fOrigin.setZero(); |
+ break; |
} |
return *this; |
} |
@@ -80,6 +91,9 @@ public: |
case kIRect_ClipType: |
return this->irect() == other.irect(); |
break; |
+ case kRect_ClipType: |
+ return this->rect() == other.rect(); |
+ break; |
} |
} |
@@ -112,6 +126,11 @@ public: |
return fClip.fIRect; |
} |
+ const SkRect& rect() const { |
+ SkASSERT(kRect_ClipType == fClipType); |
+ return fClip.fRect; |
+ } |
+ |
void reset() { |
if (kClipStack_ClipType == fClipType) { |
fClip.fStack->unref(); |
@@ -131,13 +150,15 @@ public: |
bool isWideOpen(const SkRect& rect) const { |
return (kWideOpen_ClipType == fClipType) || |
(kClipStack_ClipType == fClipType && this->clipStack()->isWideOpen()) || |
- (kIRect_ClipType == fClipType && this->irect().contains(rect)); |
+ (kIRect_ClipType == fClipType && this->irect().contains(rect)) || |
+ (kRect_ClipType == fClipType && this->rect().contains(rect)); |
} |
bool isWideOpen(const SkIRect& rect) const { |
return (kWideOpen_ClipType == fClipType) || |
(kClipStack_ClipType == fClipType && this->clipStack()->isWideOpen()) || |
- (kIRect_ClipType == fClipType && this->irect().contains(rect)); |
+ (kIRect_ClipType == fClipType && this->irect().contains(rect)) || |
+ (kRect_ClipType == fClipType && this->rect().contains(rect)); |
} |
bool isWideOpen() const { |
@@ -145,6 +166,13 @@ public: |
(kClipStack_ClipType == fClipType && this->clipStack()->isWideOpen()); |
} |
+ bool quickContains(const SkRect& rect) const { |
+ return (kWideOpen_ClipType == fClipType) || |
+ (kClipStack_ClipType == fClipType && this->clipStack()->quickContains(rect)) || |
+ (kIRect_ClipType == fClipType && this->irect().contains(rect)) || |
+ (kRect_ClipType == fClipType && this->rect().contains(rect)); |
+ } |
+ |
void getConservativeBounds(const GrSurface* surface, |
SkIRect* devResult, |
bool* isIntersectionOfRects = NULL) const { |
@@ -165,6 +193,7 @@ public: |
kClipStack_ClipType, |
kWideOpen_ClipType, |
kIRect_ClipType, |
+ kRect_ClipType, |
}; |
ClipType clipType() const { return fClipType; } |
@@ -172,6 +201,7 @@ public: |
private: |
union Clip { |
const SkClipStack* fStack; |
+ SkRect fRect; |
SkIRect fIRect; |
} fClip; |