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

Side by Side Diff: src/image/SkImage.cpp

Issue 1473373002: optimize the disable-caching case for SkImage::readPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapCache.h" 9 #include "SkBitmapCache.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dst RowBytes, 50 bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dst RowBytes,
51 int srcX, int srcY, CachingHint chint) const { 51 int srcX, int srcY, CachingHint chint) const {
52 SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY); 52 SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
53 if (!rec.trim(this->width(), this->height())) { 53 if (!rec.trim(this->width(), this->height())) {
54 return false; 54 return false;
55 } 55 }
56 return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec. fX, rec.fY, chint); 56 return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec. fX, rec.fY, chint);
57 } 57 }
58 58
59 bool SkImage::scalePixels(const SkPixmap& dst, SkFilterQuality quality, CachingH int chint) const { 59 bool SkImage::scalePixels(const SkPixmap& dst, SkFilterQuality quality, CachingH int chint) const {
60 if (this->width() == dst.width() && this->height() == dst.height()) {
61 return this->readPixels(dst, 0, 0, chint);
62 }
63
60 // Idea: If/when SkImageGenerator supports a native-scaling API (where the g enerator itself 64 // Idea: If/when SkImageGenerator supports a native-scaling API (where the g enerator itself
61 // can scale more efficiently) we should take advantage of it here. 65 // can scale more efficiently) we should take advantage of it here.
62 // 66 //
63 SkBitmap bm; 67 SkBitmap bm;
64 if (as_IB(this)->getROPixels(&bm, chint)) { 68 if (as_IB(this)->getROPixels(&bm, chint)) {
65 bm.lockPixels(); 69 bm.lockPixels();
66 SkPixmap pmap; 70 SkPixmap pmap;
67 // Note: By calling the pixmap scaler, we never cache the final result, so the chint 71 // Note: By calling the pixmap scaler, we never cache the final result, so the chint
68 // is (currently) only being applied to the getROPixels. If we get a request to 72 // is (currently) only being applied to the getROPixels. If we get a request to
69 // also attempt to cache the final (scaled) result, we would add t hat logic here. 73 // also attempt to cache the final (scaled) result, we would add t hat logic here.
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 417
414 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) { 418 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) {
415 return nullptr; 419 return nullptr;
416 } 420 }
417 421
418 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) { 422 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) {
419 return nullptr; 423 return nullptr;
420 } 424 }
421 425
422 #endif 426 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698