flag to use const& instead of const* for src-rect
BUG=skia:
Review URL: https://codereview.chromium.org/1272713005
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 342f79f..4f5e159 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1846,6 +1846,7 @@
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 @@
}
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,20 +1906,31 @@
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;
}
- 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) {
if (bitmap.drawsNothing() || dst.isEmpty()) {
@@ -1922,6 +1961,25 @@
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
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 2338374..eb7c476 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -188,7 +188,7 @@
const SkRect* src = get_rect_ptr(reader); // may be null
const SkRect& dst = reader->skipT<SkRect>(); // required
SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
- canvas->drawBitmapRect(bitmap, src, dst, paint, constraint);
+ canvas->legacy_drawBitmapRect(bitmap, src, dst, paint, constraint);
} break;
case DRAW_BITMAP_MATRIX: {
const SkPaint* paint = fPictureData->getPaint(reader);
@@ -260,7 +260,7 @@
// newer op-code stores the constraint explicitly
constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
}
- canvas->drawImageRect(image, src, dst, paint, constraint);
+ canvas->legacy_drawImageRect(image, src, dst, paint, constraint);
} break;
case DRAW_OVAL: {
const SkPaint& paint = *fPictureData->getPaint(reader);
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 25fc2d8..8c884d9 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -89,16 +89,16 @@
DRAW(DrawBitmap, drawBitmap(r.bitmap.shallowCopy(), r.left, r.top, r.paint));
DRAW(DrawBitmapNine, drawBitmapNine(r.bitmap.shallowCopy(), r.center, r.dst, r.paint));
DRAW(DrawBitmapRect,
- drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
+ legacy_drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
SkCanvas::kStrict_SrcRectConstraint));
DRAW(DrawBitmapRectFast,
- drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
+ legacy_drawBitmapRect(r.bitmap.shallowCopy(), r.src, r.dst, r.paint,
SkCanvas::kFast_SrcRectConstraint));
DRAW(DrawBitmapRectFixedSize,
- drawBitmapRect(r.bitmap.shallowCopy(), &r.src, r.dst, &r.paint, r.constraint));
+ legacy_drawBitmapRect(r.bitmap.shallowCopy(), &r.src, r.dst, &r.paint, r.constraint));
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint));
-DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint, r.constraint));
+DRAW(DrawImageRect, legacy_drawImageRect(r.image, r.src, r.dst, r.paint, r.constraint));
DRAW(DrawImageNine, drawImageNine(r.image, r.center, r.dst, r.paint));
DRAW(DrawOval, drawOval(r.oval, r.paint));
DRAW(DrawPaint, drawPaint(r.paint));