Index: src/core/SkDevice.cpp |
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp |
index 1f270af57245cc51e908163a87b2391b136d676d..af7f9215f5ce8130a886f3641e9deb98fa03b6e5 100644 |
--- a/src/core/SkDevice.cpp |
+++ b/src/core/SkDevice.cpp |
@@ -155,9 +155,22 @@ void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const |
const SkRect& dst, const SkPaint& paint, |
SkCanvas::SrcRectConstraint constraint) { |
// Default impl : turns everything into raster bitmap |
+ |
SkBitmap bm; |
- if (as_IB(image)->getROPixels(&bm)) { |
- this->drawBitmapRect(draw, bm, src, dst, paint, constraint); |
+ SkScalar scaleX = draw.fMatrix->getScaleX(); |
+ SkScalar scaleY = draw.fMatrix->getScaleY(); |
+ |
+ SkScalar scale = SkMaxScalar(scaleX * dst.width() / src->width(), |
+ scaleY * dst.height() / src->height()); |
+ if (as_IB(image)->getROPixels(&bm, scale)) { |
+ scale = SkIntToScalar(bm.width()) / SkIntToScalar(image->width()); |
+ if (scale == SK_Scalar1) { |
+ this->drawBitmapRect(draw, bm, src, dst, paint, constraint); |
+ } else { |
+ SkRect srcScaled; |
+ srcScaled.set(src->left() * scale, src->top() * scale, src->right() * scale, src->bottom() * scale); |
+ this->drawBitmapRect(draw, bm, &srcScaled, dst, paint, constraint); |
+ } |
} |
} |