Revert of Delete SkFlattenable::Type (part 1) (patchset #1 id:1 of https://codereview...
authormsarett <msarett@google.com>
Tue, 5 Apr 2016 19:00:49 +0000 (12:00 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 5 Apr 2016 19:00:49 +0000 (12:00 -0700)
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
src/core/SkValidatingReadBuffer.cpp

index c5ff06ac888baf73c0a3f6391ba590a2ea10cb7c..ffb1b5ae972361000bde825db17d7ad9dcd4a010 100644 (file)
@@ -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
index c80192f8b26d965a24b1f61bfa7abe2cbd8946e1..ad4b6c409e6a0adca7c85b87c69a59089ac76779 100644 (file)
@@ -222,14 +222,20 @@ bool SkValidatingReadBuffer::validateAvailable(size_t size) {
     return this->validate((size <= SK_MaxU32) && fReader.isAvailable(static_cast<uint32_t>(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