Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: include/gpu/GrClip.h

Issue 951653002: Enable rect clips (Closed) Base URL: https://skia.googlesource.com/skia.git@dt-on-down
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrClip.h
diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h
index 8c8b9b358f84a41433aa1a7d717cba28b76bfa0b..ba26d5c0817419e25da5e61486461e6ccb12e6a7 100644
--- a/include/gpu/GrClip.h
+++ b/include/gpu/GrClip.h
@@ -25,8 +25,11 @@ struct SkIRect;
*/
class GrClip : SkNoncopyable {
public:
- GrClip() : fClipType(kWideOpen_ClipType) {}
+ GrClip() : fClipType(kWideOpen_ClipType) {
+ fOrigin.setZero();
+ }
GrClip(const SkIRect& rect) : fClipType(kIRect_ClipType) {
+ fOrigin.setZero();
fClip.fIRect = rect;
}
~GrClip() { this->reset(); }
@@ -38,13 +41,15 @@ public:
default:
SkFAIL("Incomplete Switch\n");
case kWideOpen_ClipType:
+ fOrigin.setZero();
break;
case kClipStack_ClipType:
- fClip.fClipStack.fStack = SkRef(other.clipStack());
- fClip.fClipStack.fOrigin = other.origin();
+ fClip.fStack = SkRef(other.clipStack());
+ fOrigin = other.origin();
break;
case kIRect_ClipType:
fClip.fIRect = other.irect();
+ fOrigin.setZero();
break;
}
return *this;
@@ -84,19 +89,20 @@ public:
const SkClipStack* clipStack() const {
SkASSERT(kClipStack_ClipType == fClipType);
- return fClip.fClipStack.fStack;
+ return fClip.fStack;
}
void setClipStack(const SkClipStack* clipStack, const SkIPoint* origin = NULL) {
if (clipStack->isWideOpen()) {
fClipType = kWideOpen_ClipType;
+ fOrigin.setZero();
} else {
fClipType = kClipStack_ClipType;
- fClip.fClipStack.fStack = SkRef(clipStack);
+ fClip.fStack = SkRef(clipStack);
if (origin) {
- fClip.fClipStack.fOrigin = *origin;
+ fOrigin = *origin;
} else {
- fClip.fClipStack.fOrigin.setZero();
+ fOrigin.setZero();
}
}
}
@@ -108,15 +114,18 @@ public:
void reset() {
if (kClipStack_ClipType == fClipType) {
- fClip.fClipStack.fStack->unref();
- fClip.fClipStack.fStack = NULL;
+ fClip.fStack->unref();
+ fClip.fStack = NULL;
}
fClipType = kWideOpen_ClipType;
+ fOrigin.setZero();
}
+ // We support this for all cliptypes to simplify the logic a bit in clip mask manager.
+ // non clipstack clip types MUST have a (0,0) origin
const SkIPoint& origin() const {
- SkASSERT(kClipStack_ClipType == fClipType);
- return fClip.fClipStack.fOrigin;
+ SkASSERT(fClipType == kClipStack_ClipType || (fOrigin.fX == 0 && fOrigin.fY == 0));
+ return fOrigin;
}
bool isWideOpen(const SkRect& rect) const {
@@ -159,13 +168,11 @@ public:
private:
union Clip {
- struct ClipStack {
- const SkClipStack* fStack;
- SkIPoint fOrigin;
- } fClipStack;
+ const SkClipStack* fStack;
SkIRect fIRect;
} fClip;
+ SkIPoint fOrigin;
ClipType fClipType;
};
« no previous file with comments | « no previous file | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698