aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--experimental/PdfViewer/SkNulCanvas.h101
-rw-r--r--include/core/SkCanvas.h25
-rw-r--r--include/utils/SkDeferredCanvas.h13
-rw-r--r--include/utils/SkDumpCanvas.h13
-rw-r--r--include/utils/SkLuaCanvas.h11
-rw-r--r--include/utils/SkNWayCanvas.h10
-rw-r--r--include/utils/SkProxyCanvas.h11
-rw-r--r--src/core/SkBBoxHierarchyRecord.cpp30
-rw-r--r--src/core/SkBBoxHierarchyRecord.h18
-rw-r--r--src/core/SkCanvas.cpp119
-rw-r--r--src/core/SkPicturePlayback.cpp12
-rw-r--r--src/core/SkPictureRecord.cpp36
-rw-r--r--src/core/SkPictureRecord.h9
-rw-r--r--src/pipe/SkGPipeWrite.cpp47
-rw-r--r--src/utils/SkCanvasStack.cpp19
-rw-r--r--src/utils/SkCanvasStack.h11
-rw-r--r--src/utils/SkDeferredCanvas.cpp39
-rw-r--r--src/utils/SkDumpCanvas.cpp26
-rw-r--r--src/utils/SkLuaCanvas.cpp22
-rw-r--r--src/utils/SkNWayCanvas.cpp22
-rw-r--r--src/utils/SkNoSaveLayerCanvas.h21
-rw-r--r--src/utils/SkProxyCanvas.cpp16
-rw-r--r--src/utils/debugger/SkDebugCanvas.cpp23
-rw-r--r--src/utils/debugger/SkDebugCanvas.h32
-rw-r--r--tests/PictureTest.cpp26
25 files changed, 326 insertions, 386 deletions
diff --git a/experimental/PdfViewer/SkNulCanvas.h b/experimental/PdfViewer/SkNulCanvas.h
index 506d49f35f..8ec2d32d0f 100644
--- a/experimental/PdfViewer/SkNulCanvas.h
+++ b/experimental/PdfViewer/SkNulCanvas.h
@@ -26,89 +26,78 @@ public:
explicit SkNulCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap) {}
virtual ~SkNulCanvas() {}
- virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) SK_OVERRIDE {return 0;}
+ virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) {return 0;}
virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags = kARGB_ClipLayer_SaveFlag) SK_OVERRIDE {return 0;}
+ SaveFlags flags = kARGB_ClipLayer_SaveFlag) {return 0;}
int saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
SaveFlags flags = kARGB_ClipLayer_SaveFlag) {return 0;}
- virtual void restore() SK_OVERRIDE {}
+ virtual void restore() {}
int getSaveCount() const {return 0;}
- virtual bool isDrawingToLayer() const SK_OVERRIDE {return false;}
- virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE {return true;}
- virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE {return true;}
- virtual bool rotate(SkScalar degrees) SK_OVERRIDE {return true;}
- virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE {return true;}
- virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE {return true;}
- virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE {}
- virtual void clear(SkColor) SK_OVERRIDE {}
- virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE {}
+ virtual bool isDrawingToLayer() const {return false;}
+ virtual bool translate(SkScalar dx, SkScalar dy) {return true;}
+ virtual bool scale(SkScalar sx, SkScalar sy) {return true;}
+ virtual bool rotate(SkScalar degrees) {return true;}
+ virtual bool skew(SkScalar sx, SkScalar sy) {return true;}
+ virtual bool concat(const SkMatrix& matrix) {return true;}
+ virtual void setMatrix(const SkMatrix& matrix) {}
+ virtual bool clipRect(const SkRect& rect,
+ SkRegion::Op op = SkRegion::kIntersect_Op,
+ bool doAntiAlias = false) {return true;}
+ virtual bool clipRRect(const SkRRect& rrect,
+ SkRegion::Op op = SkRegion::kIntersect_Op,
+ bool doAntiAlias = false) {return true;}
+ virtual bool clipPath(const SkPath& path,
+ SkRegion::Op op = SkRegion::kIntersect_Op,
+ bool doAntiAlias = false) {return true;}
+ virtual bool clipRegion(const SkRegion& deviceRgn,
+ SkRegion::Op op = SkRegion::kIntersect_Op) {return true;}
+ virtual void clear(SkColor) {}
+ virtual void drawPaint(const SkPaint& paint) {}
virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
- const SkPaint& paint) SK_OVERRIDE {}
- virtual void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE {}
- virtual void drawOval(const SkRect& oval, const SkPaint&) SK_OVERRIDE {}
- virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE {}
- virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE {}
+ const SkPaint& paint) {}
+ virtual void drawRect(const SkRect& rect, const SkPaint& paint) {}
+ virtual void drawOval(const SkRect& oval, const SkPaint&) {}
+ virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) {}
+ virtual void drawPath(const SkPath& path, const SkPaint& paint) {}
virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
- const SkPaint* paint = NULL) SK_OVERRIDE {}
+ const SkPaint* paint = NULL) {}
virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst,
const SkPaint* paint,
- DrawBitmapRectFlags flags) SK_OVERRIDE {}
+ DrawBitmapRectFlags flags) {}
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
- const SkPaint* paint = NULL) SK_OVERRIDE {}
+ const SkPaint* paint = NULL) {}
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
- const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {}
+ const SkRect& dst, const SkPaint* paint = NULL) {}
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
- const SkPaint* paint = NULL) SK_OVERRIDE {}
+ const SkPaint* paint = NULL) {}
virtual void drawText(const void* text, size_t byteLength, SkScalar x,
- SkScalar y, const SkPaint& paint) SK_OVERRIDE {}
+ SkScalar y, const SkPaint& paint) {}
virtual void drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE {}
+ const SkPoint pos[], const SkPaint& paint) {}
virtual void drawPosTextH(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
- const SkPaint& paint) SK_OVERRIDE {}
+ const SkPaint& paint) {}
virtual void drawTextOnPath(const void* text, size_t byteLength,
const SkPath& path, const SkMatrix* matrix,
- const SkPaint& paint) SK_OVERRIDE {}
- virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {}
+ const SkPaint& paint) {}
+ virtual void drawPicture(SkPicture& picture) {}
virtual void drawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
- const SkPaint& paint) SK_OVERRIDE {}
- virtual void drawData(const void* data, size_t length) SK_OVERRIDE {}
- virtual void beginCommentGroup(const char* description) SK_OVERRIDE {}
- virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE {}
- virtual void endCommentGroup() SK_OVERRIDE {}
- virtual SkBounder* setBounder(SkBounder* bounder) SK_OVERRIDE {return NULL;}
- virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE {return NULL;}
-
- 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;
- }
+ const SkPaint& paint) {}
+ virtual void drawData(const void* data, size_t length) {}
+ virtual void beginCommentGroup(const char* description) {}
+ virtual void addComment(const char* kywd, const char* value) {}
+ virtual void endCommentGroup() {}
+ virtual SkBounder* setBounder(SkBounder* bounder) {return NULL;}
+ virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) {return NULL;}
protected:
virtual SkCanvas* canvasForDrawIter() {return NULL;}
virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;}
- 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 {}
-
private:
typedef SkCanvas INHERITED;
};
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 27ff8bb493..b73a1e48ca 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -481,9 +481,10 @@ public:
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.
+ @return true if the new clip region is non-empty
*/
- void setClipRegion(const SkRegion& deviceRgn) {
- this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
+ bool setClipRegion(const SkRegion& deviceRgn) {
+ return this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
}
/** Return true if the specified rectangle, after being transformed by the
@@ -547,13 +548,13 @@ public:
in a way similar to quickReject, in that it tells you that drawing
outside of these bounds will be clipped out.
*/
- virtual bool getClipBounds(SkRect* bounds) const;
+ bool getClipBounds(SkRect* bounds) const;
/** Return the bounds of the current clip, in device coordinates; returns
true if non-empty. Maybe faster than getting the clip explicitly and
then taking its bounds.
*/
- virtual bool getClipDeviceBounds(SkIRect* bounds) const;
+ bool getClipDeviceBounds(SkIRect* bounds) const;
/** Fill the entire canvas' bitmap (restricted to the current clip) with the
@@ -1030,7 +1031,7 @@ public:
* result, subsequent calls will be cheap (until the clip state changes,
* which can happen on any clip..() or restore() call.
*/
- virtual bool isClipEmpty() const;
+ bool isClipEmpty() const;
/** Return the current matrix on the canvas.
This does not account for the translate in any of the devices.
@@ -1047,7 +1048,7 @@ public:
/** Returns a description of the total clip; may be cheaper than
getting the clip and querying it directly.
*/
- virtual ClipType getClipType() const;
+ ClipType getClipType() const;
/** DEPRECATED -- need to move this guy to private/friend
* Return the current device clip (concatenation of all clip calls).
@@ -1129,16 +1130,6 @@ protected:
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
- enum ClipEdgeStyle {
- kHard_ClipEdgeStyle,
- 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);
-
// Returns the canvas to be used by DrawIter. Default implementation
// returns this. Subclasses that encapsulate an indirect canvas may
// need to overload this method. The impl must keep track of this, as it
@@ -1155,7 +1146,7 @@ protected:
// Called by child classes that override clipPath and clipRRect to only
// track fast conservative clip bounds, rather than exact clips.
- void updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op,
+ bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op,
bool inverseFilled);
// notify our surface (if we have one) that we are about to draw, so it
diff --git a/include/utils/SkDeferredCanvas.h b/include/utils/SkDeferredCanvas.h
index b26ddbc952..d028282ef2 100644
--- a/include/utils/SkDeferredCanvas.h
+++ b/include/utils/SkDeferredCanvas.h
@@ -149,6 +149,14 @@ public:
virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
+ virtual bool clipRect(const SkRect& rect, SkRegion::Op op,
+ bool doAntiAlias) SK_OVERRIDE;
+ virtual bool clipRRect(const SkRRect& rect, SkRegion::Op op,
+ bool doAntiAlias) SK_OVERRIDE;
+ virtual bool clipPath(const SkPath& path, SkRegion::Op op,
+ bool doAntiAlias) SK_OVERRIDE;
+ virtual bool clipRegion(const SkRegion& deviceRgn,
+ SkRegion::Op op) SK_OVERRIDE;
virtual void clear(SkColor) SK_OVERRIDE;
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
@@ -196,11 +204,6 @@ protected:
virtual void onDrawDRRect(const SkRRect&, const SkRRect&,
const SkPaint&) 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&, SkRegion::Op) SK_OVERRIDE;
-
public:
class NotificationClient {
public:
diff --git a/include/utils/SkDumpCanvas.h b/include/utils/SkDumpCanvas.h
index 5e3249cbee..fe4d175354 100644
--- a/include/utils/SkDumpCanvas.h
+++ b/include/utils/SkDumpCanvas.h
@@ -86,6 +86,12 @@ public:
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) 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;
+
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint) SK_OVERRIDE;
@@ -128,13 +134,6 @@ protected:
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&, SkRegion::Op) SK_OVERRIDE;
-
- static const char* EdgeStyleToAAString(ClipEdgeStyle edgeStyle);
-
private:
Dumper* fDumper;
int fNestLevel; // for nesting recursive elements like pictures
diff --git a/include/utils/SkLuaCanvas.h b/include/utils/SkLuaCanvas.h
index a4f30bc349..be1cf4d049 100644
--- a/include/utils/SkLuaCanvas.h
+++ b/include/utils/SkLuaCanvas.h
@@ -32,6 +32,12 @@ public:
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) 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;
+
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint) SK_OVERRIDE;
@@ -69,11 +75,6 @@ public:
protected:
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) 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&, SkRegion::Op) SK_OVERRIDE;
-
private:
lua_State* fL;
SkString fFunc;
diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h
index 84f4b4a177..d83dd6ed77 100644
--- a/include/utils/SkNWayCanvas.h
+++ b/include/utils/SkNWayCanvas.h
@@ -33,6 +33,11 @@ public:
virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) 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;
virtual void clear(SkColor) SK_OVERRIDE;
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
@@ -83,11 +88,6 @@ protected:
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) 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&, SkRegion::Op) SK_OVERRIDE;
-
class Iter;
private:
diff --git a/include/utils/SkProxyCanvas.h b/include/utils/SkProxyCanvas.h
index d682ba3b44..f192e54a51 100644
--- a/include/utils/SkProxyCanvas.h
+++ b/include/utils/SkProxyCanvas.h
@@ -38,6 +38,12 @@ public:
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) 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 op = SkRegion::kIntersect_Op) SK_OVERRIDE;
+
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint) SK_OVERRIDE;
@@ -82,11 +88,6 @@ public:
protected:
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) 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&, SkRegion::Op) SK_OVERRIDE;
-
private:
SkCanvas* fProxy;
diff --git a/src/core/SkBBoxHierarchyRecord.cpp b/src/core/SkBBoxHierarchyRecord.cpp
index 5d310be7bc..b120b1da87 100644
--- a/src/core/SkBBoxHierarchyRecord.cpp
+++ b/src/core/SkBBoxHierarchyRecord.cpp
@@ -77,31 +77,31 @@ void SkBBoxHierarchyRecord::setMatrix(const SkMatrix& matrix) {
fStateTree->appendTransform(getTotalMatrix());
}
-void SkBBoxHierarchyRecord::onClipRect(const SkRect& rect,
- SkRegion::Op op,
- ClipEdgeStyle edgeStyle) {
+bool SkBBoxHierarchyRecord::clipRect(const SkRect& rect,
+ SkRegion::Op op,
+ bool doAntiAlias) {
fStateTree->appendClip(this->writeStream().bytesWritten());
- this->INHERITED::onClipRect(rect, op, edgeStyle);
+ return INHERITED::clipRect(rect, op, doAntiAlias);
}
-void SkBBoxHierarchyRecord::onClipRegion(const SkRegion& region,
- SkRegion::Op op) {
+bool SkBBoxHierarchyRecord::clipRegion(const SkRegion& region,
+ SkRegion::Op op) {
fStateTree->appendClip(this->writeStream().bytesWritten());
- this->INHERITED::onClipRegion(region, op);
+ return INHERITED::clipRegion(region, op);
}
-void SkBBoxHierarchyRecord::onClipPath(const SkPath& path,
- SkRegion::Op op,
- ClipEdgeStyle edgeStyle) {
+bool SkBBoxHierarchyRecord::clipPath(const SkPath& path,
+ SkRegion::Op op,
+ bool doAntiAlias) {
fStateTree->appendClip(this->writeStream().bytesWritten());
- this->INHERITED::onClipPath(path, op, edgeStyle);
+ return INHERITED::clipPath(path, op, doAntiAlias);
}
-void SkBBoxHierarchyRecord::onClipRRect(const SkRRect& rrect,
- SkRegion::Op op,
- ClipEdgeStyle edgeStyle) {
+bool SkBBoxHierarchyRecord::clipRRect(const SkRRect& rrect,
+ SkRegion::Op op,
+ bool doAntiAlias) {
fStateTree->appendClip(this->writeStream().bytesWritten());
- this->INHERITED::onClipRRect(rrect, op, edgeStyle);
+ return INHERITED::clipRRect(rrect, op, doAntiAlias);
}
bool SkBBoxHierarchyRecord::shouldRewind(void* data) {
diff --git a/src/core/SkBBoxHierarchyRecord.h b/src/core/SkBBoxHierarchyRecord.h
index 80f59c3907..f264334807 100644
--- a/src/core/SkBBoxHierarchyRecord.h
+++ b/src/core/SkBBoxHierarchyRecord.h
@@ -35,15 +35,21 @@ public:
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
+ virtual bool clipRect(const SkRect& rect,
+ SkRegion::Op op = SkRegion::kIntersect_Op,
+ bool doAntiAlias = false) SK_OVERRIDE;
+ virtual bool clipRegion(const SkRegion& region,
+ SkRegion::Op op = SkRegion::kIntersect_Op) SK_OVERRIDE;
+ virtual bool clipPath(const SkPath& path,
+ SkRegion::Op op = SkRegion::kIntersect_Op,
+ bool doAntiAlias = false) SK_OVERRIDE;
+ virtual bool clipRRect(const SkRRect& rrect,
+ SkRegion::Op op = SkRegion::kIntersect_Op,
+ bool doAntiAlias = false) SK_OVERRIDE;
+
// Implementation of the SkBBoxHierarchyClient interface
virtual bool shouldRewind(void* data) 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;
-
private:
typedef SkBBoxRecord INHERITED;
};
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 7851fdbb81..bc14974b7d 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1166,12 +1166,6 @@ void SkCanvas::resetMatrix() {
//////////////////////////////////////////////////////////////////////////////
bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
- ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
- this->onClipRect(rect, op, edgeStyle);
- return !this->isClipEmpty();
-}
-
-void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
#ifdef SK_ENABLE_CLIP_QUICKREJECT
if (SkRegion::kIntersect_Op == op) {
if (fMCRec->fRasterClip->isEmpty()) {
@@ -1192,9 +1186,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
fDeviceCMDirty = true;
fCachedLocalClipBoundsDirty = true;
- if (!fAllowSoftClip) {
- edgeStyle = kHard_ClipEdgeStyle;
- }
+ doAA &= fAllowSoftClip;
if (fMCRec->fMatrix->rectStaysRect()) {
// for these simpler matrices, we can stay a rect even after applying
@@ -1204,8 +1196,8 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
SkRect r;
fMCRec->fMatrix->mapRect(&r, rect);
- fClipStack.clipDevRect(r, op, kSoft_ClipEdgeStyle == edgeStyle);
- fMCRec->fRasterClip->op(r, op, kSoft_ClipEdgeStyle == edgeStyle);
+ fClipStack.clipDevRect(r, op, doAA);
+ return fMCRec->fRasterClip->op(r, op, doAA);
} 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
@@ -1214,12 +1206,12 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg
SkPath path;
path.addRect(rect);
- this->SkCanvas::onClipPath(path, op, edgeStyle);
+ return this->SkCanvas::clipPath(path, op, doAA);
}
}
-static void clip_path_helper(const SkCanvas* canvas, SkRasterClip* currClip,
- const SkPath& devPath, SkRegion::Op op, bool doAA) {
+static bool clipPathHelper(const SkCanvas* canvas, SkRasterClip* currClip,
+ const SkPath& devPath, SkRegion::Op op, bool doAA) {
// base is used to limit the size (and therefore memory allocation) of the
// region that results from scan converting devPath.
SkRegion base;
@@ -1232,81 +1224,60 @@ static void clip_path_helper(const SkCanvas* canvas, SkRasterClip* currClip,
// FIXME: we should also be able to do this when currClip->isBW(),
// but relaxing the test above triggers GM asserts in
// SkRgnBuilder::blitH(). We need to investigate what's going on.
- currClip->setPath(devPath, currClip->bwRgn(), doAA);
+ return currClip->setPath(devPath, currClip->bwRgn(), doAA);
} else {
base.setRect(currClip->getBounds());
SkRasterClip clip;
clip.setPath(devPath, base, doAA);
- currClip->op(clip, op);
+ return currClip->op(clip, op);
}
} else {
const SkBaseDevice* device = canvas->getDevice();
if (!device) {
- currClip->setEmpty();
- return;
+ return currClip->setEmpty();
}
base.setRect(0, 0, device->width(), device->height());
if (SkRegion::kReplace_Op == op) {
- currClip->setPath(devPath, base, doAA);
+ return currClip->setPath(devPath, base, doAA);
} else {
SkRasterClip clip;
clip.setPath(devPath, base, doAA);
- currClip->op(clip, op);
+ return currClip->op(clip, op);
}
}
}
bool SkCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
- ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
if (rrect.isRect()) {
- this->onClipRect(rrect.getBounds(), op, edgeStyle);
- } else {
- this->onClipRRect(rrect, op, edgeStyle);
+ // call the non-virtual version
+ return this->SkCanvas::clipRect(rrect.getBounds(), op, doAA);
}
- return !this->isClipEmpty();
-}
-void SkCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
SkRRect transformedRRect;
if (rrect.transform(*fMCRec->fMatrix, &transformedRRect)) {
AutoValidateClip avc(this);
fDeviceCMDirty = true;
fCachedLocalClipBoundsDirty = true;
- if (!fAllowSoftClip) {
- edgeStyle = kHard_ClipEdgeStyle;
- }
+ doAA &= fAllowSoftClip;
- fClipStack.clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == edgeStyle);
+ fClipStack.clipDevRRect(transformedRRect, op, doAA);
SkPath devPath;
devPath.addRRect(transformedRRect);
- clip_path_helper(this, fMCRec->fRasterClip, devPath, op, kSoft_ClipEdgeStyle == edgeStyle);
- return;
+ return clipPathHelper(this, fMCRec->fRasterClip, devPath, op, doAA);
}
SkPath path;
path.addRRect(rrect);
// call the non-virtual version
- this->SkCanvas::onClipPath(path, op, edgeStyle);
+ return this->SkCanvas::clipPath(path, op, doAA);
}
bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
- ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
- SkRect r;
- if (!path.isInverseFillType() && path.isRect(&r)) {
- this->onClipRect(r, op, edgeStyle);
- } else {
- this->onClipPath(path, op, edgeStyle);
- }
-
- return !this->isClipEmpty();
-}
-
-void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
#ifdef SK_ENABLE_CLIP_QUICKREJECT
if (SkRegion::kIntersect_Op == op && !path.isInverseFillType()) {
if (fMCRec->fRasterClip->isEmpty()) {
@@ -1327,9 +1298,7 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg
fDeviceCMDirty = true;
fCachedLocalClipBoundsDirty = true;
- if (!fAllowSoftClip) {
- edgeStyle = kHard_ClipEdgeStyle;
- }
+ doAA &= fAllowSoftClip;
SkPath devPath;
path.transform(*fMCRec->fMatrix, &devPath);
@@ -1345,7 +1314,7 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg
}
// if we called path.swap() we could avoid a deep copy of this path
- fClipStack.clipDevPath(devPath, op, kSoft_ClipEdgeStyle == edgeStyle);
+ fClipStack.clipDevPath(devPath, op, doAA);
if (fAllowSimplifyClip) {
devPath.reset();
@@ -1369,17 +1338,15 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg
// if the prev and curr clips disagree about aa -vs- not, favor the aa request.
// perhaps we need an API change to avoid this sort of mixed-signals about
// clipping.
- if (element->isAA()) {
- edgeStyle = kSoft_ClipEdgeStyle;
- }
+ doAA |= element->isAA();
}
op = SkRegion::kReplace_Op;
}
- clip_path_helper(this, fMCRec->fRasterClip, devPath, op, edgeStyle);
+ return clipPathHelper(this, fMCRec->fRasterClip, devPath, op, doAA);
}
-void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegion::Op op,
+bool SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegion::Op op,
bool inverseFilled) {
// This is for updating the clip conservatively using only bounds
// information.
@@ -1403,7 +1370,7 @@ void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegio
case SkRegion::kDifference_Op:
// These ops can only shrink the current clip. So leaving
// the clip unchanges conservatively respects the contract.
- return;
+ return this->getClipDeviceBounds(NULL);
case SkRegion::kUnion_Op:
case SkRegion::kReplace_Op:
case SkRegion::kReverseDifference_Op:
@@ -1419,9 +1386,10 @@ void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegio
this->SkCanvas::save(SkCanvas::kMatrix_SaveFlag);
// set the clip in device space
this->SkCanvas::setMatrix(SkMatrix::I());
- this->SkCanvas::clipRect(deviceBounds, SkRegion::kReplace_Op, false);
+ bool result = this->SkCanvas::clipRect(deviceBounds,
+ SkRegion::kReplace_Op, false);
this->SkCanvas::restore(); //pop the matrix, but keep the clip
- return;
+ return result;
}
default:
SkASSERT(0); // unhandled op?
@@ -1432,34 +1400,27 @@ void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegio
case SkRegion::kIntersect_Op:
case SkRegion::kUnion_Op:
case SkRegion::kReplace_Op:
- this->SkCanvas::clipRect(bounds, op, false);
- return;
+ return this->SkCanvas::clipRect(bounds, op, false);
case SkRegion::kDifference_Op:
// Difference can only shrink the current clip.
// Leaving clip unchanged conservatively fullfills the contract.
- return;
+ return this->getClipDeviceBounds(NULL);
case SkRegion::kReverseDifference_Op:
// To reverse, we swap in the bounds with a replace op.
// As with difference, leave it unchanged.
- this->SkCanvas::clipRect(bounds, SkRegion::kReplace_Op, false);
- return;
+ return this->SkCanvas::clipRect(bounds, SkRegion::kReplace_Op, false);
case SkRegion::kXOR_Op:
// Be conservative, based on (A XOR B) always included in (A union B),
// which is always included in (bounds(A) union bounds(B))
- this->SkCanvas::clipRect(bounds, SkRegion::kUnion_Op, false);
- return;
+ return this->SkCanvas::clipRect(bounds, SkRegion::kUnion_Op, false);
default:
SkASSERT(0); // unhandled op?
}
}
+ return true;
}
bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) {
- this->onClipRegion(rgn, op);
- return !this->isClipEmpty();
-}
-
-void SkCanvas::onClipRegion(const SkRegion& rgn, SkRegion::Op op) {
AutoValidateClip avc(this);
fDeviceCMDirty = true;
@@ -1469,7 +1430,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);
+ return fMCRec->fRasterClip->op(rgn, op);
}
#ifdef SK_DEBUG
@@ -1499,7 +1460,11 @@ void SkCanvas::validateClip() const {
default: {
SkPath path;
element->asPath(&path);
- clip_path_helper(this, &tmpClip, path, element->getOp(), element->isAA());
+ clipPathHelper(this,
+ &tmpClip,
+ path,
+ element->getOp(),
+ element->isAA());
break;
}
}
@@ -1578,7 +1543,7 @@ bool SkCanvas::quickReject(const SkPath& path) const {
bool SkCanvas::getClipBounds(SkRect* bounds) const {
SkIRect ibounds;
- if (!this->getClipDeviceBounds(&ibounds)) {
+ if (!getClipDeviceBounds(&ibounds)) {
return false;
}
@@ -1623,12 +1588,8 @@ const SkMatrix& SkCanvas::getTotalMatrix() const {
}
SkCanvas::ClipType SkCanvas::getClipType() const {
- if (fMCRec->fRasterClip->isEmpty()) {
- return kEmpty_ClipType;
- }
- if (fMCRec->fRasterClip->isRect()) {
- return kRect_ClipType;
- }
+ if (fMCRec->fRasterClip->isEmpty()) return kEmpty_ClipType;
+ if (fMCRec->fRasterClip->isRect()) return kRect_ClipType;
return kComplex_ClipType;
}
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index f170476241..a8279ca089 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -819,8 +819,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
size_t offsetToRestore = reader.readInt();
SkASSERT(!offsetToRestore || \
offsetToRestore >= reader.offset());
- canvas.clipPath(path, regionOp, doAA);
- if (canvas.isClipEmpty() && offsetToRestore) {
+ if (!canvas.clipPath(path, regionOp, doAA) && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipPath.recordSkip(offsetToRestore - reader.offset());
#endif
@@ -835,8 +834,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
size_t offsetToRestore = reader.readInt();
SkASSERT(!offsetToRestore || \
offsetToRestore >= reader.offset());
- canvas.clipRegion(region, regionOp);
- if (canvas.isClipEmpty() && offsetToRestore) {
+ if (!canvas.clipRegion(region, regionOp) && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipRegion.recordSkip(offsetToRestore - reader.offset());
#endif
@@ -851,8 +849,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
size_t offsetToRestore = reader.readInt();
SkASSERT(!offsetToRestore || \
offsetToRestore >= reader.offset());
- canvas.clipRect(rect, regionOp, doAA);
- if (canvas.isClipEmpty() && offsetToRestore) {
+ if (!canvas.clipRect(rect, regionOp, doAA) && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipRect.recordSkip(offsetToRestore - reader.offset());
#endif
@@ -868,8 +865,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
size_t offsetToRestore = reader.readInt();
SkASSERT(!offsetToRestore || \
offsetToRestore >= reader.offset());
- canvas.clipRRect(rrect, regionOp, doAA);
- if (canvas.isClipEmpty() && offsetToRestore) {
+ if (!canvas.clipRRect(rrect, regionOp, doAA) && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipRRect.recordSkip(offsetToRestore - reader.offset());
#endif
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index dda6f46b10..978e2b37c2 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -847,14 +847,14 @@ int SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) {
}
#endif
-void SkPictureRecord::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
fMCMgr.clipRect(rect, op, doAA);
#else
- this->recordClipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
+ this->recordClipRect(rect, op, doAA);
#endif
- this->INHERITED::onClipRect(rect, op, edgeStyle);
+ return this->INHERITED::clipRect(rect, op, doAA);
}
int SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
@@ -878,17 +878,20 @@ int SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool do
return offset;
}
-void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkPictureRecord::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
+ if (rrect.isRect()) {
+ return this->SkPictureRecord::clipRect(rrect.getBounds(), op, doAA);
+ }
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
fMCMgr.clipRRect(rrect, op, doAA);
#else
- this->recordClipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
+ this->recordClipRRect(rrect, op, doAA);
#endif
if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) {
- this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
+ return this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
} else {
- this->INHERITED::onClipRRect(rrect, op, edgeStyle);
+ return this->INHERITED::clipRRect(rrect, op, doAA);
}
}
@@ -912,20 +915,25 @@ int SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool
return offset;
}
-void SkPictureRecord::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+bool SkPictureRecord::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
+
+ SkRect r;
+ if (!path.isInverseFillType() && path.isRect(&r)) {
+ return this->clipRect(r, op, doAA);
+ }
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
fMCMgr.clipPath(path, op, doAA);
#else
int pathID = this->addPathToHeap(path);
- this->recordClipPath(pathID, op, kSoft_ClipEdgeStyle == edgeStyle);
+ this->recordClipPath(pathID, op, doAA);
#endif
if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) {
- this->updateClipConservativelyUsingBounds(path.getBounds(), op,
- path.isInverseFillType());
+ return this->updateClipConservativelyUsingBounds(path.getBounds(), op,
+ path.isInverseFillType());
} else {
- this->INHERITED::onClipPath(path, op, edgeStyle);
+ return this->INHERITED::clipPath(path, op, doAA);
}
}
@@ -949,14 +957,14 @@ int SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) {
return offset;
}
-void SkPictureRecord::onClipRegion(const SkRegion& region, SkRegion::Op op) {
+bool SkPictureRecord::clipRegion(const SkRegion& region, SkRegion::Op op) {
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
fMCMgr.clipRegion(region, op);
#else
this->recordClipRegion(region, op);
#endif
- this->INHERITED::onClipRegion(region, op);
+ return this->INHERITED::clipRegion(region, op);
}
int SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op) {
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 1b62f3dadc..dc439a108d 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -45,6 +45,10 @@ public:
virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) 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& region, SkRegion::Op op) SK_OVERRIDE;
virtual void clear(SkColor) SK_OVERRIDE;
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
@@ -224,11 +228,6 @@ protected:
virtual void onPushCull(const SkRect&) 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&, SkRegion::Op) SK_OVERRIDE;
-
// Return fontmetrics.fTop,fBottom in topbot[0,1], after they have been
// tweaked by paint.computeFastBounds().
static void ComputeFontMetricsTopBottom(const SkPaint& paint, SkScalar topbot[2]);
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 43209f644b..879ce8288b 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -240,6 +240,11 @@ public:
virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
+ virtual bool clipRect(const SkRect&, SkRegion::Op op, bool doAntiAlias = false) SK_OVERRIDE;
+ virtual bool clipRRect(const SkRRect&, SkRegion::Op op, bool doAntiAlias = false) SK_OVERRIDE;
+ virtual bool clipPath(const SkPath& path, SkRegion::Op op,
+ bool doAntiAlias = false) SK_OVERRIDE;
+ virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE;
virtual void clear(SkColor) SK_OVERRIDE;
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
@@ -289,11 +294,6 @@ public:
protected:
virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) 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&, SkRegion::Op) SK_OVERRIDE;
-
private:
enum {
kNoSaveLayer = -1,
@@ -635,56 +635,47 @@ void SkGPipeCanvas::setMatrix(const SkMatrix& matrix) {
this->INHERITED::setMatrix(matrix);
}
-void SkGPipeCanvas::onClipRect(const SkRect& rect, SkRegion::Op rgnOp,
- ClipEdgeStyle edgeStyle) {
+bool SkGPipeCanvas::clipRect(const SkRect& rect, SkRegion::Op rgnOp,
+ bool doAntiAlias) {
NOTIFY_SETUP(this);
if (this->needOpBytes(sizeof(SkRect))) {
- unsigned flags = 0;
- if (kSoft_ClipEdgeStyle == edgeStyle) {
- flags = kClip_HasAntiAlias_DrawOpFlag;
- }
+ unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag;
this->writeOp(kClipRect_DrawOp, flags, rgnOp);
fWriter.writeRect(rect);
}
- this->INHERITED::onClipRect(rect, rgnOp, edgeStyle);
+ return this->INHERITED::clipRect(rect, rgnOp, doAntiAlias);
}
-void SkGPipeCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op rgnOp,
- ClipEdgeStyle edgeStyle) {
+bool SkGPipeCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op rgnOp,
+ bool doAntiAlias) {
NOTIFY_SETUP(this);
if (this->needOpBytes(kSizeOfFlatRRect)) {
- unsigned flags = 0;
- if (kSoft_ClipEdgeStyle == edgeStyle) {
- flags = kClip_HasAntiAlias_DrawOpFlag;
- }
+ unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag;
this->writeOp(kClipRRect_DrawOp, flags, rgnOp);
fWriter.writeRRect(rrect);
}
- this->INHERITED::onClipRRect(rrect, rgnOp, edgeStyle);
+ return this->INHERITED::clipRRect(rrect, rgnOp, doAntiAlias);
}
-void SkGPipeCanvas::onClipPath(const SkPath& path, SkRegion::Op rgnOp,
- ClipEdgeStyle edgeStyle) {
+bool SkGPipeCanvas::clipPath(const SkPath& path, SkRegion::Op rgnOp,
+ bool doAntiAlias) {
NOTIFY_SETUP(this);
if (this->needOpBytes(path.writeToMemory(NULL))) {
- unsigned flags = 0;
- if (kSoft_ClipEdgeStyle == edgeStyle) {
- flags = kClip_HasAntiAlias_DrawOpFlag;
- }
+ unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag;
this->writeOp(kClipPath_DrawOp, flags, rgnOp);
fWriter.writePath(path);
}
// we just pass on the bounds of the path
- this->INHERITED::onClipRect(path.getBounds(), rgnOp, edgeStyle);
+ return this->INHERITED::clipRect(path.getBounds(), rgnOp, doAntiAlias);
}
-void SkGPipeCanvas::onClipRegion(const SkRegion& region, SkRegion::Op rgnOp) {
+bool SkGPipeCanvas::clipRegion(const SkRegion& region, SkRegion::Op rgnOp) {
NOTIFY_SETUP(this);
if (this->needOpBytes(region.writeToMemory(NULL))) {
this->writeOp(kClipRegion_DrawOp, 0, rgnOp);
fWriter.writeRegion(region);
}
- this->INHERITED::onClipRegion(region, rgnOp);
+ return this->INHERITED::clipRegion(region, rgnOp);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/utils/SkCanvasStack.cpp b/src/utils/SkCanvasStack.cpp
index d85f34b506..8951149b42 100644
--- a/src/utils/SkCanvasStack.cpp
+++ b/src/utils/SkCanvasStack.cpp
@@ -77,22 +77,25 @@ void SkCanvasStack::setMatrix(const SkMatrix& matrix) {
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 @@ void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
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 ba2fed4932..5311118270 100644
--- a/src/utils/SkCanvasStack.h
+++ b/src/utils/SkCanvasStack.h
@@ -30,12 +30,11 @@ public:
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 09494c9aaa..3911fd0dfa 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -789,34 +789,39 @@ void SkDeferredCanvas::setMatrix(const SkMatrix& matrix) {
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 4805d6287c..d768137578 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -261,40 +261,40 @@ void SkDumpCanvas::setMatrix(const SkMatrix& matrix) {
///////////////////////////////////////////////////////////////////////////////
-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 0f13073049..8c25dc0401 100644
--- a/src/utils/SkLuaCanvas.cpp
+++ b/src/utils/SkLuaCanvas.cpp
@@ -139,30 +139,30 @@ void SkLuaCanvas::setMatrix(const SkMatrix& matrix) {
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 a9543f9c02..27adc6d51d 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -130,36 +130,36 @@ void SkNWayCanvas::setMatrix(const SkMatrix& matrix) {
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 60fad87237..58d28b40b1 100644
--- a/src/utils/SkNoSaveLayerCanvas.h
+++ b/src/utils/SkNoSaveLayerCanvas.h
@@ -32,20 +32,25 @@ public:
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 0a9d7a80c2..245e0a6969 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -58,20 +58,20 @@ void SkProxyCanvas::setMatrix(const SkMatrix& matrix) {
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 fedef697aa..15165c27e2 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -43,8 +43,7 @@ SkDebugCanvas::SkDebugCanvas(int width, int height)
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 @@ void SkDebugCanvas::clear(SkColor color) {
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 11771a4e3e..7d496274ac 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -143,6 +143,16 @@ public:
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 @@ public:
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;
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index c6afb1f9da..89f0af43fb 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -982,30 +982,22 @@ public:
, fClipCount(0){
}
- virtual void onClipRect(const SkRect& r,
- SkRegion::Op op,
- ClipEdgeStyle edgeStyle) SK_OVERRIDE {
+ virtual bool clipRect(const SkRect& r, SkRegion::Op op, bool doAA)
+ SK_OVERRIDE {
fClipCount += 1;
- this->INHERITED::onClipRect(r, op, edgeStyle);
+ return this->INHERITED::clipRect(r, op, doAA);
}
- virtual void onClipRRect(const SkRRect& rrect,
- SkRegion::Op op,
- ClipEdgeStyle edgeStyle)SK_OVERRIDE {
+ virtual bool clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA)
+ SK_OVERRIDE {
fClipCount += 1;
- this->INHERITED::onClipRRect(rrect, op, edgeStyle);
+ return this->INHERITED::clipRRect(rrect, op, doAA);
}
- virtual void onClipPath(const SkPath& path,
- SkRegion::Op op,
- ClipEdgeStyle edgeStyle) SK_OVERRIDE {
+ virtual bool clipPath(const SkPath& path, SkRegion::Op op, bool doAA)
+ SK_OVERRIDE {
fClipCount += 1;
- this->INHERITED::onClipPath(path, op, edgeStyle);
- }
-
- virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) SK_OVERRIDE {
- fClipCount += 1;
- this->INHERITED::onClipRegion(deviceRgn, op);
+ return this->INHERITED::clipPath(path, op, doAA);
}
unsigned getClipCount() const { return fClipCount; }