aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkCanvas.h
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-22 13:19:12 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-22 13:19:12 +0000
commitad254fee73ad70a45acba69dccb9b65f88c3a92a (patch)
tree12b18a7e1d9f810991864d61120bd74a7d72a1b1 /include/core/SkCanvas.h
parentdb6fa1729a5117e1bdacd6c237373812cd44a7c0 (diff)
If the path is a rect, call drawRect to raster the geometry in SkCanvas::drawPath to get better performance.
Committed: http://code.google.com/p/skia/source/detail?r=11842 R=bsalomon@google.com Review URL: https://codereview.chromium.org/23484007 git-svn-id: http://skia.googlecode.com/svn/trunk@11904 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkCanvas.h')
-rw-r--r--include/core/SkCanvas.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index dc3953ed4b..6869585419 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -575,16 +575,20 @@ public:
will be filled or stroked based on the Style in the paint.
@param rect The rect to be drawn
@param paint The paint used to draw the rect
+
+ Overriding this function is deprecated. It will be made non-virtual
+ soon. Instead override onDrawRect.
*/
- virtual void drawRect(const SkRect& rect, const SkPaint& paint);
+ virtual void drawRect(const SkRect& rect, const SkPaint& paint) {
+ this->onDrawRect(rect, paint);
+ }
/** Draw the specified rectangle using the specified paint. The rectangle
will be filled or framed based on the Style in the paint.
@param rect The rect to be drawn
@param paint The paint used to draw the rect
*/
- void drawIRect(const SkIRect& rect, const SkPaint& paint)
- {
+ void drawIRect(const SkIRect& rect, const SkPaint& paint) {
SkRect r;
r.set(rect); // promotes the ints to scalars
this->drawRect(r, paint);
@@ -656,8 +660,18 @@ public:
filled or framed based on the Style in the paint.
@param path The path to be drawn
@param paint The paint used to draw the path
+
+ Overriding this function is deprecated. It will be made non-virtual
+ soon. Instead override onDrawRect.
*/
- virtual void drawPath(const SkPath& path, const SkPaint& paint);
+ virtual void drawPath(const SkPath& path, const SkPaint& paint) {
+ SkRect rect;
+ if (path.isRect(&rect) && !path.isInverseFillType()) {
+ this->onDrawRect(rect, paint);
+ } else {
+ this->onDrawPath(path, paint);
+ }
+ }
/** Draw the specified bitmap, with its top/left corner at (x,y), using the
specified paint, transformed by the current matrix. Note: if the paint
@@ -1034,6 +1048,10 @@ protected:
// can perform copy-on-write or invalidate any cached images
void predrawNotify();
+ virtual void onDrawRect(const SkRect& rect, const SkPaint& paint);
+
+ virtual void onDrawPath(const SkPath& path, const SkPaint& paint);
+
/** DEPRECATED -- use constructor(device)
Marked as 'protected' to avoid new clients using this before we can