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

Unified Diff: include/core/SkCanvas.h

Issue 777643003: use ClipOp instead of SkRegion for clipping (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « gyp/skia_for_chromium_defines.gypi ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkCanvas.h
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index ff60c57fa7ec325a7678fbb8e1e28629b83e71a2..5bed56eafffedd7897f19e54a406515c5f153479 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -19,6 +19,12 @@
#include "SkSurfaceProps.h"
#include "SkXfermode.h"
+// Undefine this when we change callers to use SkClipOp or legacyClip (temporarily)
+//#define SK_SUPPORT_REGION_CLIPOPS
+
+// Undefine this when we have updated all callers to SkClipOp
+#define SK_SUPPORT_LEGACY_CLIPOPS
+
#ifdef SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL
#define SK_LEGACY_DRAWTEXT_VIRTUAL virtual
#else
@@ -42,6 +48,11 @@ class GrRenderTarget;
class SkCanvasState;
+enum SkClipOp {
+ kIntersect_SkClipOp,
+ kDifference_SkClipOp,
+};
+
/** \class SkCanvas
A Canvas encapsulates all of the state about drawing into a device (bitmap).
@@ -469,35 +480,68 @@ public:
*/
void resetMatrix();
+#ifndef SK_SUPPORT_REGION_CLIPOPS
+private:
+#endif
+ void clipRect(const SkRect&, SkRegion::Op, bool doAntiAlias = false);
+ void clipRRect(const SkRRect&, SkRegion::Op, bool doAntiAlias = false);
+ void clipPath(const SkPath&, SkRegion::Op, bool doAntiAlias = false);
+ void clipRegion(const SkRegion&, SkRegion::Op);
+#ifndef SK_SUPPORT_REGION_CLIPOPS
+public:
+#endif
+
+/* These support SkRegion ops, and are used in the interim until we can remove all
+ * needs for these ops. When all callers only need Intersect or Difference, we will
+ * remove these calls.
+ */
+#ifdef SK_SUPPORT_LEGACY_CLIPOPS
+ void legacyClipRect(const SkRect& rect, SkRegion::Op op, bool doAntiAlias = false) {
+ this->clipRect(rect, op, doAntiAlias);
+ }
+ void legacyClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAntiAlias = false) {
+ this->clipRRect(rrect, op, doAntiAlias);
+ }
+ void legacyClipPath(const SkPath& path, SkRegion::Op op, bool doAntiAlias = false) {
+ this->clipPath(path, op, doAntiAlias);
+ }
+ void legacyClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+ this->clipRegion(deviceRgn, op);
+ }
+#endif
+
/**
* Modify the current clip with the specified rectangle.
* @param rect The rect to combine with the current clip
- * @param op The region op to apply to the current clip
+ * @param op The ClipOp 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, SkClipOp op, bool doAntiAlias = false);
+ void clipRect(const SkRect& rect) {
+ this->clipRect(rect, kIntersect_SkClipOp, false);
+ }
/**
* Modify the current clip with the specified SkRRect.
* @param rrect The rrect to combine with the current clip
- * @param op The region op to apply to the current clip
+ * @param op The ClipOp 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, SkClipOp op, bool doAntiAlias = false);
+ void clipRRect(const SkRRect& rrect) {
+ this->clipRRect(rrect, kIntersect_SkClipOp, false);
+ }
/**
* Modify the current clip with the specified path.
* @param path The path to combine with the current clip
- * @param op The region op to apply to the current clip
+ * @param op The ClipOp 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, SkClipOp op, bool doAntiAlias = false);
+ void clipPath(const SkPath& path) {
+ this->clipPath(path, kIntersect_SkClipOp, false);
+ }
/** EXPERIMENTAL -- only used for testing
Set to false to force clips to be hard, even if doAntiAlias=true is
@@ -519,10 +563,9 @@ public:
matrix, clipRegion() assumes its argument is already in device
coordinates, and so no transformation is performed.
@param deviceRgn The region to apply to the current clip
- @param op The region op to apply to the current clip
+ @param op The ClipOp to apply to the current clip
*/
- void clipRegion(const SkRegion& deviceRgn,
- SkRegion::Op op = SkRegion::kIntersect_Op);
+ void clipRegion(const SkRegion& deviceRgn, SkClipOp op = kIntersect_SkClipOp);
/** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the
specified region. This does not intersect or in any other way account
@@ -530,7 +573,7 @@ public:
@param deviceRgn The region to copy into the current clip.
*/
void setClipRegion(const SkRegion& deviceRgn) {
- this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
+ this->legacyClipRegion(deviceRgn, SkRegion::kReplace_Op);
}
/** Return true if the specified rectangle, after being transformed by the
« no previous file with comments | « gyp/skia_for_chromium_defines.gypi ('k') | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698