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; |
} |