Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Unified Diff: include/core/SkCanvas.h

Issue 1777403002: Allow const& for SkImages and SkPictures in draw methods. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkCanvas.h
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 034e405f3d623a2bb57457812b19b11fe4874f27..3c3eace58936b1af39e6502d3f8a0e705f8d59fe 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -772,6 +772,10 @@ public:
@param paint The paint used to draw the image, or NULL
*/
void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint = NULL);
+ void drawImage(sk_sp<const SkImage> image, SkScalar left, SkScalar top,
bungeman-skia 2016/03/10 22:14:01 Taking the sk_sp by value here means you're taking
bsalomon 2016/03/10 22:22:16 Is there a downside to a const sk_sp<const>& param
bungeman-skia 2016/03/10 23:06:14 We would need two signatures, one for "const sk_sp
+ const SkPaint* paint = NULL) {
+ this->drawImage(image.get(), left, top, paint);
+ }
/**
* Controls the behavior at the edge of the src-rect, when specified in drawImageRect,
@@ -823,6 +827,20 @@ public:
void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint = kStrict_SrcRectConstraint);
+ void drawImageRect(sk_sp<const SkImage> image, const SkRect& src, const SkRect& dst,
+ const SkPaint* paint,
+ SrcRectConstraint constraint = kStrict_SrcRectConstraint) {
+ this->drawImageRect(image.get(), src, dst, paint, constraint);
+ }
+ void drawImageRect(sk_sp<const SkImage> image, const SkIRect& isrc, const SkRect& dst,
+ const SkPaint* paint, SrcRectConstraint cons = kStrict_SrcRectConstraint) {
+ this->drawImageRect(image.get(), isrc, dst, paint, cons);
+ }
+ void drawImageRect(sk_sp<const SkImage> image, const SkRect& dst, const SkPaint* paint,
+ SrcRectConstraint cons = kStrict_SrcRectConstraint) {
+ this->drawImageRect(image.get(), dst, paint, cons);
+ }
+
/**
* Draw the image stretched differentially to fit into dst.
* center is a rect within the image, and logically divides the image
@@ -838,7 +856,11 @@ public:
* - The sides (along the shrink axis) and center are not drawn
*/
void drawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
- const SkPaint* paint = NULL);
+ const SkPaint* paint = nullptr);
+ void drawImageNine(sk_sp<const SkImage> image, const SkIRect& center, const SkRect& dst,
+ const SkPaint* paint = nullptr) {
+ this->drawImageNine(image.get(), center, dst, 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
@@ -1065,6 +1087,17 @@ public:
this->drawAtlas(atlas, xform, tex, NULL, count, SkXfermode::kDst_Mode, cullRect, paint);
}
+ void drawAtlas(sk_sp<const SkImage> atlas, const SkRSXform xform[], const SkRect tex[],
+ const SkColor colors[], int count, SkXfermode::Mode mode, const SkRect* cull,
+ const SkPaint* paint) {
+ this->drawAtlas(atlas.get(), xform, tex, colors, count, mode, cull, paint);
+ }
+ void drawAtlas(sk_sp<const SkImage> atlas, const SkRSXform xform[], const SkRect tex[],
+ int count, const SkRect* cullRect, const SkPaint* paint) {
+ this->drawAtlas(atlas.get(), xform, tex, nullptr, count, SkXfermode::kDst_Mode,
+ cullRect, paint);
+ }
+
/**
* Draw the contents of this drawable into the canvas. If the canvas is async
* (e.g. it is recording into a picture) then the drawable will be referenced instead,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698