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

Unified Diff: src/core/SkImageCacherator.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
Index: src/core/SkImageCacherator.cpp
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index 1c976567c9315429f9c3ccb117cc4c971f8e610f..f4a2ab734a5dd60edc9563e2778a92f6d398b564 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -108,14 +108,28 @@ bool SkImageCacherator::generateBitmap(SkBitmap* bitmap) {
}
}
+bool SkImageCacherator::directGeneratePixels(const SkImageInfo& info, void* pixels, size_t rb,
+ int srcX, int srcY) {
+ ScopedGenerator generator(this);
+ const SkImageInfo& genInfo = generator->getInfo();
+ // Currently generators do not natively handle subsets, so check that first.
+ if (srcX || srcY || genInfo.width() != info.width() || genInfo.height() != info.height()) {
+ return false;
+ }
+ return generator->getPixels(info, pixels, rb);
+}
+
//////////////////////////////////////////////////////////////////////////////////////////////////
+bool SkImageCacherator::lockAsBitmapOnlyIfAlreadyCached(SkBitmap* bitmap) {
+ return SkBitmapCache::Find(fUniqueID, bitmap) && check_output_bitmap(*bitmap, fUniqueID);
+}
+
bool SkImageCacherator::tryLockAsBitmap(SkBitmap* bitmap, const SkImage* client,
SkImage::CachingHint chint) {
- if (SkBitmapCache::Find(fUniqueID, bitmap)) {
- return check_output_bitmap(*bitmap, fUniqueID);
+ if (this->lockAsBitmapOnlyIfAlreadyCached(bitmap)) {
+ return true;
}
-
if (!this->generateBitmap(bitmap)) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698