Index: src/core/SkReadBuffer.h |
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h |
index 48edcfe7620e1018e940b68ac17e73724d85f35a..babd276dad0002f8f26262c8debb14b30adb8370 100644 |
--- a/src/core/SkReadBuffer.h |
+++ b/src/core/SkReadBuffer.h |
@@ -22,6 +22,7 @@ |
#include "SkReader32.h" |
#include "SkRefCnt.h" |
#include "SkShader.h" |
+#include "SkTHash.h" |
#include "SkWriteBuffer.h" |
#include "SkXfermode.h" |
@@ -202,6 +203,15 @@ public: |
} |
/** |
+ * For an input flattenable (specified by name), set custom factory proc |
+ * to use when unflattening. |
+ */ |
+ void setCustomFactory(const char* name, SkFlattenable::Factory factory) { |
+ SkFlattenable::Factory defaultFactory = SkFlattenable::NameToFactory(name); |
+ fCustomFactory->set(defaultFactory, 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. |
@@ -218,6 +228,14 @@ public: |
protected: |
SkReader32 fReader; |
+ /** |
+ * Checks if a custom factory has been set for a given flattenable. |
+ * Returns the custom factory if it exists, or nullptr otherwise. |
+ */ |
+ SkFlattenable::Factory* getCustomFactory(SkFlattenable::Factory factory) { |
+ return fCustomFactory->find(factory); |
+ } |
+ |
private: |
bool readArray(void* value, size_t size, size_t elementSize); |
@@ -233,6 +251,10 @@ private: |
SkFlattenable::Factory* fFactoryArray; |
int fFactoryCount; |
+ // Maps the default Factory to any custom Factory that was specified for |
+ // this SkReadBuffer. |
+ SkAutoTDelete<SkTHashMap<SkFlattenable::Factory, SkFlattenable::Factory>> fCustomFactory; |
+ |
SkPicture::InstallPixelRefProc fBitmapDecoder; |
#ifdef DEBUG_NON_DETERMINISTIC_ASSERT |