From be243d4737bb5601984e1d1c4e72e2a6c0788edf Mon Sep 17 00:00:00 2001 From: msarett Date: Tue, 5 Apr 2016 12:00:49 -0700 Subject: [PATCH] Revert of Delete SkFlattenable::Type (part 1) (patchset #1 id:1 of https://codereview.chromium.org/1861013002/ ) Reason for revert: See sugoi's comment. Original issue's description: > Delete SkFlattenable::Type (part 1) > > This should allow me to delete uses of SkFlattenable::Type in Chrome. > Then I'll follow up with the full delete. > https://codereview.chromium.org/1834303003/ > > TBR=reed@google.com > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1861013002 > > Committed: https://skia.googlesource.com/skia/+/6b63536e917d86028630199c4eef4aa1597292ce TBR=reed@google.com,mtklein@google.com,sugoi@chromium.org,senorblanco@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1860693005 --- include/core/SkFlattenableSerialization.h | 2 +- src/core/SkValidatingReadBuffer.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/core/SkFlattenableSerialization.h b/include/core/SkFlattenableSerialization.h index c5ff06ac88..ffb1b5ae97 100644 --- a/include/core/SkFlattenableSerialization.h +++ b/include/core/SkFlattenableSerialization.h @@ -14,6 +14,6 @@ class SkData; SK_API SkData* SkValidatingSerializeFlattenable(SkFlattenable*); SK_API SkFlattenable* SkValidatingDeserializeFlattenable(const void* data, size_t size, - SkFlattenable::Type type = SkFlattenable::kSkUnused_Type); + SkFlattenable::Type type); #endif diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp index c80192f8b2..ad4b6c409e 100644 --- a/src/core/SkValidatingReadBuffer.cpp +++ b/src/core/SkValidatingReadBuffer.cpp @@ -222,14 +222,20 @@ bool SkValidatingReadBuffer::validateAvailable(size_t size) { return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast(size))); } -SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type) { +SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type) { SkString name; this->readString(&name); if (fError) { return nullptr; } + // Is this the type we wanted ? const char* cname = name.c_str(); + SkFlattenable::Type baseType; + if (!SkFlattenable::NameToType(cname, &baseType) || (baseType != type)) { + return nullptr; + } + SkFlattenable::Factory factory = SkFlattenable::NameToFactory(cname); if (nullptr == factory) { return nullptr; // writer failed to give us the flattenable -- 2.34.1