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

Side by Side Diff: src/image/SkImage_Generator.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
« src/core/SkImageCacherator.h ('K') | « src/image/SkImage.cpp ('k') | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkImage_Base.h" 8 #include "SkImage_Base.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 23 matching lines...) Expand all
34 SkAutoTDelete<SkImageCacherator> fCache; 34 SkAutoTDelete<SkImageCacherator> fCache;
35 35
36 typedef SkImage_Base INHERITED; 36 typedef SkImage_Base INHERITED;
37 }; 37 };
38 38
39 /////////////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////////////
40 40
41 bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels , size_t dstRB, 41 bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels , size_t dstRB,
42 int srcX, int srcY, CachingHint chint) cons t { 42 int srcX, int srcY, CachingHint chint) cons t {
43 SkBitmap bm; 43 SkBitmap bm;
44 if (kDisallow_CachingHint == chint) {
45 if (fCache->lockAsBitmapOnlyIfAlreadyCached(&bm)) {
46 return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
47 } else {
48 // Try passing the caller's buffer directly down to the generator. I f this fails we
49 // may still succeed in the general case, as the generator may prefe r some other
50 // config, which we could then convert via SkBitmap::readPixels.
51 if (fCache->directGeneratePixels(dstInfo, dstPixels, dstRB, srcX, sr cY)) {
52 return true;
53 }
54 // else fall through
55 }
56 }
57
44 if (this->getROPixels(&bm, chint)) { 58 if (this->getROPixels(&bm, chint)) {
45 return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY); 59 return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
46 } 60 }
47 return false; 61 return false;
48 } 62 }
49 63
50 const void* SkImage_Generator::onPeekPixels(SkImageInfo* infoPtr, size_t* rowByt esPtr) const { 64 const void* SkImage_Generator::onPeekPixels(SkImageInfo* infoPtr, size_t* rowByt esPtr) const {
51 return NULL; 65 return NULL;
52 } 66 }
53 67
(...skipping 25 matching lines...) Expand all
79 return surface->newImageSnapshot(); 93 return surface->newImageSnapshot();
80 } 94 }
81 95
82 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s ubset) { 96 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s ubset) {
83 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su bset); 97 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su bset);
84 if (!cache) { 98 if (!cache) {
85 return nullptr; 99 return nullptr;
86 } 100 }
87 return new SkImage_Generator(cache); 101 return new SkImage_Generator(cache);
88 } 102 }
OLDNEW
« src/core/SkImageCacherator.h ('K') | « src/image/SkImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698