Index: include/core/SkCanvas.h |
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h |
index d28d0f18982292a0c4294cd032db3590ad4cad50..3c90cd7bbfa4bf4f5f80f38db680a4501fac2aad 100644 |
--- a/include/core/SkCanvas.h |
+++ b/include/core/SkCanvas.h |
@@ -10,6 +10,7 @@ |
#include "SkTypes.h" |
#include "SkBitmap.h" |
+#include "SkClipOp.h" |
#include "SkDeque.h" |
#include "SkImage.h" |
#include "SkPaint.h" |
@@ -41,6 +42,8 @@ class SkSurface; |
class SkSurface_Base; |
class SkTextBlob; |
+#define SK_SUPPORT_LEGACY_CLIP_REGIONOPS |
+ |
/** \class SkCanvas |
A Canvas encapsulates all of the state about drawing into a device (bitmap). |
@@ -60,8 +63,27 @@ class SK_API SkCanvas : public SkRefCnt { |
enum PrivateSaveLayerFlags { |
kDontClipToLayer_PrivateSaveLayerFlag = 1U << 31, |
}; |
- |
+ |
public: |
+#ifdef SK_SUPPORT_LEGACY_CLIP_REGIONOPS |
+ typedef SkRegion::Op ClipOp; |
f(malita)
2016/09/19 15:39:25
Any reason to use typedef + static consts instead
reed1
2016/09/19 18:17:08
I want an alias for whatever ClipOp is going to be
f(malita)
2016/09/19 19:43:24
I see. Would it work to typedef unsigned ClipOp f
|
+ |
+ static const ClipOp kDifference_Op = SkRegion::kDifference_Op; |
f(malita)
2016/09/19 15:39:25
constexpr?
reed1
2016/09/19 18:17:08
Turns out the linker wants to see these as actual
|
+ static const ClipOp kIntersect_Op = SkRegion::kIntersect_Op; |
+ static const ClipOp kUnion_Op = SkRegion::kUnion_Op; |
+ static const ClipOp kXOR_Op = SkRegion::kXOR_Op; |
+ static const ClipOp kReverseDifference_Op = SkRegion::kReverseDifference_Op; |
+ static const ClipOp kReplace_Op = SkRegion::kReplace_Op; |
+#else |
+ typedef SkClipOp ClipOp; |
+ |
+ static const ClipOp kDifference_Op = kDifference_SkClipOp; |
+ static const ClipOp kIntersect_Op = kIntersect_SkClipOp; |
+ static const ClipOp kUnion_Op = kUnion_SkClipOp; |
+ static const ClipOp kXOR_Op = kXOR_SkClipOp; |
+ static const ClipOp kReverseDifference_Op = kReverseDifference_SkClipOp; |
+ static const ClipOp kReplace_Op = kReplace_SkClipOp; |
+#endif |
/** |
* Attempt to allocate raster canvas, matching the ImageInfo, that will draw directly into the |
* specified pixels. To access the pixels after drawing to them, the caller should call |
@@ -477,9 +499,7 @@ public: |
* @param op The region op to apply to the current clip |
* @param doAntiAlias true if the clip should be antialiased |
*/ |
- void clipRect(const SkRect& rect, |
- SkRegion::Op op = SkRegion::kIntersect_Op, |
- bool doAntiAlias = false); |
+ void clipRect(const SkRect& rect, ClipOp op = kIntersect_Op, bool doAntiAlias = false); |
/** |
* Modify the current clip with the specified SkRRect. |
@@ -487,9 +507,7 @@ public: |
* @param op The region op to apply to the current clip |
* @param doAntiAlias true if the clip should be antialiased |
*/ |
- void clipRRect(const SkRRect& rrect, |
- SkRegion::Op op = SkRegion::kIntersect_Op, |
- bool doAntiAlias = false); |
+ void clipRRect(const SkRRect& rrect, ClipOp op = kIntersect_Op, bool doAntiAlias = false); |
/** |
* Modify the current clip with the specified path. |
@@ -497,9 +515,7 @@ public: |
* @param op The region op to apply to the current clip |
* @param doAntiAlias true if the clip should be antialiased |
*/ |
- void clipPath(const SkPath& path, |
- SkRegion::Op op = SkRegion::kIntersect_Op, |
- bool doAntiAlias = false); |
+ void clipPath(const SkPath& path, ClipOp op = kIntersect_Op, bool doAntiAlias = false); |
/** EXPERIMENTAL -- only used for testing |
Set to false to force clips to be hard, even if doAntiAlias=true is |
@@ -523,17 +539,18 @@ 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, |
- SkRegion::Op op = SkRegion::kIntersect_Op); |
+ void clipRegion(const SkRegion& deviceRgn, ClipOp op = kIntersect_Op); |
+#ifdef SK_LEGACY_SUPPORT_SETCLIPREGION |
f(malita)
2016/09/19 15:39:26
SK_SUPPORT_LEGACY_SETCLIPREGION?
reed1
2016/09/19 18:17:08
Done.
|
/** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the |
specified region. This does not intersect or in any other way account |
for the existing clip region. |
@param deviceRgn The region to copy into the current clip. |
*/ |
void setClipRegion(const SkRegion& deviceRgn) { |
- this->clipRegion(deviceRgn, SkRegion::kReplace_Op); |
+ this->clipRegion(deviceRgn, kReplace_Op); |
} |
+#endif |
/** Return true if the specified rectangle, after being transformed by the |
current matrix, would lie completely outside of the current clip. Call |
@@ -1466,10 +1483,10 @@ protected: |
kSoft_ClipEdgeStyle |
}; |
- virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle); |
- virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle); |
- virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle); |
- virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); |
+ virtual void onClipRect(const SkRect& rect, ClipOp, ClipEdgeStyle); |
+ virtual void onClipRRect(const SkRRect& rrect, ClipOp, ClipEdgeStyle); |
+ virtual void onClipPath(const SkPath& path, ClipOp, ClipEdgeStyle); |
+ virtual void onClipRegion(const SkRegion& deviceRgn, ClipOp); |
virtual void onDiscard(); |