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

Unified Diff: src/core/SkCanvas.cpp

Issue 1272713005: flag to use const& instead of const* for src-rect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 342f79f9d99a0b0efa6f55df9687fded9b961798..4f5e15911d3ad1c3b7d2b60a00edc5f69c02c93b 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1846,6 +1846,7 @@ void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkP
this->onDrawImage(image, x, y, paint);
}
+#ifdef SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT
void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
if (dst.isEmpty()) {
@@ -1853,20 +1854,47 @@ void SkCanvas::drawImageRect(const SkImage* image, const SkRect* src, const SkRe
}
this->onDrawImageRect(image, src, dst, paint, constraint);
}
+void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
+ const SkPaint* paint, SrcRectConstraint constraint) {
+ if (bitmap.drawsNothing() || dst.isEmpty()) {
+ return;
+ }
+ this->onDrawBitmapRect(bitmap, src, dst, paint, constraint);
+}
+#endif
+
+void SkCanvas::drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
+ const SkPaint* paint, SrcRectConstraint constraint) {
+ if (dst.isEmpty() || src.isEmpty()) {
+ return;
+ }
+ this->onDrawImageRect(image, &src, dst, paint, constraint);
+}
void SkCanvas::drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
- SkRect src = SkRect::Make(isrc);
- this->drawImageRect(image, &src, dst, paint, constraint);
+ this->drawImageRect(image, SkRect::Make(isrc), dst, paint, constraint);
}
+#ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT
+void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint) {
+ this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint);
+}
+#else
+void SkCanvas::drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint,
+ SrcRectConstraint constraint) {
+ this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()), dst, paint,
+ constraint);
+}
+#endif
+
void SkCanvas::drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
const SkPaint* paint) {
if (dst.isEmpty()) {
return;
}
if (!SkNinePatchIter::Valid(image->width(), image->height(), center)) {
- this->drawImageRect(image, NULL, dst, paint);
+ this->drawImageRect(image, dst, paint);
}
this->onDrawImageNine(image, center, dst, paint);
}
@@ -1878,19 +1906,30 @@ void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar dx, SkScalar dy, cons
this->onDrawBitmap(bitmap, dx, dy, paint);
}
-void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
+void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
- if (bitmap.drawsNothing() || dst.isEmpty()) {
+ if (bitmap.drawsNothing() || dst.isEmpty() || src.isEmpty()) {
return;
}
robertphillips 2015/08/06 17:23:00 We don't want to change onDrawBitmapRect too?
- this->onDrawBitmapRect(bitmap, src, dst, paint, constraint);
+ this->onDrawBitmapRect(bitmap, &src, dst, paint, constraint);
}
void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
- SkRect src = SkRect::Make(isrc);
- this->drawBitmapRect(bitmap, &src, dst, paint, constraint);
+ this->drawBitmapRect(bitmap, SkRect::Make(isrc), dst, paint, constraint);
+}
+
+#ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT
+void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint) {
+ this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height()), dst, paint);
+}
+#else
+void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint,
+ SrcRectConstraint constraint) {
+ this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height()), dst, paint,
+ constraint);
}
+#endif
void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
const SkPaint* paint) {
@@ -1922,6 +1961,25 @@ void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const Sk
this->onDrawAtlas(atlas, xform, tex, colors, count, mode, cull, paint);
}
+void SkCanvas::legacy_drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
+ const SkPaint* paint, SrcRectConstraint constraint) {
+ if (src) {
+ this->drawImageRect(image, *src, dst, paint, constraint);
+ } else {
+ this->drawImageRect(image, SkRect::MakeIWH(image->width(), image->height()),
+ dst, paint, constraint);
+ }
+}
+void SkCanvas::legacy_drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
+ const SkPaint* paint, SrcRectConstraint constraint) {
+ if (src) {
+ this->drawBitmapRect(bitmap, *src, dst, paint, constraint);
+ } else {
+ this->drawBitmapRect(bitmap, SkRect::MakeIWH(bitmap.width(), bitmap.height()),
+ dst, paint, constraint);
+ }
+}
+
//////////////////////////////////////////////////////////////////////////////
// These are the virtual drawing methods
//////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698