diff options
author | 2014-09-23 14:10:50 -0700 | |
---|---|---|
committer | 2014-09-23 14:10:50 -0700 | |
commit | 432789972c1e1f8a66165c75a250dba1853efa08 (patch) | |
tree | 587fd2e2ae72baa63af8fcad67d2471980894dbe /include | |
parent | 271a030f5d0d3c59715fbeffb31c761279f3f8ca (diff) |
SkCanvas::drawImage is the new way for drawing a SkImage to a Canvas
BUG=skia:2947
R=junov@chromium.org, reed@google.com, bsalomon@google.com
Author: piotaixr@chromium.org
Review URL: https://codereview.chromium.org/583453002
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkCanvas.h | 12 | ||||
-rw-r--r-- | include/core/SkImage.h | 24 |
2 files changed, 23 insertions, 13 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 77038c3067..5828466d62 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -29,6 +29,7 @@ class SkCanvasClipVisitor; class SkBaseDevice; class SkDraw; class SkDrawFilter; +class SkImage; class SkMetaData; class SkPicture; class SkRRect; @@ -811,6 +812,13 @@ public: */ virtual void drawPath(const SkPath& path, const SkPaint& paint); + virtual void drawImage(const SkImage* image, SkScalar left, SkScalar top, + const SkPaint* paint = NULL); + + virtual void drawImageRect(const SkImage* image, const SkRect* src, + const SkRect& dst, + const SkPaint* paint = NULL); + /** 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 contains a maskfilter that generates a mask which extends beyond the @@ -1313,7 +1321,7 @@ private: friend class SkSurface_Raster; // needs getDevice() friend class SkRecorder; // InitFlags friend class SkNoSaveLayerCanvas; // InitFlags - + enum InitFlags { kDefault_InitFlags = 0, kConservativeRasterClip_InitFlag = 1 << 0, @@ -1324,7 +1332,7 @@ private: // needs gettotalclip() friend SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas*); - + SkBaseDevice* createLayerDevice(const SkImageInfo&); // call this each time we attach ourselves to a device diff --git a/include/core/SkImage.h b/include/core/SkImage.h index a723aeeb86..c7625f6b4d 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -71,17 +71,6 @@ public: SkShader::TileMode, const SkMatrix* localMatrix = NULL) const; - void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; - - /** - * Draw the image, cropped to the src rect, to the dst rect of a canvas. - * If src is larger than the bounds of the image, the rest of the image is - * filled with transparent black pixels. - * - * See SkCanvas::drawBitmapRectToRect for similar behavior. - */ - void draw(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*) const; - /** * If the image has direct access to its pixels (i.e. they are in local * RAM) return the (const) address of those pixels, and if not null, return @@ -122,6 +111,19 @@ private: typedef SkRefCnt INHERITED; + friend class SkCanvas; + + void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; + + /** + * Draw the image, cropped to the src rect, to the dst rect of a canvas. + * If src is larger than the bounds of the image, the rest of the image is + * filled with transparent black pixels. + * + * See SkCanvas::drawBitmapRectToRect for similar behavior. + */ + void draw(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*) const; + /** * Return a copy of the image's pixels, limiting them to the subset * rectangle's intersection wit the image bounds. If subset is NULL, then |