| Index: include/gpu/GrClip.h
|
| diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h
|
| index 76cb46e3123c9bf2d74959783a700e2871b61de7..e8f42a231765e3969d5db48f12049cb47822b8b0 100644
|
| --- a/include/gpu/GrClip.h
|
| +++ b/include/gpu/GrClip.h
|
| @@ -15,7 +15,7 @@ struct SkIRect;
|
|
|
| /**
|
| * GrClip encapsulates the information required to construct the clip
|
| - * masks. 'A GrClip is either wide open, just an IRect, just a Rect(TODO), or a full clipstack.
|
| + * masks. 'A GrClip is either wide open, just an IRect, just a Rect, or a full clipstack.
|
| * If the clip is a clipstack than the origin is used to translate the stack with
|
| * respect to device coordinates. This allows us to use a clip stack that is
|
| * specified for a root device with a layer device that is restricted to a subset
|
| @@ -28,18 +28,23 @@ 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) {
|
| this->reset();
|
| fClipType = other.fClipType;
|
| switch (other.fClipType) {
|
| - default:
|
| - SkFAIL("Incomplete Switch\n");
|
| case kWideOpen_ClipType:
|
| fOrigin.setZero();
|
| break;
|
| @@ -51,6 +56,10 @@ public:
|
| fClip.fIRect = other.irect();
|
| fOrigin.setZero();
|
| break;
|
| + case kRect_ClipType:
|
| + fClip.fRect = other.rect();
|
| + fOrigin.setZero();
|
| + break;
|
| }
|
| return *this;
|
| }
|
| @@ -61,9 +70,6 @@ public:
|
| }
|
|
|
| switch (fClipType) {
|
| - default:
|
| - SkFAIL("Incomplete Switch\n");
|
| - return false;
|
| case kWideOpen_ClipType:
|
| return true;
|
| case kClipStack_ClipType:
|
| @@ -80,6 +86,9 @@ public:
|
| case kIRect_ClipType:
|
| return this->irect() == other.irect();
|
| break;
|
| + case kRect_ClipType:
|
| + return this->rect() == other.rect();
|
| + break;
|
| }
|
| }
|
|
|
| @@ -113,6 +122,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();
|
| @@ -132,13 +146,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 {
|
| @@ -146,6 +162,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 {
|
| @@ -163,6 +186,7 @@ public:
|
| kClipStack_ClipType,
|
| kWideOpen_ClipType,
|
| kIRect_ClipType,
|
| + kRect_ClipType,
|
| };
|
|
|
| ClipType clipType() const { return fClipType; }
|
| @@ -170,6 +194,7 @@ public:
|
| private:
|
| union Clip {
|
| const SkClipStack* fStack;
|
| + SkRect fRect;
|
| SkIRect fIRect;
|
| } fClip;
|
|
|
|
|