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

Unified Diff: src/core/SkDevice.cpp

Issue 1412423008: Handling large jpegs in CPU raster - downsample to display res and 565 Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « include/core/SkImageGenerator.h ('k') | src/core/SkImageCacherator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ }
}
}
« no previous file with comments | « include/core/SkImageGenerator.h ('k') | src/core/SkImageCacherator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698