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

Unified Diff: src/core/SkReadBuffer.h

Issue 2187613002: Deserialize pictures with custom image-deserializer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix legacy case, remove null-check Created 4 years, 4 months 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
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/core/SkReadBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkReadBuffer.h
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 110b2a582c2e95b19de4c7535fb9a88be44f2d56..a8bed7be48e71654365d5f9e8586ecdc68ac6d45 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -167,12 +167,11 @@ public:
virtual uint32_t getArrayCount();
/**
- * Returns false if the bitmap could not be completely read. In that case, it will be set
+ * Returns false if the image could not be completely read. In that case, it will be set
* to have width/height, but no pixels.
*/
- bool readBitmap(SkBitmap* bitmap);
-
- SkImage* readImage();
+ sk_sp<SkImage> readBitmapAsImage();
+ sk_sp<SkImage> readImage();
virtual SkTypeface* readTypeface();
@@ -204,14 +203,9 @@ public:
fCustomFactory.set(name, factory);
}
- /**
- * Provide a function to decode an SkBitmap from encoded data. Only used if the writer
- * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap with the
- * appropriate size will be used.
- */
- void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) {
- fBitmapDecoder = bitmapDecoder;
- }
+ // If nullptr is passed, then the default deserializer will be used
+ // which calls SkImage::MakeFromEncoded()
+ void setImageDeserializer(SkImageDeserializer* factory);
// Default impelementations don't check anything.
virtual bool validate(bool isValid) { return isValid; }
@@ -228,7 +222,6 @@ protected:
*/
int factoryCount() { return fFactoryCount; }
-
/**
* Checks if a custom factory has been set for a given flattenable.
* Returns the custom factory if it exists, or nullptr otherwise.
@@ -260,7 +253,8 @@ private:
// Only used if we do not have an fFactoryArray.
SkTHashMap<SkString, SkFlattenable::Factory> fCustomFactory;
- SkPicture::InstallPixelRefProc fBitmapDecoder;
+ // We do not own this ptr, we just use it (guaranteed to never be null)
+ SkImageDeserializer* fImageDeserializer;
#ifdef DEBUG_NON_DETERMINISTIC_ASSERT
// Debugging counter to keep track of how many bitmaps we
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/core/SkReadBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698