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;
};
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
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
* 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.
/** 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).
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
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[],
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:
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;
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
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;
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;
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[],
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:
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;
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;
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) {
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;
};
//////////////////////////////////////////////////////////////////////////////
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()) {
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
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
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;
// 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()) {
fDeviceCMDirty = true;
fCachedLocalClipBoundsDirty = true;
- doAA &= fAllowSoftClip;
+ if (!fAllowSoftClip) {
+ edgeStyle = kHard_ClipEdgeStyle;
+ }
SkPath devPath;
path.transform(*fMCRec->fMatrix, &devPath);
}
// 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();
// 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,
case SkRegion::kIntersect_Op:
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);
+ // the clip unchanged conservatively respects the contract.
+ break;
case SkRegion::kUnion_Op:
case SkRegion::kReplace_Op:
case SkRegion::kReverseDifference_Op:
- case SkRegion::kXOR_Op:
- {
+ case SkRegion::kXOR_Op: {
// These ops can grow the current clip up to the extents of
// the input clip, which is inverse filled, so we just set
// the current clip to the device bounds.
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::onClipRect(deviceBounds, SkRegion::kReplace_Op,
+ kHard_ClipEdgeStyle);
this->SkCanvas::restore(); //pop the matrix, but keep the clip
- return result;
- }
+ break;
+ }
default:
SkASSERT(0); // unhandled op?
}
case SkRegion::kIntersect_Op:
case SkRegion::kUnion_Op:
case SkRegion::kReplace_Op:
- return this->SkCanvas::clipRect(bounds, op, false);
+ this->SkCanvas::onClipRect(bounds, op, kHard_ClipEdgeStyle);
+ break;
case SkRegion::kDifference_Op:
// Difference can only shrink the current clip.
// Leaving clip unchanged conservatively fullfills the contract.
- return this->getClipDeviceBounds(NULL);
+ break;
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::onClipRect(bounds, SkRegion::kReplace_Op, kHard_ClipEdgeStyle);
+ break;
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::onClipRect(bounds, SkRegion::kUnion_Op, kHard_ClipEdgeStyle);
+ break;
default:
SkASSERT(0); // unhandled op?
}
}
- return true;
+
+ return !this->isClipEmpty();
}
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;
// 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
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;
}
}
bool SkCanvas::getClipBounds(SkRect* bounds) const {
SkIRect ibounds;
- if (!getClipDeviceBounds(&ibounds)) {
+ if (!this->getClipDeviceBounds(&ibounds)) {
return false;
}
}
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;
}
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
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
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
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
}
#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) {
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);
}
}
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);
}
}
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) {
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[],
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]);
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[],
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,
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);
}
///////////////////////////////////////////////////////////////////////////////
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;
tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op);
fList[i]->clipRegion(tempRegion, op);
}
- return this->SkCanvas::clipRegion(deviceRgn, op);
+ this->SkCanvas::onClipRegion(deviceRgn, op);
}
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();
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) {
///////////////////////////////////////////////////////////////////////////////
-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) {
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) {
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) {
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:
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) {
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() {
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) {
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,
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;
, 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; }