aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2016-12-12 10:02:12 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-12 15:38:31 +0000
commitebfce6d9b42198e04288a15953f40c395a7b6139 (patch)
treeedb5bfa26c2efb5c58f7071efb3811ca33e23560 /include
parentc30833327f0dda75a8fbe061f3f1966d1f6621a3 (diff)
change SkClipOp to a class enum
BUG=skia: Change-Id: I25dbe6d6b8666a2a0a7be7bdd2ae0b067868d14e Reviewed-on: https://skia-review.googlesource.com/5718 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkCanvas.h14
-rw-r--r--include/core/SkClipOp.h21
-rw-r--r--include/core/SkClipStack.h11
-rw-r--r--include/private/SkRecords.h11
4 files changed, 47 insertions, 10 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 3507786ab9..620c5820b9 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -42,6 +42,12 @@ class SkSurface;
class SkSurface_Base;
class SkTextBlob;
+#ifdef SK_SUPPORT_LEGACY_CLIPOPS_PLAIN_ENUM
+ #define SkCanvasImpl_DefaultClipOp kIntersect_SkClipOp
+#else
+ #define SkCanvasImpl_DefaultClipOp SkClipOp::kIntersect
+#endif
+
/** \class SkCanvas
A Canvas encapsulates all of the state about drawing into a device (bitmap).
@@ -477,7 +483,7 @@ public:
this->clipRect(rect, op, false);
}
void clipRect(const SkRect& rect, bool doAntiAlias = false) {
- this->clipRect(rect, kIntersect_SkClipOp, doAntiAlias);
+ this->clipRect(rect, SkCanvasImpl_DefaultClipOp, doAntiAlias);
}
/**
@@ -491,7 +497,7 @@ public:
this->clipRRect(rrect, op, false);
}
void clipRRect(const SkRRect& rrect, bool doAntiAlias = false) {
- this->clipRRect(rrect, kIntersect_SkClipOp, doAntiAlias);
+ this->clipRRect(rrect, SkCanvasImpl_DefaultClipOp, doAntiAlias);
}
/**
@@ -505,7 +511,7 @@ public:
this->clipPath(path, op, false);
}
void clipPath(const SkPath& path, bool doAntiAlias = false) {
- this->clipPath(path, kIntersect_SkClipOp, doAntiAlias);
+ this->clipPath(path, SkCanvasImpl_DefaultClipOp, doAntiAlias);
}
/** EXPERIMENTAL -- only used for testing
@@ -522,7 +528,7 @@ public:
@param deviceRgn The region to apply to the current clip
@param op The region op to apply to the current clip
*/
- void clipRegion(const SkRegion& deviceRgn, SkClipOp op = kIntersect_SkClipOp);
+ void clipRegion(const SkRegion& deviceRgn, SkClipOp op = SkCanvasImpl_DefaultClipOp);
/** Return true if the specified rectangle, after being transformed by the
current matrix, would lie completely outside of the current clip. Call
diff --git a/include/core/SkClipOp.h b/include/core/SkClipOp.h
index 2e4fbbf868..4a69ef29d5 100644
--- a/include/core/SkClipOp.h
+++ b/include/core/SkClipOp.h
@@ -10,7 +10,10 @@
#include "SkTypes.h"
-// these kept in SkRegion::Op order for now ...
+// SkClipOp enum values always match the corresponding values in SkRegion::Op
+
+#ifdef SK_SUPPORT_LEGACY_CLIPOPS_PLAIN_ENUM
+
enum SkClipOp {
kDifference_SkClipOp = 0,
kIntersect_SkClipOp = 1,
@@ -23,4 +26,20 @@ enum SkClipOp {
kReplace_SkClipOp = 5,
};
+#else
+
+enum class SkClipOp {
+ kDifference = 0,
+ kIntersect = 1,
+
+ // Goal: remove these, since they can grow the current clip
+
+ kUnion = 2,
+ kXOR = 3,
+ kReverseDifference = 4,
+ kReplace = 5,
+};
+
+#endif
+
#endif
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
index 98a3f7698b..64f462601f 100644
--- a/include/core/SkClipStack.h
+++ b/include/core/SkClipStack.h
@@ -18,6 +18,13 @@
class SkCanvasClipVisitor;
+
+#ifdef SK_SUPPORT_LEGACY_CLIPOPS_PLAIN_ENUM
+ #define SkClipStackImpl_ReplaceOp kReplace_SkClipOp
+#else
+ #define SkClipStackImpl_ReplaceOp SkClipOp::kReplace
+#endif
+
// Because a single save/restore state can have multiple clips, this class
// stores the stack depth (fSaveCount) and clips (fDeque) separately.
// Each clip in fDeque stores the stack state to which it belongs
@@ -54,7 +61,7 @@ public:
static const int kTypeCnt = kLastType + 1;
Element() {
- this->initCommon(0, kReplace_SkClipOp, false);
+ this->initCommon(0, SkClipStackImpl_ReplaceOp, false);
this->setEmpty();
}
@@ -226,7 +233,7 @@ public:
int fGenID;
Element(int saveCount) {
- this->initCommon(saveCount, kReplace_SkClipOp, false);
+ this->initCommon(saveCount, SkClipStackImpl_ReplaceOp, false);
this->setEmpty();
}
diff --git a/include/private/SkRecords.h b/include/private/SkRecords.h
index 54efab1891..d1fadc3395 100644
--- a/include/private/SkRecords.h
+++ b/include/private/SkRecords.h
@@ -192,9 +192,14 @@ RECORD(TranslateZ, 0, SkScalar z);
struct ClipOpAndAA {
ClipOpAndAA() {}
- ClipOpAndAA(SkClipOp op, bool aa) : op(op), aa(aa) {}
- SkClipOp op : 31; // This really only needs to be 3, but there's no win today to do so.
- unsigned aa : 1; // MSVC won't pack an enum with an bool, so we call this an unsigned.
+ ClipOpAndAA(SkClipOp op, bool aa) : fOp(static_cast<unsigned>(op)), fAA(aa) {}
+
+ SkClipOp op() const { return static_cast<SkClipOp>(fOp); }
+ bool aa() const { return fAA != 0; }
+
+private:
+ unsigned fOp : 31; // This really only needs to be 3, but there's no win today to do so.
+ unsigned fAA : 1; // MSVC won't pack an enum with an bool, so we call this an unsigned.
};
static_assert(sizeof(ClipOpAndAA) == 4, "ClipOpAndAASize");