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

Unified Diff: src/core/SkCanvas.cpp

Issue 2355483002: abstract name of clipping ops, to transtion to a more restricted set (Closed)
Patch Set: remove setClipRegion entirely Created 4 years, 3 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 | « samplecode/SampleLayers.cpp ('k') | src/core/SkClipStack.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index e53a104c47fa28406f1d440dbcd670365d877a24..c09d6d402814b470610b600dbd572cb5c8b263ce 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -345,8 +345,7 @@ public:
bool next() {
if (fMultiDeviceCS && fDevice) {
// remove the previous device's bounds
- fMultiDeviceCS->clipDevRect(compute_device_bounds(fDevice),
- SkRegion::kDifference_Op);
+ fMultiDeviceCS->clipDevRect(compute_device_bounds(fDevice), SkCanvas::kDifference_Op);
}
// skip over recs with empty clips
@@ -1111,7 +1110,7 @@ bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveLayerFlags saveLayerFlag
if (BoundsAffectsClip(saveLayerFlags)) {
// Simplify the current clips since they will be applied properly during restore()
- fClipStack->clipDevRect(ir, SkRegion::kReplace_Op);
+ fClipStack->clipDevRect(ir, kReplace_Op);
fMCRec->fRasterClip.setRect(ir);
fDeviceClipBounds = qr_clip_bounds(ir);
}
@@ -1543,7 +1542,7 @@ sk_sp<SkLights> SkCanvas::getLights() const {
//////////////////////////////////////////////////////////////////////////////
-void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
+void SkCanvas::clipRect(const SkRect& rect, ClipOp op, bool doAA) {
if (!fAllowSoftClip) {
doAA = false;
}
@@ -1572,7 +1571,7 @@ void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
this->onClipRect(rect, op, edgeStyle);
}
-void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+void SkCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle) {
#ifdef SK_ENABLE_CLIP_QUICKREJECT
if (SkRegion::kIntersect_Op == op) {
f(malita) 2016/09/19 19:43:25 kIntersect_Op
reed1 2016/09/19 20:42:50 deleted
if (fMCRec->fRasterClip.isEmpty()) {
@@ -1598,10 +1597,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
}
#ifndef SK_SUPPORT_PRECHECK_CLIPRECT
- if (SkRegion::kIntersect_Op == op &&
- kHard_ClipEdgeStyle == edgeStyle
- && isScaleTrans)
- {
+ if (kIntersect_Op == op && kHard_ClipEdgeStyle == edgeStyle && isScaleTrans) {
if (devR.round().contains(fMCRec->fRasterClip.getBounds())) {
#if 0
SkDebugf("------- ignored clipRect [%g %g %g %g]\n",
@@ -1619,7 +1615,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
if (isScaleTrans) {
const bool isAA = kSoft_ClipEdgeStyle == edgeStyle;
fClipStack->clipDevRect(devR, op, isAA);
- fMCRec->fRasterClip.op(devR, this->getTopLayerBounds(), op, isAA);
+ fMCRec->fRasterClip.op(devR, this->getTopLayerBounds(), (SkRegion::Op)op, isAA);
f(malita) 2016/09/19 19:43:25 Maybe add static asserts for all ClipOp values mat
reed1 2016/09/19 20:42:50 Done.
} else {
// since we're rotated or some such thing, we convert the rect to a path
// and clip against that, since it can handle any matrix. However, to
@@ -1635,7 +1631,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
fDeviceClipBounds = qr_clip_bounds(fMCRec->fRasterClip.getBounds());
}
-void SkCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
+void SkCanvas::clipRRect(const SkRRect& rrect, ClipOp op, bool doAA) {
this->checkForDeferredSave();
ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
if (rrect.isRect()) {
@@ -1645,7 +1641,7 @@ void SkCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
}
}
-void SkCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+void SkCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
SkRRect transformedRRect;
if (rrect.transform(fMCRec->fMatrix, &transformedRRect)) {
AutoValidateClip avc(this);
@@ -1657,7 +1653,7 @@ void SkCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle
fClipStack->clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == edgeStyle);
- fMCRec->fRasterClip.op(transformedRRect, this->getTopLayerBounds(), op,
+ fMCRec->fRasterClip.op(transformedRRect, this->getTopLayerBounds(), (SkRegion::Op)op,
kSoft_ClipEdgeStyle == edgeStyle);
fDeviceClipBounds = qr_clip_bounds(fMCRec->fRasterClip.getBounds());
return;
@@ -1670,7 +1666,7 @@ void SkCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle
this->SkCanvas::onClipPath(path, op, edgeStyle);
}
-void SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
+void SkCanvas::clipPath(const SkPath& path, ClipOp op, bool doAA) {
this->checkForDeferredSave();
ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
@@ -1695,7 +1691,7 @@ void SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
this->onClipPath(path, op, edgeStyle);
}
-void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+void SkCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
#ifdef SK_ENABLE_CLIP_QUICKREJECT
if (SkRegion::kIntersect_Op == op && !path.isInverseFillType()) {
f(malita) 2016/09/19 19:43:25 kIntersect_Op
reed1 2016/09/19 20:42:50 deleted
if (fMCRec->fRasterClip.isEmpty()) {
@@ -1748,19 +1744,19 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg
edgeStyle = kSoft_ClipEdgeStyle;
}
- op = SkRegion::kReplace_Op;
+ op = kReplace_Op;
}
- fMCRec->fRasterClip.op(devPath, this->getTopLayerBounds(), op, edgeStyle);
+ fMCRec->fRasterClip.op(devPath, this->getTopLayerBounds(), (SkRegion::Op)op, edgeStyle);
fDeviceClipBounds = qr_clip_bounds(fMCRec->fRasterClip.getBounds());
}
-void SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) {
+void SkCanvas::clipRegion(const SkRegion& rgn, ClipOp op) {
this->checkForDeferredSave();
this->onClipRegion(rgn, op);
}
-void SkCanvas::onClipRegion(const SkRegion& rgn, SkRegion::Op op) {
+void SkCanvas::onClipRegion(const SkRegion& rgn, ClipOp op) {
AutoValidateClip avc(this);
fDeviceCMDirty = true;
@@ -1769,7 +1765,7 @@ void SkCanvas::onClipRegion(const SkRegion& rgn, SkRegion::Op op) {
// we have to ignore it, and use the region directly?
fClipStack->clipDevRect(rgn.getBounds(), op);
- fMCRec->fRasterClip.op(rgn, op);
+ fMCRec->fRasterClip.op(rgn, (SkRegion::Op)op);
fDeviceClipBounds = qr_clip_bounds(fMCRec->fRasterClip.getBounds());
}
@@ -1792,7 +1788,7 @@ void SkCanvas::validateClip() const {
switch (element->getType()) {
case SkClipStack::Element::kRect_Type:
element->getRect().round(&ir);
- tmpClip.op(ir, element->getOp());
+ tmpClip.op(ir, (SkRegion::Op)element->getOp());
break;
case SkClipStack::Element::kEmpty_Type:
tmpClip.setEmpty();
@@ -1800,7 +1796,8 @@ void SkCanvas::validateClip() const {
default: {
SkPath path;
element->asPath(&path);
- tmpClip.op(path, this->getTopLayerBounds(), element->getOp(), element->isAA());
+ tmpClip.op(path, this->getTopLayerBounds(), (SkRegion::Op)element->getOp(),
+ element->isAA());
break;
}
}
@@ -3511,3 +3508,21 @@ SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
return this->makeSurface(info, props).release();
}
#endif
+
+/////////////////////////////////
+
+#ifdef SK_SUPPORT_LEGACY_CLIP_REGIONOPS
+const SkCanvas::ClipOp SkCanvas::kDifference_Op;
+const SkCanvas::ClipOp SkCanvas::kIntersect_Op;
+const SkCanvas::ClipOp SkCanvas::kUnion_Op;
+const SkCanvas::ClipOp SkCanvas::kXOR_Op;
+const SkCanvas::ClipOp SkCanvas::kReverseDifference_Op;
+const SkCanvas::ClipOp SkCanvas::kReplace_Op;
+#else
+const SkCanvas::ClipOp SkCanvas::kDifference_Op;
+const SkCanvas::ClipOp SkCanvas::kIntersect_Op;
+const SkCanvas::ClipOp SkCanvas::kUnion_Op;
+const SkCanvas::ClipOp SkCanvas::kXOR_Op;
+const SkCanvas::ClipOp SkCanvas::kReverseDifference_Op;
+const SkCanvas::ClipOp SkCanvas::kReplace_Op;
+#endif
« no previous file with comments | « samplecode/SampleLayers.cpp ('k') | src/core/SkClipStack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698