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

Unified Diff: src/core/SkReadBuffer.cpp

Issue 1837913003: Add support for serializing/deserializing of SkDrawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add ability to specify custom flattenable factories on SkReadBuffer Created 4 years, 9 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
Index: src/core/SkReadBuffer.cpp
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 2dd9f093ac2be7e21da632f84e7f03cc15bbc0c7..cc591c7258b7922b99418fdacf8fe0d144023688 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -33,6 +33,7 @@ SkReadBuffer::SkReadBuffer() {
fFactoryArray = nullptr;
fFactoryCount = 0;
+ fCustomFactory.reset(new SkTHashMap<SkFlattenable::Factory, SkFlattenable::Factory>());
fBitmapDecoder = nullptr;
#ifdef DEBUG_NON_DETERMINISTIC_ASSERT
fDecodedBitmapIndex = -1;
@@ -51,6 +52,7 @@ SkReadBuffer::SkReadBuffer(const void* data, size_t size) {
fFactoryArray = nullptr;
fFactoryCount = 0;
+ fCustomFactory.reset(new SkTHashMap<SkFlattenable::Factory, SkFlattenable::Factory>());
fBitmapDecoder = nullptr;
#ifdef DEBUG_NON_DETERMINISTIC_ASSERT
fDecodedBitmapIndex = -1;
@@ -71,6 +73,7 @@ SkReadBuffer::SkReadBuffer(SkStream* stream) {
fFactoryArray = nullptr;
fFactoryCount = 0;
+ fCustomFactory.reset(new SkTHashMap<SkFlattenable::Factory, SkFlattenable::Factory>());
fBitmapDecoder = nullptr;
#ifdef DEBUG_NON_DETERMINISTIC_ASSERT
fDecodedBitmapIndex = -1;
@@ -352,6 +355,12 @@ SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) {
if (nullptr == factory) {
return nullptr; // writer failed to give us the flattenable
}
+
+ // Check if a custom Factory has been specified for this flattenable.
+ SkFlattenable::Factory* customFactoryPtr = getCustomFactory(factory);
+ if (customFactoryPtr) {
+ factory = *customFactoryPtr;
+ }
}
// if we get here, factory may still be null, but if that is the case, the

Powered by Google App Engine
This is Rietveld 408576698