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

Unified 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, 1 month 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
« src/core/SkImageCacherator.h ('K') | « src/image/SkImage.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Generator.cpp
diff --git a/src/image/SkImage_Generator.cpp b/src/image/SkImage_Generator.cpp
index 5031c24548118b747c3251232cd35b1e0ca8691b..fbde92da663f8fb51d61f36b43103bca6df36c6d 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -41,6 +41,20 @@ private:
bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
int srcX, int srcY, CachingHint chint) const {
SkBitmap bm;
+ if (kDisallow_CachingHint == chint) {
+ if (fCache->lockAsBitmapOnlyIfAlreadyCached(&bm)) {
+ return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
+ } else {
+ // Try passing the caller's buffer directly down to the generator. If this fails we
+ // may still succeed in the general case, as the generator may prefer some other
+ // config, which we could then convert via SkBitmap::readPixels.
+ if (fCache->directGeneratePixels(dstInfo, dstPixels, dstRB, srcX, srcY)) {
+ return true;
+ }
+ // else fall through
+ }
+ }
+
if (this->getROPixels(&bm, chint)) {
return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
}
« 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