aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkReadBuffer.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-08-11 03:55:15 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-11 03:55:15 -0700
commita9ca05ca5e604b9ee18e9cce19b059085ca0e22c (patch)
treeb8b28257068935dc55c956c41ff2e3d899e031c7 /src/core/SkReadBuffer.h
parent286a8657da0364006e95cb0988477cc3a5f0e112 (diff)
Deserialize pictures with custom image-deserializer
Diffstat (limited to 'src/core/SkReadBuffer.h')
-rw-r--r--src/core/SkReadBuffer.h22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 110b2a582c..a8bed7be48 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