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

Unified Diff: src/core/SkValidatingReadBuffer.cpp

Issue 1858323002: Enable flattening/unflattening with custom unflatten procs (Closed) Base URL: https://skia.googlesource.com/skia.git@flattenable
Patch Set: Avoid duping strings Created 4 years, 8 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/SkValidatingReadBuffer.cpp
diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp
index 52006f23ad066391ee9731f942d737b54170c8b6..8807cc07f64e8b6dbc5af855e8cd72b7a6729089 100644
--- a/src/core/SkValidatingReadBuffer.cpp
+++ b/src/core/SkValidatingReadBuffer.cpp
@@ -232,28 +232,25 @@ SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type)
return nullptr;
}
- SkFlattenable::Factory factory = SkFlattenable::NameToFactory(cname);
- if (nullptr == factory) {
- return nullptr; // writer failed to give us the flattenable
+ // Get the factory for this flattenable.
+ SkFlattenable::Factory factory = getCustomFactory(name);
mtklein 2016/04/19 18:14:55 this->
msarett 2016/04/19 18:55:51 Done.
+ if (!factory) {
+ factory = SkFlattenable::NameToFactory(cname);
+ if (!factory) {
+ return nullptr; // writer failed to give us the flattenable
+ }
}
- // if we get here, factory may still be null, but if that is the case, the
- // failure was ours, not the writer.
+ // If we get here, the factory is non-null.
sk_sp<SkFlattenable> obj;
uint32_t sizeRecorded = this->readUInt();
- if (factory) {
- size_t offset = fReader.offset();
- obj = (*factory)(*this);
- // check that we read the amount we expected
- size_t sizeRead = fReader.offset() - offset;
- this->validate(sizeRecorded == sizeRead);
- if (fError) {
- obj = nullptr;
- }
- } else {
- // we must skip the remaining data
- this->skip(sizeRecorded);
- SkASSERT(false);
+ size_t offset = fReader.offset();
+ obj = (*factory)(*this);
+ // check that we read the amount we expected
+ size_t sizeRead = fReader.offset() - offset;
+ this->validate(sizeRecorded == sizeRead);
+ if (fError) {
+ obj = nullptr;
}
return obj.release();
}

Powered by Google App Engine
This is Rietveld 408576698