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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « include/core/SkImageGenerator.h ('k') | src/core/SkImageCacherator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkColorFilter.h" 8 #include "SkColorFilter.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 SkBitmap bm; 148 SkBitmap bm;
149 if (as_IB(image)->getROPixels(&bm)) { 149 if (as_IB(image)->getROPixels(&bm)) {
150 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); 150 this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint);
151 } 151 }
152 } 152 }
153 153
154 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src, 154 void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src,
155 const SkRect& dst, const SkPaint& paint, 155 const SkRect& dst, const SkPaint& paint,
156 SkCanvas::SrcRectConstraint constraint) { 156 SkCanvas::SrcRectConstraint constraint) {
157 // Default impl : turns everything into raster bitmap 157 // Default impl : turns everything into raster bitmap
158
158 SkBitmap bm; 159 SkBitmap bm;
159 if (as_IB(image)->getROPixels(&bm)) { 160 SkScalar scaleX = draw.fMatrix->getScaleX();
160 this->drawBitmapRect(draw, bm, src, dst, paint, constraint); 161 SkScalar scaleY = draw.fMatrix->getScaleY();
162
163 SkScalar scale = SkMaxScalar(scaleX * dst.width() / src->width(),
164 scaleY * dst.height() / src->height());
165 if (as_IB(image)->getROPixels(&bm, scale)) {
166 scale = SkIntToScalar(bm.width()) / SkIntToScalar(image->width());
167 if (scale == SK_Scalar1) {
168 this->drawBitmapRect(draw, bm, src, dst, paint, constraint);
169 } else {
170 SkRect srcScaled;
171 srcScaled.set(src->left() * scale, src->top() * scale, src->right() * scale, src->bottom() * scale);
172 this->drawBitmapRect(draw, bm, &srcScaled, dst, paint, constraint);
173 }
161 } 174 }
162 } 175 }
163 176
164 void SkBaseDevice::drawImageNine(const SkDraw& draw, const SkImage* image, const SkIRect& center, 177 void SkBaseDevice::drawImageNine(const SkDraw& draw, const SkImage* image, const SkIRect& center,
165 const SkRect& dst, const SkPaint& paint) { 178 const SkRect& dst, const SkPaint& paint) {
166 SkNinePatchIter iter(image->width(), image->height(), center, dst); 179 SkNinePatchIter iter(image->width(), image->height(), center, dst);
167 180
168 SkRect srcR, dstR; 181 SkRect srcR, dstR;
169 while (iter.next(&srcR, &dstR)) { 182 while (iter.next(&srcR, &dstR)) {
170 this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_S rcRectConstraint); 183 this->drawImageRect(draw, image, &srcR, dstR, paint, SkCanvas::kStrict_S rcRectConstraint);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry() 425 if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry()
413 || this->onShouldDisableLCD(paint)) { 426 || this->onShouldDisableLCD(paint)) {
414 427
415 flags &= ~SkPaint::kLCDRenderText_Flag; 428 flags &= ~SkPaint::kLCDRenderText_Flag;
416 flags |= SkPaint::kGenA8FromLCD_Flag; 429 flags |= SkPaint::kGenA8FromLCD_Flag;
417 } 430 }
418 431
419 return flags; 432 return flags;
420 } 433 }
421 434
OLDNEW
« 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