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, 386 insertions, 326 deletions
diff --git a/experimental/PdfViewer/SkNulCanvas.h b/experimental/PdfViewer/SkNulCanvas.h
index 8ec2d32d0f..506d49f35f 100644
--- a/experimental/PdfViewer/SkNulCanvas.h
+++ b/experimental/PdfViewer/SkNulCanvas.h
@@ -26,78 +26,89 @@ public:
explicit SkNulCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap) {}
virtual ~SkNulCanvas() {}
- virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) {return 0;}
+ virtual int save(SaveFlags flags = kMatrixClip_SaveFlag) SK_OVERRIDE {return 0;}
virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags = kARGB_ClipLayer_SaveFlag) {return 0;}
+ SaveFlags flags = kARGB_ClipLayer_SaveFlag) SK_OVERRIDE {return 0;}
int saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
SaveFlags flags = kARGB_ClipLayer_SaveFlag) {return 0;}
- virtual void restore() {}
+ virtual void restore() SK_OVERRIDE {}
int getSaveCount() const {return 0;}
- 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 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 void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
- 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) {}
+ 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 {}
virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
- const SkPaint* paint = NULL) {}
+ const SkPaint* paint = NULL) SK_OVERRIDE {}
virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst,
const SkPaint* paint,
- DrawBitmapRectFlags flags) {}
+ DrawBitmapRectFlags flags) SK_OVERRIDE {}
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
- const SkPaint* paint = NULL) {}
+ const SkPaint* paint = NULL) SK_OVERRIDE {}
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
- const SkRect& dst, const SkPaint* paint = NULL) {}
+ const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE {}
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
- const SkPaint* paint = NULL) {}
+ const SkPaint* paint = NULL) SK_OVERRIDE {}
virtual void drawText(const void* text, size_t byteLength, SkScalar x,
- SkScalar y, const SkPaint& paint) {}
+ SkScalar y, const SkPaint& paint) SK_OVERRIDE {}
virtual void drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint& paint) {}
+ const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE {}
virtual void drawPosTextH(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
- const SkPaint& paint) {}
+ const SkPaint& paint) SK_OVERRIDE {}
virtual void drawTextOnPath(const void* text, size_t byteLength,
const SkPath& path, const SkMatrix* matrix,
- const SkPaint& paint) {}
- virtual void drawPicture(SkPicture& picture) {}
+ const SkPaint& paint) SK_OVERRIDE {}
+ virtual void drawPicture(SkPicture& picture) SK_OVERRIDE {}
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) {}
- 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;}
+ 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;
+ }
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 b73a1e48ca..27ff8bb493 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -481,10 +481,9 @@ 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
*/
- bool setClipRegion(const SkRegion& deviceRgn) {
- return this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
+ void setClipRegion(const SkRegion& deviceRgn) {
+ this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
}
/** Return true if the specified rectangle, after being transformed by the
@@ -548,13 +547,13 @@ public:
in a way similar to quickReject, in that it tells you that drawing
outside of these bounds will be clipped out.
*/
- bool getClipBounds(SkRect* bounds) const;
+ virtual 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.
*/
- bool getClipDeviceBounds(SkIRect* bounds) const;
+ virtual bool getClipDeviceBounds(SkIRect* bounds) const;
/** Fill the entire canvas' bitmap (restricted to the current clip) with the
@@ -1031,7 +1030,7 @@ public:
* result, subsequent calls will be cheap (until the clip state changes,
* which can happen on any clip..() or restore() call.
*/
- bool isClipEmpty() const;
+ virtual bool isClipEmpty() const;
/** Return the current matrix on the canvas.
This does not account for the translate in any of the devices.
@@ -1048,7 +1047,7 @@ public:
/** Returns a description of the total clip; may be cheaper than
getting the clip and querying it directly.
*/
- ClipType getClipType() const;
+ virtual ClipType getClipType() const;
/** DEPRECATED -- need to move this guy to private/friend
* Return the current device clip (concatenation of all clip calls).
@@ -1130,6 +1129,16 @@ 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
@@ -1146,7 +1155,7 @@ protected:
// Called by child classes that override clipPath and clipRRect to only
// track fast conservative clip bounds, rather than exact clips.
- bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op,
+ void 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 d028282ef2..b26ddbc952 100644
--- a/include/utils/SkDeferredCanvas.h
+++ b/include/utils/SkDeferredCanvas.h
@@ -149,14 +149,6 @@ 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[],
@@ -204,6 +196,11 @@ 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 fe4d175354..5e3249cbee 100644
--- a/include/utils/SkDumpCanvas.h
+++ b/include/utils/SkDumpCanvas.h
@@ -86,12 +86,6 @@ 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;
@@ -134,6 +128,13 @@ 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 be1cf4d049..a4f30bc349 100644
--- a/include/utils/SkLuaCanvas.h
+++ b/include/utils/SkLuaCanvas.h
@@ -32,12 +32,6 @@ 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;
@@ -75,6 +69,11 @@ 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 d83dd6ed77..84f4b4a177 100644
--- a/include/utils/SkNWayCanvas.h
+++ b/include/utils/SkNWayCanvas.h
@@ -33,11 +33,6 @@ 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[],
@@ -88,6 +83,11 @@ 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 f192e54a51..d682ba3b44 100644
--- a/include/utils/SkProxyCanvas.h
+++ b/include/utils/SkProxyCanvas.h
@@ -38,12 +38,6 @@ 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;
@@ -88,6 +82,11 @@ 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 b120b1da87..5d310be7bc 100644
--- a/src/core/SkBBoxHierarchyRecord.cpp
+++ b/src/core/SkBBoxHierarchyRecord.cpp
@@ -77,31 +77,31 @@ void SkBBoxHierarchyRecord::setMatrix(const SkMatrix& matrix) {
fStateTree->appendTransform(getTotalMatrix());
}
-bool SkBBoxHierarchyRecord::clipRect(const SkRect& rect,
- SkRegion::Op op,
- bool doAntiAlias) {
+void SkBBoxHierarchyRecord::onClipRect(const SkRect& rect,
+ SkRegion::Op op,
+ ClipEdgeStyle edgeStyle) {
fStateTree->appendClip(this->writeStream().bytesWritten());
- return INHERITED::clipRect(rect, op, doAntiAlias);
+ this->INHERITED::onClipRect(rect, op, edgeStyle);
}
-bool SkBBoxHierarchyRecord::clipRegion(const SkRegion& region,
- SkRegion::Op op) {
+void SkBBoxHierarchyRecord::onClipRegion(const SkRegion& region,
+ SkRegion::Op op) {
fStateTree->appendClip(this->writeStream().bytesWritten());
- return INHERITED::clipRegion(region, op);
+ this->INHERITED::onClipRegion(region, op);
}
-bool SkBBoxHierarchyRecord::clipPath(const SkPath& path,
- SkRegion::Op op,
- bool doAntiAlias) {
+void SkBBoxHierarchyRecord::onClipPath(const SkPath& path,
+ SkRegion::Op op,
+ ClipEdgeStyle edgeStyle) {
fStateTree->appendClip(this->writeStream().bytesWritten());
- return INHERITED::clipPath(path, op, doAntiAlias);
+ this->INHERITED::onClipPath(path, op, edgeStyle);
}
-bool SkBBoxHierarchyRecord::clipRRect(const SkRRect& rrect,
- SkRegion::Op op,
- bool doAntiAlias) {
+void SkBBoxHierarchyRecord::onClipRRect(const SkRRect& rrect,
+ SkRegion::Op op,
+ ClipEdgeStyle edgeStyle) {
fStateTree->appendClip(this->writeStream().bytesWritten());
- return INHERITED::clipRRect(rrect, op, doAntiAlias);
+ this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
bool SkBBoxHierarchyRecord::shouldRewind(void* data) {
diff --git a/src/core/SkBBoxHierarchyRecord.h b/src/core/SkBBoxHierarchyRecord.h
index f264334807..80f59c3907 100644
--- a/src/core/SkBBoxHierarchyRecord.h
+++ b/src/core/SkBBoxHierarchyRecord.h
@@ -35,21 +35,15 @@ 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 bc14974b7d..7851fdbb81 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1166,6 +1166,12 @@ 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()) {
@@ -1186,7 +1192,9 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
fDeviceCMDirty = true;
fCachedLocalClipBoundsDirty = true;
- doAA &= fAllowSoftClip;
+ if (!fAllowSoftClip) {
+ edgeStyle = kHard_ClipEdgeStyle;
+ }
if (fMCRec->fMatrix->rectStaysRect()) {
// for these simpler matrices, we can stay a rect even after applying
@@ -1196,8 +1204,8 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
SkRect r;
fMCRec->fMatrix->mapRect(&r, rect);
- fClipStack.clipDevRect(r, op, doAA);
- return fMCRec->fRasterClip->op(r, op, doAA);
+ fClipStack.clipDevRect(r, op, kSoft_ClipEdgeStyle == edgeStyle);
+ fMCRec->fRasterClip->op(r, op, kSoft_ClipEdgeStyle == edgeStyle);
} 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
@@ -1206,12 +1214,12 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
SkPath path;
path.addRect(rect);
- return this->SkCanvas::clipPath(path, op, doAA);
+ this->SkCanvas::onClipPath(path, op, edgeStyle);
}
}
-static bool clipPathHelper(const SkCanvas* canvas, SkRasterClip* currClip,
- const SkPath& devPath, SkRegion::Op op, bool doAA) {
+static void clip_path_helper(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;
@@ -1224,60 +1232,81 @@ static bool clipPathHelper(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.
- return currClip->setPath(devPath, currClip->bwRgn(), doAA);
+ currClip->setPath(devPath, currClip->bwRgn(), doAA);
} else {
base.setRect(currClip->getBounds());
SkRasterClip clip;
clip.setPath(devPath, base, doAA);
- return currClip->op(clip, op);
+ currClip->op(clip, op);
}
} else {
const SkBaseDevice* device = canvas->getDevice();
if (!device) {
- return currClip->setEmpty();
+ currClip->setEmpty();
+ return;
}
base.setRect(0, 0, device->width(), device->height());
if (SkRegion::kReplace_Op == op) {
- return currClip->setPath(devPath, base, doAA);
+ currClip->setPath(devPath, base, doAA);
} else {
SkRasterClip clip;
clip.setPath(devPath, base, doAA);
- return currClip->op(clip, op);
+ 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()) {
- // call the non-virtual version
- return this->SkCanvas::clipRect(rrect.getBounds(), op, doAA);
+ this->onClipRect(rrect.getBounds(), op, edgeStyle);
+ } else {
+ this->onClipRRect(rrect, op, edgeStyle);
}
+ 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;
- doAA &= fAllowSoftClip;
+ if (!fAllowSoftClip) {
+ edgeStyle = kHard_ClipEdgeStyle;
+ }
- fClipStack.clipDevRRect(transformedRRect, op, doAA);
+ fClipStack.clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == edgeStyle);
SkPath devPath;
devPath.addRRect(transformedRRect);
- return clipPathHelper(this, fMCRec->fRasterClip, devPath, op, doAA);
+ clip_path_helper(this, fMCRec->fRasterClip, devPath, op, kSoft_ClipEdgeStyle == edgeStyle);
+ return;
}
SkPath path;
path.addRRect(rrect);
// call the non-virtual version
- return this->SkCanvas::clipPath(path, op, doAA);
+ this->SkCanvas::onClipPath(path, op, edgeStyle);
}
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()) {
@@ -1298,7 +1327,9 @@ bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
fDeviceCMDirty = true;
fCachedLocalClipBoundsDirty = true;
- doAA &= fAllowSoftClip;
+ if (!fAllowSoftClip) {
+ edgeStyle = kHard_ClipEdgeStyle;
+ }
SkPath devPath;
path.transform(*fMCRec->fMatrix, &devPath);
@@ -1314,7 +1345,7 @@ bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
}
// if we called path.swap() we could avoid a deep copy of this path
- fClipStack.clipDevPath(devPath, op, doAA);
+ fClipStack.clipDevPath(devPath, op, kSoft_ClipEdgeStyle == edgeStyle);
if (fAllowSimplifyClip) {
devPath.reset();
@@ -1338,15 +1369,17 @@ bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
// 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.
- doAA |= element->isAA();
+ if (element->isAA()) {
+ edgeStyle = kSoft_ClipEdgeStyle;
+ }
}
op = SkRegion::kReplace_Op;
}
- return clipPathHelper(this, fMCRec->fRasterClip, devPath, op, doAA);
+ clip_path_helper(this, fMCRec->fRasterClip, devPath, op, edgeStyle);
}
-bool SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegion::Op op,
+void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegion::Op op,
bool inverseFilled) {
// This is for updating the clip conservatively using only bounds
// information.
@@ -1370,7 +1403,7 @@ bool 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 this->getClipDeviceBounds(NULL);
+ return;
case SkRegion::kUnion_Op:
case SkRegion::kReplace_Op:
case SkRegion::kReverseDifference_Op:
@@ -1386,10 +1419,9 @@ bool SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegio
this->SkCanvas::save(SkCanvas::kMatrix_SaveFlag);
// set the clip in device space
this->SkCanvas::setMatrix(SkMatrix::I());
- bool result = this->SkCanvas::clipRect(deviceBounds,
- SkRegion::kReplace_Op, false);
+ this->SkCanvas::clipRect(deviceBounds, SkRegion::kReplace_Op, false);
this->SkCanvas::restore(); //pop the matrix, but keep the clip
- return result;
+ return;
}
default:
SkASSERT(0); // unhandled op?
@@ -1400,27 +1432,34 @@ bool SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegio
case SkRegion::kIntersect_Op:
case SkRegion::kUnion_Op:
case SkRegion::kReplace_Op:
- return this->SkCanvas::clipRect(bounds, op, false);
+ this->SkCanvas::clipRect(bounds, op, false);
+ return;
case SkRegion::kDifference_Op:
// Difference can only shrink the current clip.
// Leaving clip unchanged conservatively fullfills the contract.
- return this->getClipDeviceBounds(NULL);
+ return;
case SkRegion::kReverseDifference_Op:
// To reverse, we swap in the bounds with a replace op.
// As with difference, leave it unchanged.
- return this->SkCanvas::clipRect(bounds, SkRegion::kReplace_Op, false);
+ this->SkCanvas::clipRect(bounds, SkRegion::kReplace_Op, false);
+ return;
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))
- return this->SkCanvas::clipRect(bounds, SkRegion::kUnion_Op, false);
+ this->SkCanvas::clipRect(bounds, SkRegion::kUnion_Op, false);
+ return;
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;
@@ -1430,7 +1469,7 @@ bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) {
// we have to ignore it, and use the region directly?
fClipStack.clipDevRect(rgn.getBounds(), op);
- return fMCRec->fRasterClip->op(rgn, op);
+ fMCRec->fRasterClip->op(rgn, op);
}
#ifdef SK_DEBUG
@@ -1460,11 +1499,7 @@ void SkCanvas::validateClip() const {
default: {
SkPath path;
element->asPath(&path);
- clipPathHelper(this,
- &tmpClip,
- path,
- element->getOp(),
- element->isAA());
+ clip_path_helper(this, &tmpClip, path, element->getOp(), element->isAA());
break;
}
}
@@ -1543,7 +1578,7 @@ bool SkCanvas::quickReject(const SkPath& path) const {
bool SkCanvas::getClipBounds(SkRect* bounds) const {
SkIRect ibounds;
- if (!getClipDeviceBounds(&ibounds)) {
+ if (!this->getClipDeviceBounds(&ibounds)) {
return false;
}
@@ -1588,8 +1623,12 @@ 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 a8279ca089..f170476241 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -819,7 +819,8 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
size_t offsetToRestore = reader.readInt();
SkASSERT(!offsetToRestore || \
offsetToRestore >= reader.offset());
- if (!canvas.clipPath(path, regionOp, doAA) && offsetToRestore) {
+ canvas.clipPath(path, regionOp, doAA);
+ if (canvas.isClipEmpty() && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipPath.recordSkip(offsetToRestore - reader.offset());
#endif
@@ -834,7 +835,8 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
size_t offsetToRestore = reader.readInt();
SkASSERT(!offsetToRestore || \
offsetToRestore >= reader.offset());
- if (!canvas.clipRegion(region, regionOp) && offsetToRestore) {
+ canvas.clipRegion(region, regionOp);
+ if (canvas.isClipEmpty() && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipRegion.recordSkip(offsetToRestore - reader.offset());
#endif
@@ -849,7 +851,8 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
size_t offsetToRestore = reader.readInt();
SkASSERT(!offsetToRestore || \
offsetToRestore >= reader.offset());
- if (!canvas.clipRect(rect, regionOp, doAA) && offsetToRestore) {
+ canvas.clipRect(rect, regionOp, doAA);
+ if (canvas.isClipEmpty() && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipRect.recordSkip(offsetToRestore - reader.offset());
#endif
@@ -865,7 +868,8 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
size_t offsetToRestore = reader.readInt();
SkASSERT(!offsetToRestore || \
offsetToRestore >= reader.offset());
- if (!canvas.clipRRect(rrect, regionOp, doAA) && offsetToRestore) {
+ canvas.clipRRect(rrect, regionOp, doAA);
+ if (canvas.isClipEmpty() && offsetToRestore) {
#ifdef SPEW_CLIP_SKIPPING
skipRRect.recordSkip(offsetToRestore - reader.offset());
#endif
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 978e2b37c2..dda6f46b10 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -847,14 +847,14 @@ int SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) {
}
#endif
-bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
+void SkPictureRecord::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
fMCMgr.clipRect(rect, op, doAA);
#else
- this->recordClipRect(rect, op, doAA);
+ this->recordClipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
#endif
- return this->INHERITED::clipRect(rect, op, doAA);
+ this->INHERITED::onClipRect(rect, op, edgeStyle);
}
int SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
@@ -878,20 +878,17 @@ int SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool do
return offset;
}
-bool SkPictureRecord::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
- if (rrect.isRect()) {
- return this->SkPictureRecord::clipRect(rrect.getBounds(), op, doAA);
- }
+void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
fMCMgr.clipRRect(rrect, op, doAA);
#else
- this->recordClipRRect(rrect, op, doAA);
+ this->recordClipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
#endif
if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) {
- return this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
+ this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
} else {
- return this->INHERITED::clipRRect(rrect, op, doAA);
+ this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
}
@@ -915,25 +912,20 @@ int SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool
return offset;
}
-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);
- }
+void SkPictureRecord::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
fMCMgr.clipPath(path, op, doAA);
#else
int pathID = this->addPathToHeap(path);
- this->recordClipPath(pathID, op, doAA);
+ this->recordClipPath(pathID, op, kSoft_ClipEdgeStyle == edgeStyle);
#endif
if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) {
- return this->updateClipConservativelyUsingBounds(path.getBounds(), op,
- path.isInverseFillType());
+ this->updateClipConservativelyUsingBounds(path.getBounds(), op,
+ path.isInverseFillType());
} else {
- return this->INHERITED::clipPath(path, op, doAA);
+ this->INHERITED::onClipPath(path, op, edgeStyle);
}
}
@@ -957,14 +949,14 @@ int SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) {
return offset;
}
-bool SkPictureRecord::clipRegion(const SkRegion& region, SkRegion::Op op) {
+void SkPictureRecord::onClipRegion(const SkRegion& region, SkRegion::Op op) {
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
fMCMgr.clipRegion(region, op);
#else
this->recordClipRegion(region, op);
#endif
- return this->INHERITED::clipRegion(region, op);
+ this->INHERITED::onClipRegion(region, op);
}
int SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op) {
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index dc439a108d..1b62f3dadc 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -45,10 +45,6 @@ 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[],
@@ -228,6 +224,11 @@ 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 879ce8288b..43209f644b 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -240,11 +240,6 @@ 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[],
@@ -294,6 +289,11 @@ 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,47 +635,56 @@ void SkGPipeCanvas::setMatrix(const SkMatrix& matrix) {
this->INHERITED::setMatrix(matrix);
}
-bool SkGPipeCanvas::clipRect(const SkRect& rect, SkRegion::Op rgnOp,
- bool doAntiAlias) {
+void SkGPipeCanvas::onClipRect(const SkRect& rect, SkRegion::Op rgnOp,
+ ClipEdgeStyle edgeStyle) {
NOTIFY_SETUP(this);
if (this->needOpBytes(sizeof(SkRect))) {
- unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag;
+ unsigned flags = 0;
+ if (kSoft_ClipEdgeStyle == edgeStyle) {
+ flags = kClip_HasAntiAlias_DrawOpFlag;
+ }
this->writeOp(kClipRect_DrawOp, flags, rgnOp);
fWriter.writeRect(rect);
}
- return this->INHERITED::clipRect(rect, rgnOp, doAntiAlias);
+ this->INHERITED::onClipRect(rect, rgnOp, edgeStyle);
}
-bool SkGPipeCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op rgnOp,
- bool doAntiAlias) {
+void SkGPipeCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op rgnOp,
+ ClipEdgeStyle edgeStyle) {
NOTIFY_SETUP(this);
if (this->needOpBytes(kSizeOfFlatRRect)) {
- unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag;
+ unsigned flags = 0;
+ if (kSoft_ClipEdgeStyle == edgeStyle) {
+ flags = kClip_HasAntiAlias_DrawOpFlag;
+ }
this->writeOp(kClipRRect_DrawOp, flags, rgnOp);
fWriter.writeRRect(rrect);
}
- return this->INHERITED::clipRRect(rrect, rgnOp, doAntiAlias);
+ this->INHERITED::onClipRRect(rrect, rgnOp, edgeStyle);
}
-bool SkGPipeCanvas::clipPath(const SkPath& path, SkRegion::Op rgnOp,
- bool doAntiAlias) {
+void SkGPipeCanvas::onClipPath(const SkPath& path, SkRegion::Op rgnOp,
+ ClipEdgeStyle edgeStyle) {
NOTIFY_SETUP(this);
if (this->needOpBytes(path.writeToMemory(NULL))) {
- unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag;
+ unsigned flags = 0;
+ if (kSoft_ClipEdgeStyle == edgeStyle) {
+ flags = kClip_HasAntiAlias_DrawOpFlag;
+ }
this->writeOp(kClipPath_DrawOp, flags, rgnOp);
fWriter.writePath(path);
}
// we just pass on the bounds of the path
- return this->INHERITED::clipRect(path.getBounds(), rgnOp, doAntiAlias);
+ this->INHERITED::onClipRect(path.getBounds(), rgnOp, edgeStyle);
}
-bool SkGPipeCanvas::clipRegion(const SkRegion& region, SkRegion::Op rgnOp) {
+void SkGPipeCanvas::onClipRegion(const SkRegion& region, SkRegion::Op rgnOp) {
NOTIFY_SETUP(this);
if (this->needOpBytes(region.writeToMemory(NULL))) {
this->writeOp(kClipRegion_DrawOp, 0, rgnOp);
fWriter.writeRegion(region);
}
- return this->INHERITED::clipRegion(region, rgnOp);
+ this->INHERITED::onClipRegion(region, rgnOp);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/utils/SkCanvasStack.cpp b/src/utils/SkCanvasStack.cpp
index 8951149b42..d85f34b506 100644
--- a/src/utils/SkCanvasStack.cpp
+++ b/src/utils/SkCanvasStack.cpp
@@ -77,25 +77,22 @@ void SkCanvasStack::setMatrix(const SkMatrix& matrix) {
this->SkCanvas::setMatrix(matrix);
}
-bool SkCanvasStack::clipRect(const SkRect& r, SkRegion::Op op, bool aa) {
- bool result = this->INHERITED::clipRect(r, op, aa);
+void SkCanvasStack::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+ this->INHERITED::onClipRect(r, op, edgeStyle);
this->clipToZOrderedBounds();
- return result;
}
-bool SkCanvasStack::clipRRect(const SkRRect& rr, SkRegion::Op op, bool aa) {
- bool result = this->INHERITED::clipRRect(rr, op, aa);
+void SkCanvasStack::onClipRRect(const SkRRect& rr, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+ this->INHERITED::onClipRRect(rr, op, edgeStyle);
this->clipToZOrderedBounds();
- return result;
}
-bool SkCanvasStack::clipPath(const SkPath& p, SkRegion::Op op, bool aa) {
- bool result = this->INHERITED::clipPath(p, op, aa);
+void SkCanvasStack::onClipPath(const SkPath& p, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+ this->INHERITED::onClipPath(p, op, edgeStyle);
this->clipToZOrderedBounds();
- return result;
}
-bool SkCanvasStack::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
SkASSERT(fList.count() == fCanvasData.count());
for (int i = 0; i < fList.count(); ++i) {
SkRegion tempRegion;
@@ -104,5 +101,5 @@ bool SkCanvasStack::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op);
fList[i]->clipRegion(tempRegion, op);
}
- return this->SkCanvas::clipRegion(deviceRgn, op);
+ this->SkCanvas::onClipRegion(deviceRgn, op);
}
diff --git a/src/utils/SkCanvasStack.h b/src/utils/SkCanvasStack.h
index 5311118270..ba2fed4932 100644
--- a/src/utils/SkCanvasStack.h
+++ b/src/utils/SkCanvasStack.h
@@ -30,11 +30,12 @@ public:
virtual void removeCanvas(SkCanvas*) SK_OVERRIDE { SkDEBUGFAIL("Invalid Op"); }
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;
+
+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:
void clipToZOrderedBounds();
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 3911fd0dfa..09494c9aaa 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -789,39 +789,34 @@ void SkDeferredCanvas::setMatrix(const SkMatrix& matrix) {
this->recordedDrawCommand();
}
-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);
+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);
this->recordedDrawCommand();
- return val;
}
-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);
+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);
this->recordedDrawCommand();
- return val;
}
-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);
+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);
this->recordedDrawCommand();
- return val;
}
-bool SkDeferredCanvas::clipRegion(const SkRegion& deviceRgn,
- SkRegion::Op op) {
+void SkDeferredCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
this->drawingCanvas()->clipRegion(deviceRgn, op);
- bool val = this->INHERITED::clipRegion(deviceRgn, op);
+ this->INHERITED::onClipRegion(deviceRgn, op);
this->recordedDrawCommand();
- return val;
}
void SkDeferredCanvas::clear(SkColor color) {
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index d768137578..4805d6287c 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -261,40 +261,40 @@ void SkDumpCanvas::setMatrix(const SkMatrix& matrix) {
///////////////////////////////////////////////////////////////////////////////
-static const char* bool_to_aastring(bool doAA) {
- return doAA ? "AA" : "BW";
+const char* SkDumpCanvas::EdgeStyleToAAString(ClipEdgeStyle edgeStyle) {
+ return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW";
}
-bool SkDumpCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
+void SkDumpCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
SkString str;
toString(rect, &str);
this->dump(kClip_Verb, NULL, "clipRect(%s %s %s)", str.c_str(), toString(op),
- bool_to_aastring(doAA));
- return this->INHERITED::clipRect(rect, op, doAA);
+ EdgeStyleToAAString(edgeStyle));
+ this->INHERITED::onClipRect(rect, op, edgeStyle);
}
-bool SkDumpCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
+void SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
SkString str;
toString(rrect, &str);
this->dump(kClip_Verb, NULL, "clipRRect(%s %s %s)", str.c_str(), toString(op),
- bool_to_aastring(doAA));
- return this->INHERITED::clipRRect(rrect, op, doAA);
+ EdgeStyleToAAString(edgeStyle));
+ this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
-bool SkDumpCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
+void SkDumpCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
SkString str;
toString(path, &str);
this->dump(kClip_Verb, NULL, "clipPath(%s %s %s)", str.c_str(), toString(op),
- bool_to_aastring(doAA));
- return this->INHERITED::clipPath(path, op, doAA);
+ EdgeStyleToAAString(edgeStyle));
+ this->INHERITED::onClipPath(path, op, edgeStyle);
}
-bool SkDumpCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
SkString str;
toString(deviceRgn, &str);
this->dump(kClip_Verb, NULL, "clipRegion(%s %s)", str.c_str(),
toString(op));
- return this->INHERITED::clipRegion(deviceRgn, op);
+ this->INHERITED::onClipRegion(deviceRgn, op);
}
void SkDumpCanvas::onPushCull(const SkRect& cullRect) {
diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp
index 8c25dc0401..0f13073049 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);
}
-bool SkLuaCanvas::clipRect(const SkRect& r, SkRegion::Op op, bool doAA) {
+void SkLuaCanvas::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
AUTO_LUA("clipRect");
lua.pushRect(r, "rect");
- lua.pushBool(doAA, "aa");
- return this->INHERITED::clipRect(r, op, doAA);
+ lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa");
+ this->INHERITED::onClipRect(r, op, edgeStyle);
}
-bool SkLuaCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
+void SkLuaCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
AUTO_LUA("clipRRect");
lua.pushRRect(rrect, "rrect");
- lua.pushBool(doAA, "aa");
- return this->INHERITED::clipRRect(rrect, op, doAA);
+ lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa");
+ this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
-bool SkLuaCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
+void SkLuaCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
AUTO_LUA("clipPath");
lua.pushPath(path, "path");
- lua.pushBool(doAA, "aa");
- return this->INHERITED::clipPath(path, op, doAA);
+ lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa");
+ this->INHERITED::onClipPath(path, op, edgeStyle);
}
-bool SkLuaCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+void SkLuaCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
AUTO_LUA("clipRegion");
- return this->INHERITED::clipRegion(deviceRgn, op);
+ this->INHERITED::onClipRegion(deviceRgn, op);
}
void SkLuaCanvas::drawPaint(const SkPaint& paint) {
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 27adc6d51d..a9543f9c02 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);
}
-bool SkNWayCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
+void SkNWayCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
Iter iter(fList);
while (iter.next()) {
- iter->clipRect(rect, op, doAA);
+ iter->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
}
- return this->INHERITED::clipRect(rect, op, doAA);
+ this->INHERITED::onClipRect(rect, op, edgeStyle);
}
-bool SkNWayCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
+void SkNWayCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
Iter iter(fList);
while (iter.next()) {
- iter->clipRRect(rrect, op, doAA);
+ iter->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
}
- return this->INHERITED::clipRRect(rrect, op, doAA);
+ this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
-bool SkNWayCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
+void SkNWayCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
Iter iter(fList);
while (iter.next()) {
- iter->clipPath(path, op, doAA);
+ iter->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
}
- return this->INHERITED::clipPath(path, op, doAA);
+ this->INHERITED::onClipPath(path, op, edgeStyle);
}
-bool SkNWayCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+void SkNWayCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
Iter iter(fList);
while (iter.next()) {
iter->clipRegion(deviceRgn, op);
}
- return this->INHERITED::clipRegion(deviceRgn, op);
+ this->INHERITED::onClipRegion(deviceRgn, op);
}
void SkNWayCanvas::clear(SkColor color) {
diff --git a/src/utils/SkNoSaveLayerCanvas.h b/src/utils/SkNoSaveLayerCanvas.h
index 58d28b40b1..60fad87237 100644
--- a/src/utils/SkNoSaveLayerCanvas.h
+++ b/src/utils/SkNoSaveLayerCanvas.h
@@ -32,25 +32,20 @@ public:
return count;
}
+protected:
// disable aa for speed
- virtual bool clipRect(const SkRect& rect,
- SkRegion::Op op,
- bool doAA) SK_OVERRIDE {
- return this->INHERITED::clipRect(rect, op, false);
+ virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
+ this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle);
}
// for speed, just respect the bounds, and disable AA. May give us a few
// false positives and negatives.
- virtual bool clipPath(const SkPath& path,
- SkRegion::Op op,
- bool doAA) SK_OVERRIDE {
- return this->updateClipConservativelyUsingBounds(path.getBounds(), op,
- path.isInverseFillType());
+ virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
+ this->updateClipConservativelyUsingBounds(path.getBounds(), op,
+ path.isInverseFillType());
}
- virtual bool clipRRect(const SkRRect& rrect,
- SkRegion::Op op,
- bool doAA) SK_OVERRIDE {
- return this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
+ virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE {
+ this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false);
}
private:
diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp
index 245e0a6969..0a9d7a80c2 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -58,20 +58,20 @@ void SkProxyCanvas::setMatrix(const SkMatrix& matrix) {
fProxy->setMatrix(matrix);
}
-bool SkProxyCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
- return fProxy->clipRect(rect, op, doAA);
+void SkProxyCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+ fProxy->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
}
-bool SkProxyCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
- return fProxy->clipRRect(rrect, op, doAA);
+void SkProxyCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+ fProxy->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
}
-bool SkProxyCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
- return fProxy->clipPath(path, op, doAA);
+void SkProxyCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+ fProxy->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
}
-bool SkProxyCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
- return fProxy->clipRegion(deviceRgn, op);
+void SkProxyCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+ 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 15165c27e2..fedef697aa 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -43,7 +43,8 @@ SkDebugCanvas::SkDebugCanvas(int width, int height)
large.roundOut(&largeIRect);
SkASSERT(!largeIRect.isEmpty());
#endif
- INHERITED::clipRect(large, SkRegion::kReplace_Op, false);
+ // call the base class' version to avoid adding a draw command
+ this->INHERITED::onClipRect(large, SkRegion::kReplace_Op, kHard_ClipEdgeStyle);
}
SkDebugCanvas::~SkDebugCanvas() {
@@ -297,24 +298,20 @@ void SkDebugCanvas::clear(SkColor color) {
addDrawCommand(new SkClearCommand(color));
}
-bool SkDebugCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
- addDrawCommand(new SkClipPathCommand(path, op, doAA));
- return true;
+void SkDebugCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+ this->addDrawCommand(new SkClipPathCommand(path, 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::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+ this->addDrawCommand(new SkClipRectCommand(rect, 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::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
+ this->addDrawCommand(new SkClipRRectCommand(rrect, op, kSoft_ClipEdgeStyle == edgeStyle));
}
-bool SkDebugCanvas::clipRegion(const SkRegion& region, SkRegion::Op op) {
- addDrawCommand(new SkClipRegionCommand(region, op));
- return true;
+void SkDebugCanvas::onClipRegion(const SkRegion& region, SkRegion::Op op) {
+ this->addDrawCommand(new SkClipRegionCommand(region, op));
}
bool SkDebugCanvas::concat(const SkMatrix& matrix) {
diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h
index 7d496274ac..11771a4e3e 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -143,16 +143,6 @@ 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,
@@ -233,11 +223,33 @@ 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 89f0af43fb..c6afb1f9da 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -982,22 +982,30 @@ public:
, fClipCount(0){
}
- virtual bool clipRect(const SkRect& r, SkRegion::Op op, bool doAA)
- SK_OVERRIDE {
+ virtual void onClipRect(const SkRect& r,
+ SkRegion::Op op,
+ ClipEdgeStyle edgeStyle) SK_OVERRIDE {
fClipCount += 1;
- return this->INHERITED::clipRect(r, op, doAA);
+ this->INHERITED::onClipRect(r, op, edgeStyle);
}
- virtual bool clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA)
- SK_OVERRIDE {
+ virtual void onClipRRect(const SkRRect& rrect,
+ SkRegion::Op op,
+ ClipEdgeStyle edgeStyle)SK_OVERRIDE {
fClipCount += 1;
- return this->INHERITED::clipRRect(rrect, op, doAA);
+ this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
- virtual bool clipPath(const SkPath& path, SkRegion::Op op, bool doAA)
- SK_OVERRIDE {
+ virtual void onClipPath(const SkPath& path,
+ SkRegion::Op op,
+ ClipEdgeStyle edgeStyle) SK_OVERRIDE {
fClipCount += 1;
- return this->INHERITED::clipPath(path, op, doAA);
+ this->INHERITED::onClipPath(path, op, edgeStyle);
+ }
+
+ virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) SK_OVERRIDE {
+ fClipCount += 1;
+ this->INHERITED::onClipRegion(deviceRgn, op);
}
unsigned getClipCount() const { return fClipCount; }