Revert of r13620 (add new onClip* methods to SkCanvas - https://codereview.chromium.org/183453002/) due to broken Chrome Canary and failing tests.
git-svn-id: http://skia.googlecode.com/svn/trunk@13622 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/utils/SkCanvasStack.cpp b/src/utils/SkCanvasStack.cpp
index d85f34b..8951149 100644
--- a/src/utils/SkCanvasStack.cpp
+++ b/src/utils/SkCanvasStack.cpp
@@ -77,22 +77,25 @@
this->SkCanvas::setMatrix(matrix);
}
-void SkCanvasStack::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
- this->INHERITED::onClipRect(r, op, edgeStyle);
+bool SkCanvasStack::clipRect(const SkRect& r, SkRegion::Op op, bool aa) {
+ bool result = this->INHERITED::clipRect(r, op, aa);
this->clipToZOrderedBounds();
+ return result;
}
-void SkCanvasStack::onClipRRect(const SkRRect& rr, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
- this->INHERITED::onClipRRect(rr, op, edgeStyle);
+bool SkCanvasStack::clipRRect(const SkRRect& rr, SkRegion::Op op, bool aa) {
+ bool result = this->INHERITED::clipRRect(rr, op, aa);
this->clipToZOrderedBounds();
+ return result;
}
-void SkCanvasStack::onClipPath(const SkPath& p, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
- this->INHERITED::onClipPath(p, op, edgeStyle);
+bool SkCanvasStack::clipPath(const SkPath& p, SkRegion::Op op, bool aa) {
+ bool result = this->INHERITED::clipPath(p, op, aa);
this->clipToZOrderedBounds();
+ return result;
}
-void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+bool SkCanvasStack::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
SkASSERT(fList.count() == fCanvasData.count());
for (int i = 0; i < fList.count(); ++i) {
SkRegion tempRegion;
@@ -101,5 +104,5 @@
tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op);
fList[i]->clipRegion(tempRegion, op);
}
- this->SkCanvas::onClipRegion(deviceRgn, op);
+ return this->SkCanvas::clipRegion(deviceRgn, op);
}
diff --git a/src/utils/SkCanvasStack.h b/src/utils/SkCanvasStack.h
index ba2fed4..5311118 100644
--- a/src/utils/SkCanvasStack.h
+++ b/src/utils/SkCanvasStack.h
@@ -30,12 +30,11 @@
virtual void removeCanvas(SkCanvas*) SK_OVERRIDE { SkDEBUGFAIL("Invalid Op"); }
virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
-
-protected:
- virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
- virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
- virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
- virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
+ virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
+ virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE;
+ virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
+ virtual bool clipRegion(const SkRegion& deviceRgn,
+ SkRegion::Op) SK_OVERRIDE;
private:
void clipToZOrderedBounds();
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 09494c9..3911fd0 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -789,34 +789,39 @@
this->recordedDrawCommand();
}
-void SkDeferredCanvas::onClipRect(const SkRect& rect,
- SkRegion::Op op,
- ClipEdgeStyle edgeStyle) {
- this->drawingCanvas()->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
- this->INHERITED::onClipRect(rect, op, edgeStyle);
+bool SkDeferredCanvas::clipRect(const SkRect& rect,
+ SkRegion::Op op,
+ bool doAntiAlias) {
+ this->drawingCanvas()->clipRect(rect, op, doAntiAlias);
+ bool val = this->INHERITED::clipRect(rect, op, doAntiAlias);
this->recordedDrawCommand();
+ return val;
}
-void SkDeferredCanvas::onClipRRect(const SkRRect& rrect,
- SkRegion::Op op,
- ClipEdgeStyle edgeStyle) {
- this->drawingCanvas()->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
- this->INHERITED::onClipRRect(rrect, op, edgeStyle);
+bool SkDeferredCanvas::clipRRect(const SkRRect& rrect,
+ SkRegion::Op op,
+ bool doAntiAlias) {
+ this->drawingCanvas()->clipRRect(rrect, op, doAntiAlias);
+ bool val = this->INHERITED::clipRRect(rrect, op, doAntiAlias);
this->recordedDrawCommand();
+ return val;
}
-void SkDeferredCanvas::onClipPath(const SkPath& path,
- SkRegion::Op op,
- ClipEdgeStyle edgeStyle) {
- this->drawingCanvas()->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
- this->INHERITED::onClipPath(path, op, edgeStyle);
+bool SkDeferredCanvas::clipPath(const SkPath& path,
+ SkRegion::Op op,
+ bool doAntiAlias) {
+ this->drawingCanvas()->clipPath(path, op, doAntiAlias);
+ bool val = this->INHERITED::clipPath(path, op, doAntiAlias);
this->recordedDrawCommand();
+ return val;
}
-void SkDeferredCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+bool SkDeferredCanvas::clipRegion(const SkRegion& deviceRgn,
+ SkRegion::Op op) {
this->drawingCanvas()->clipRegion(deviceRgn, op);
- this->INHERITED::onClipRegion(deviceRgn, op);
+ bool val = this->INHERITED::clipRegion(deviceRgn, op);
this->recordedDrawCommand();
+ return val;
}
void SkDeferredCanvas::clear(SkColor color) {
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index 4805d62..d768137 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -261,40 +261,40 @@
///////////////////////////////////////////////////////////////////////////////
-const char* SkDumpCanvas::EdgeStyleToAAString(ClipEdgeStyle edgeStyle) {
- return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW";
+static const char* bool_to_aastring(bool doAA) {
+ return doAA ? "AA" : "BW";
}
-void SkDumpCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkDumpCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
SkString str;
toString(rect, &str);
this->dump(kClip_Verb, NULL, "clipRect(%s %s %s)", str.c_str(), toString(op),
- EdgeStyleToAAString(edgeStyle));
- this->INHERITED::onClipRect(rect, op, edgeStyle);
+ bool_to_aastring(doAA));
+ return this->INHERITED::clipRect(rect, op, doAA);
}
-void SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkDumpCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
SkString str;
toString(rrect, &str);
this->dump(kClip_Verb, NULL, "clipRRect(%s %s %s)", str.c_str(), toString(op),
- EdgeStyleToAAString(edgeStyle));
- this->INHERITED::onClipRRect(rrect, op, edgeStyle);
+ bool_to_aastring(doAA));
+ return this->INHERITED::clipRRect(rrect, op, doAA);
}
-void SkDumpCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkDumpCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
SkString str;
toString(path, &str);
this->dump(kClip_Verb, NULL, "clipPath(%s %s %s)", str.c_str(), toString(op),
- EdgeStyleToAAString(edgeStyle));
- this->INHERITED::onClipPath(path, op, edgeStyle);
+ bool_to_aastring(doAA));
+ return this->INHERITED::clipPath(path, op, doAA);
}
-void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+bool SkDumpCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
SkString str;
toString(deviceRgn, &str);
this->dump(kClip_Verb, NULL, "clipRegion(%s %s)", str.c_str(),
toString(op));
- this->INHERITED::onClipRegion(deviceRgn, op);
+ return this->INHERITED::clipRegion(deviceRgn, op);
}
void SkDumpCanvas::onPushCull(const SkRect& cullRect) {
diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp
index 0f13073..8c25dc0 100644
--- a/src/utils/SkLuaCanvas.cpp
+++ b/src/utils/SkLuaCanvas.cpp
@@ -139,30 +139,30 @@
this->INHERITED::setMatrix(matrix);
}
-void SkLuaCanvas::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkLuaCanvas::clipRect(const SkRect& r, SkRegion::Op op, bool doAA) {
AUTO_LUA("clipRect");
lua.pushRect(r, "rect");
- lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa");
- this->INHERITED::onClipRect(r, op, edgeStyle);
+ lua.pushBool(doAA, "aa");
+ return this->INHERITED::clipRect(r, op, doAA);
}
-void SkLuaCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkLuaCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
AUTO_LUA("clipRRect");
lua.pushRRect(rrect, "rrect");
- lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa");
- this->INHERITED::onClipRRect(rrect, op, edgeStyle);
+ lua.pushBool(doAA, "aa");
+ return this->INHERITED::clipRRect(rrect, op, doAA);
}
-void SkLuaCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkLuaCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
AUTO_LUA("clipPath");
lua.pushPath(path, "path");
- lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa");
- this->INHERITED::onClipPath(path, op, edgeStyle);
+ lua.pushBool(doAA, "aa");
+ return this->INHERITED::clipPath(path, op, doAA);
}
-void SkLuaCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+bool SkLuaCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
AUTO_LUA("clipRegion");
- this->INHERITED::onClipRegion(deviceRgn, op);
+ return this->INHERITED::clipRegion(deviceRgn, op);
}
void SkLuaCanvas::drawPaint(const SkPaint& paint) {
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index a9543f9..27adc6d 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -130,36 +130,36 @@
this->INHERITED::setMatrix(matrix);
}
-void SkNWayCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkNWayCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
Iter iter(fList);
while (iter.next()) {
- iter->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
+ iter->clipRect(rect, op, doAA);
}
- this->INHERITED::onClipRect(rect, op, edgeStyle);
+ return this->INHERITED::clipRect(rect, op, doAA);
}
-void SkNWayCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkNWayCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
Iter iter(fList);
while (iter.next()) {
- iter->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
+ iter->clipRRect(rrect, op, doAA);
}
- this->INHERITED::onClipRRect(rrect, op, edgeStyle);
+ return this->INHERITED::clipRRect(rrect, op, doAA);
}
-void SkNWayCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkNWayCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
Iter iter(fList);
while (iter.next()) {
- iter->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
+ iter->clipPath(path, op, doAA);
}
- this->INHERITED::onClipPath(path, op, edgeStyle);
+ return this->INHERITED::clipPath(path, op, doAA);
}
-void SkNWayCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+bool SkNWayCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
Iter iter(fList);
while (iter.next()) {
iter->clipRegion(deviceRgn, op);
}
- this->INHERITED::onClipRegion(deviceRgn, op);
+ return this->INHERITED::clipRegion(deviceRgn, op);
}
void SkNWayCanvas::clear(SkColor color) {
diff --git a/src/utils/SkNoSaveLayerCanvas.h b/src/utils/SkNoSaveLayerCanvas.h
index 60fad87..58d28b4 100644
--- a/src/utils/SkNoSaveLayerCanvas.h
+++ b/src/utils/SkNoSaveLayerCanvas.h
@@ -32,20 +32,25 @@
return count;
}
-protected:
// disable aa for speed
- virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
- this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle);
+ virtual bool clipRect(const SkRect& rect,
+ SkRegion::Op op,
+ bool doAA) SK_OVERRIDE {
+ return this->INHERITED::clipRect(rect, op, false);
}
// for speed, just respect the bounds, and disable AA. May give us a few
// false positives and negatives.
- virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
- this->updateClipConservativelyUsingBounds(path.getBounds(), op,
- path.isInverseFillType());
+ virtual bool clipPath(const SkPath& path,
+ SkRegion::Op op,
+ bool doAA) SK_OVERRIDE {
+ return this->updateClipConservativelyUsingBounds(path.getBounds(), op,
+ path.isInverseFillType());
}
- virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
- this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
+ virtual bool clipRRect(const SkRRect& rrect,
+ SkRegion::Op op,
+ bool doAA) SK_OVERRIDE {
+ return this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
}
private:
diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp
index 0a9d7a8..245e0a6 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -58,20 +58,20 @@
fProxy->setMatrix(matrix);
}
-void SkProxyCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
- fProxy->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
+bool SkProxyCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
+ return fProxy->clipRect(rect, op, doAA);
}
-void SkProxyCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
- fProxy->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
+bool SkProxyCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
+ return fProxy->clipRRect(rrect, op, doAA);
}
-void SkProxyCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
- fProxy->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
+bool SkProxyCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
+ return fProxy->clipPath(path, op, doAA);
}
-void SkProxyCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
- fProxy->clipRegion(deviceRgn, op);
+bool SkProxyCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+ return fProxy->clipRegion(deviceRgn, op);
}
void SkProxyCanvas::drawPaint(const SkPaint& paint) {
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index fedef69..15165c2 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -43,8 +43,7 @@
large.roundOut(&largeIRect);
SkASSERT(!largeIRect.isEmpty());
#endif
- // call the base class' version to avoid adding a draw command
- this->INHERITED::onClipRect(large, SkRegion::kReplace_Op, kHard_ClipEdgeStyle);
+ INHERITED::clipRect(large, SkRegion::kReplace_Op, false);
}
SkDebugCanvas::~SkDebugCanvas() {
@@ -298,20 +297,24 @@
addDrawCommand(new SkClearCommand(color));
}
-void SkDebugCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
- this->addDrawCommand(new SkClipPathCommand(path, op, kSoft_ClipEdgeStyle == edgeStyle));
+bool SkDebugCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
+ addDrawCommand(new SkClipPathCommand(path, op, doAA));
+ return true;
}
-void SkDebugCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
- this->addDrawCommand(new SkClipRectCommand(rect, op, kSoft_ClipEdgeStyle == edgeStyle));
+bool SkDebugCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
+ addDrawCommand(new SkClipRectCommand(rect, op, doAA));
+ return true;
}
-void SkDebugCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
- this->addDrawCommand(new SkClipRRectCommand(rrect, op, kSoft_ClipEdgeStyle == edgeStyle));
+bool SkDebugCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
+ addDrawCommand(new SkClipRRectCommand(rrect, op, doAA));
+ return true;
}
-void SkDebugCanvas::onClipRegion(const SkRegion& region, SkRegion::Op op) {
- this->addDrawCommand(new SkClipRegionCommand(region, op));
+bool SkDebugCanvas::clipRegion(const SkRegion& region, SkRegion::Op op) {
+ addDrawCommand(new SkClipRegionCommand(region, op));
+ return true;
}
bool SkDebugCanvas::concat(const SkMatrix& matrix) {
diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h
index 11771a4..7d49627 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -143,6 +143,16 @@
virtual void clear(SkColor) SK_OVERRIDE;
+ virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
+
+ virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
+
+ virtual bool clipRRect(const SkRRect& rrect,
+ SkRegion::Op op = SkRegion::kIntersect_Op,
+ bool doAntiAlias = false) SK_OVERRIDE;
+
+ virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE;
+
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
@@ -223,33 +233,11 @@
static const int kVizImageHeight = 256;
static const int kVizImageWidth = 256;
- virtual bool isClipEmpty() const SK_OVERRIDE { return false; }
- virtual ClipType getClipType() const SK_OVERRIDE { return kRect_ClipType; }
- virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE {
- if (NULL != bounds) {
- bounds->setXYWH(0, 0,
- SkIntToScalar(this->imageInfo().fWidth),
- SkIntToScalar(this->imageInfo().fHeight));
- }
- return true;
- }
- virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE {
- if (NULL != bounds) {
- bounds->setLargest();
- }
- return true;
- }
-
protected:
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
virtual void onPopCull() SK_OVERRIDE;
- virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
- virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
- virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
- virtual void onClipRegion(const SkRegion& region, SkRegion::Op) SK_OVERRIDE;
-
private:
SkTDArray<SkDrawCommand*> fCommandVector;
int fWidth;