Purge 2020 picture versions

Pull a thread, and end up removing logs of old fontmgr code.

Change-Id: I73cebf9c011a99e9d12fd728e8677fcb0700407f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/429338
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/include/core/SkFontMgr.h b/include/core/SkFontMgr.h
index 8b9ef06..611faa3 100644
--- a/include/core/SkFontMgr.h
+++ b/include/core/SkFontMgr.h
@@ -105,13 +105,6 @@
     sk_sp<SkTypeface> makeFromStream(std::unique_ptr<SkStreamAsset>, const SkFontArguments&) const;
 
     /**
-     *  Create a typeface from the specified font data.
-     *  Will return NULL if the typeface could not be created.
-     *  The caller must call unref() on the returned object if it is not null.
-     */
-    sk_sp<SkTypeface> makeFromFontData(std::unique_ptr<SkFontData>) const;
-
-    /**
      *  Create a typeface for the specified fileName and TTC index
      *  (pass 0 for none) or NULL if the file is not found, or its contents are
      *  not recognized. The caller must call unref() on the returned object
@@ -143,7 +136,6 @@
                                                     int ttcIndex) const = 0;
     virtual sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>,
                                                    const SkFontArguments&) const = 0;
-    virtual sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const;
     virtual sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const = 0;
 
     virtual sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle) const = 0;
diff --git a/include/utils/SkOrderedFontMgr.h b/include/utils/SkOrderedFontMgr.h
index 687b4f0..8d6152d 100644
--- a/include/utils/SkOrderedFontMgr.h
+++ b/include/utils/SkOrderedFontMgr.h
@@ -42,7 +42,6 @@
                                             int ttcIndex) const override;
     sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>,
                                            const SkFontArguments&) const override;
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const override;
     sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override;
 
     sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle) const override;
diff --git a/modules/skottie/src/SkottieTest.cpp b/modules/skottie/src/SkottieTest.cpp
index 8a8884d..a49f878 100644
--- a/modules/skottie/src/SkottieTest.cpp
+++ b/modules/skottie/src/SkottieTest.cpp
@@ -237,9 +237,6 @@
                                                    const SkFontArguments&) const override {
             return fTestFont;
         }
-        sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const override {
-            return fTestFont;
-        }
         sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override {
             return fTestFont;
         }
@@ -661,9 +658,6 @@
                                                const SkFontArguments&) const override {
             return nullptr;
         }
-        sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const override {
-            return nullptr;
-        }
         sk_sp<SkTypeface> onMakeFromFile(const char[], int) const override {
             return nullptr;
         }
diff --git a/modules/skparagraph/include/TypefaceFontProvider.h b/modules/skparagraph/include/TypefaceFontProvider.h
index 88acf95..df759b1 100644
--- a/modules/skparagraph/include/TypefaceFontProvider.h
+++ b/modules/skparagraph/include/TypefaceFontProvider.h
@@ -62,7 +62,6 @@
                                            const SkFontArguments&) const override {
         return nullptr;
     }
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const override;
     sk_sp<SkTypeface> onMakeFromFile(const char[], int) const override {
         return nullptr;
     }
diff --git a/modules/skparagraph/src/TypefaceFontProvider.cpp b/modules/skparagraph/src/TypefaceFontProvider.cpp
index cd30a67..d1b9f26 100644
--- a/modules/skparagraph/src/TypefaceFontProvider.cpp
+++ b/modules/skparagraph/src/TypefaceFontProvider.cpp
@@ -24,10 +24,6 @@
     return nullptr;
 }
 
-sk_sp<SkTypeface> TypefaceFontProvider::onMakeFromFontData(std::unique_ptr<SkFontData>) const {
-    return nullptr;
-}
-
 size_t TypefaceFontProvider::registerTypeface(sk_sp<SkTypeface> typeface) {
     if (typeface == nullptr) {
         return 0;
diff --git a/src/core/SkFontDescriptor.cpp b/src/core/SkFontDescriptor.cpp
index 066e3ed..7445202 100644
--- a/src/core/SkFontDescriptor.cpp
+++ b/src/core/SkFontDescriptor.cpp
@@ -20,7 +20,6 @@
     // These count backwards from 0xFF, so as not to collide with the SFNT
     // defines for names in its 'name' table.
     kFontVariation  = 0xFA,
-    kFontAxes       = 0xFB, // Only picture version 79 and eariler.
     kFontIndex      = 0xFD,
     kSentinel       = 0xFF,
 };
@@ -55,25 +54,12 @@
     return i;
 }
 
-std::unique_ptr<SkFontData> SkFontDescriptor::maybeAsSkFontData() {
-    if (!fVariationDataIsOldAndBad || !this->hasStream()) {
-        return nullptr;
-    }
-    SkFontArguments args;
-    args.setCollectionIndex(this->getCollectionIndex());
-    args.setVariationDesignPosition({this->getVariation(), this->getVariationCoordinateCount()});
-    return std::make_unique<SkFontData>(this->dupStream(), args);
-}
-
 bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) {
     size_t styleBits;
     if (!stream->readPackedUInt(&styleBits)) { return false; }
     result->fStyle = SkFontStyle((styleBits >> 16) & 0xFFFF,
                                  (styleBits >> 8 ) & 0xFF,
                                  static_cast<SkFontStyle::Slant>(styleBits & 0xFF));
-    bool variationDataIsNewAndGood = false;
-    result->fVariationDataIsOldAndBad = false;
-    SkFixed oldBadVariationValue;
 
     size_t coordinateCount;
     using CoordinateCountType = decltype(result->fCoordinateCount);
@@ -92,26 +78,6 @@
             case kPostscriptName:
                 if (!read_string(stream, &result->fPostscriptName)) { return false; }
                 break;
-            case kFontAxes:
-                if (variationDataIsNewAndGood) {
-                    if (!stream->readPackedUInt(&coordinateCount)) { return false; }
-                    for (size_t i = 0; i < coordinateCount; ++i) {
-                        if (!stream->readS32(&oldBadVariationValue)) { return false; }
-                    }
-                } else {
-                    if (!stream->readPackedUInt(&coordinateCount)) { return false; }
-                    if (!SkTFitsIn<CoordinateCountType>(coordinateCount)) { return false; }
-                    result->fCoordinateCount = SkTo<CoordinateCountType>(coordinateCount);
-
-                    result->fVariation.reset(coordinateCount);
-                    for (size_t i = 0; i < coordinateCount; ++i) {
-                        if (!stream->readS32(&oldBadVariationValue)) { return false; }
-                        result->fVariation[i].axis = 0;
-                        result->fVariation[i].value = SkFixedToScalar(oldBadVariationValue);
-                    }
-                    result->fVariationDataIsOldAndBad = true;
-                }
-                break;
             case kFontVariation:
                 if (!stream->readPackedUInt(&coordinateCount)) { return false; }
                 if (!SkTFitsIn<CoordinateCountType>(coordinateCount)) { return false; }
@@ -122,8 +88,6 @@
                     if (!stream->readU32(&result->fVariation[i].axis)) { return false; }
                     if (!stream->readScalar(&result->fVariation[i].value)) { return false; }
                 }
-                variationDataIsNewAndGood = true;
-                result->fVariationDataIsOldAndBad = false;
                 break;
             case kFontIndex:
                 if (!stream->readPackedUInt(&index)) { return false; }
diff --git a/src/core/SkFontDescriptor.h b/src/core/SkFontDescriptor.h
index c4c2a83..4bc328a 100644
--- a/src/core/SkFontDescriptor.h
+++ b/src/core/SkFontDescriptor.h
@@ -94,8 +94,6 @@
         return fVariation.reset(coordinateCount);
     }
 
-    std::unique_ptr<SkFontData> maybeAsSkFontData();
-
 private:
     SkString fFamilyName;
     SkString fFullName;
@@ -105,7 +103,6 @@
     std::unique_ptr<SkStreamAsset> fStream;
     int fCollectionIndex = 0;
     using Coordinates = SkAutoSTMalloc<4, SkFontArguments::VariationPosition::Coordinate>;
-    bool fVariationDataIsOldAndBad = false;
     int fCoordinateCount = 0;
     Coordinates fVariation;
 };
diff --git a/src/core/SkFontMgr.cpp b/src/core/SkFontMgr.cpp
index f93404c..e06ad48 100644
--- a/src/core/SkFontMgr.cpp
+++ b/src/core/SkFontMgr.cpp
@@ -70,9 +70,6 @@
                                            const SkFontArguments&) const override {
         return nullptr;
     }
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const override {
-        return nullptr;
-    }
     sk_sp<SkTypeface> onMakeFromFile(const char[], int) const override {
         return nullptr;
     }
@@ -138,13 +135,6 @@
     return this->onMakeFromStreamArgs(std::move(stream), args);
 }
 
-sk_sp<SkTypeface> SkFontMgr::makeFromFontData(std::unique_ptr<SkFontData> data) const {
-    if (nullptr == data) {
-        return nullptr;
-    }
-    return this->onMakeFromFontData(std::move(data));
-}
-
 sk_sp<SkTypeface> SkFontMgr::makeFromFile(const char path[], int ttcIndex) const {
     if (nullptr == path) {
         return nullptr;
@@ -156,10 +146,6 @@
     return this->onLegacyMakeTypeface(familyName, style);
 }
 
-sk_sp<SkTypeface> SkFontMgr::onMakeFromFontData(std::unique_ptr<SkFontData> data) const {
-    return this->makeFromStream(data->detachStream(), data->getIndex());
-}
-
 // A global function pointer that's not declared, but can be overriden at startup by test tools.
 sk_sp<SkFontMgr> (*gSkFontMgr_DefaultFactory)() = nullptr;
 
diff --git a/src/core/SkPicturePriv.h b/src/core/SkPicturePriv.h
index 7da42ed..871943f 100644
--- a/src/core/SkPicturePriv.h
+++ b/src/core/SkPicturePriv.h
@@ -99,15 +99,6 @@
     // V87: SkPaint now holds a user-defined blend function (SkBlender), no longer has DrawLooper
 
     enum Version {
-        kEdgeAAQuadColor4f_Version          = 73,
-        kMorphologyTakesScalar_Version      = 74,
-        kVerticesUseReadBuffer_Version      = 75,
-        kFilterEnumInImageShader_Version    = 76,
-        kFilterOptionsInImageShader_Version = 77,
-        kSerializeMipmaps_Version           = 78,
-        kCubicResamplerImageShader_Version  = 79,
-        kSamplingInImageShader_Version      = 80,
-        kSamplingInDrawImage_Version        = 81,
         kPictureShaderFilterParam_Version   = 82,
         kMatrixImageFilterSampling_Version  = 83,
         kImageFilterImageSampling_Version   = 84,
@@ -116,12 +107,9 @@
         kSkBlenderInSkPaint                 = 87,
 
         // Only SKPs within the min/current picture version range (inclusive) can be read.
-        kMin_Version     = kEdgeAAQuadColor4f_Version,
+        kMin_Version     = kPictureShaderFilterParam_Version,
         kCurrent_Version = kSkBlenderInSkPaint
     };
-
-    static_assert(SkPicturePriv::kMin_Version <= SkPicturePriv::kCubicResamplerImageShader_Version,
-        "Remove SkFontDescriptor::maybeAsSkFontData, SkFontMgr::makeFromFontData, kFontAxes");
 };
 
 #endif
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 798654c..c89829e 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -314,83 +314,11 @@
     return *((uint32_t*)fCurr);
 }
 
-/*  Format:
- *  (subset) width, height
- *  (subset) origin x, y
- *  size (31bits)
- *  data [ encoded, with raw width/height ]
- */
-sk_sp<SkImage> SkReadBuffer::readImage_preV78() {
-    SkASSERT(this->isVersionLT(SkPicturePriv::kSerializeMipmaps_Version));
-
-    SkIRect bounds;
-    this->readIRect(&bounds);
-
-    const int width = bounds.width();
-    const int height = bounds.height();
-    if (width <= 0 || height <= 0) {    // SkImage never has a zero dimension
-        this->validate(false);
-        return nullptr;
-    }
-
-    int32_t size = this->read32();
-    if (size == SK_NaN32) {
-        // 0x80000000 is never valid, since it cannot be passed to abs().
-        this->validate(false);
-        return nullptr;
-    }
-    if (size == 0) {
-        // The image could not be encoded at serialization time - return an empty placeholder.
-        return MakeEmptyImage(width, height);
-    }
-
-    // we used to negate the size for "custom" encoded images -- ignore that signal (Dec-2017)
-    size = SkAbs32(size);
-    if (size == 1) {
-        // legacy check (we stopped writing this for "raw" images Nov-2017)
-        this->validate(false);
-        return nullptr;
-    }
-
-    // Preflight check to make sure there's enough stuff in the buffer before
-    // we allocate the memory. This helps the fuzzer avoid OOM when it creates
-    // bad/corrupt input.
-    if (!this->validateCanReadN<uint8_t>(size)) {
-        return nullptr;
-    }
-
-    sk_sp<SkData> data = SkData::MakeUninitialized(size);
-    if (!this->readPad32(data->writable_data(), size)) {
-        this->validate(false);
-        return nullptr;
-    }
-
-    sk_sp<SkImage> image;
-    if (fProcs.fImageProc) {
-        image = fProcs.fImageProc(data->data(), data->size(), fProcs.fImageCtx);
-    }
-    if (!image) {
-        image = SkImage::MakeFromEncoded(std::move(data));
-    }
-    if (image) {
-        if (bounds.x() || bounds.y() || width < image->width() || height < image->height()) {
-            image = image->makeSubset(bounds);
-        }
-    }
-    // Question: are we correct to return an "empty" image instead of nullptr, if the decoder
-    //           failed for some reason?
-    return image ? image : MakeEmptyImage(width, height);
-}
-
 #include "src/core/SkMipmap.h"
 
 // If we see a corrupt stream, we return null (fail). If we just fail trying to decode
 // the image, we don't fail, but return a 1x1 empty image.
 sk_sp<SkImage> SkReadBuffer::readImage() {
-    if (this->isVersionLT(SkPicturePriv::kSerializeMipmaps_Version)) {
-        return this->readImage_preV78();
-    }
-
     uint32_t flags = this->read32();
 
     sk_sp<SkImage> image;
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 77c687c..cffaac6 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -215,8 +215,6 @@
     bool readArray(void* value, size_t size, size_t elementSize);
     bool isAvailable(size_t size) const { return size <= this->available(); }
 
-    sk_sp<SkImage> readImage_preV78();
-
     // These are always 4-byte aligned
     const char* fCurr = nullptr;  // current position within buffer
     const char* fStop = nullptr;  // end of buffer
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 4df93d9..77d10c2 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -215,17 +215,6 @@
         }
     }
 
-    // Have to check for old data format first.
-    std::unique_ptr<SkFontData> data = desc.maybeAsSkFontData();
-    if (data) {
-        // Should only get here with old skps.
-        sk_sp<SkFontMgr> defaultFm = SkFontMgr::RefDefault();
-        sk_sp<SkTypeface> typeface(defaultFm->makeFromFontData(std::move(data)));
-        if (typeface) {
-            return typeface;
-        }
-    }
-
     if (desc.hasStream()) {
         SkFontArguments args;
         args.setCollectionIndex(desc.getCollectionIndex());
diff --git a/src/core/SkVertices.cpp b/src/core/SkVertices.cpp
index 972ccd8..7569de7 100644
--- a/src/core/SkVertices.cpp
+++ b/src/core/SkVertices.cpp
@@ -264,14 +264,6 @@
 }
 
 sk_sp<SkVertices> SkVerticesPriv::Decode(SkReadBuffer& buffer) {
-    if (buffer.isVersionLT(SkPicturePriv::kVerticesUseReadBuffer_Version)) {
-        // Old versions used an embedded blob that was serialized with SkWriter32/SkReader32.
-        // We don't support loading those, but skip over the vertices to keep the buffer valid.
-        auto data = buffer.readByteArrayAsData();
-        (void)data;
-        return nullptr;
-    }
-
     auto decode = [](SkReadBuffer& buffer) -> sk_sp<SkVertices> {
         SkSafeRange safe;
         bool hasCustomData = buffer.isVersionLT(SkPicturePriv::kVerticesRemoveCustomData_Version);
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index 358209f..5d97be0 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -113,16 +113,9 @@
 
 sk_sp<SkFlattenable> SkMorphologyImageFilter::CreateProc(SkReadBuffer& buffer) {
     SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
-    SkScalar width;
-    SkScalar height;
-    if (buffer.isVersionLT(SkPicturePriv::kMorphologyTakesScalar_Version)) {
-        width = buffer.readInt();
-        height = buffer.readInt();
-    } else {
-        width = buffer.readScalar();
-        height = buffer.readScalar();
-    }
 
+    SkScalar width = buffer.readScalar();
+    SkScalar height = buffer.readScalar();
     MorphType filterType = buffer.read32LE(MorphType::kLastType);
 
     if (filterType == MorphType::kDilate) {
diff --git a/src/ports/SkFontMgr_FontConfigInterface.cpp b/src/ports/SkFontMgr_FontConfigInterface.cpp
index aec954a..43fa7a7 100644
--- a/src/ports/SkFontMgr_FontConfigInterface.cpp
+++ b/src/ports/SkFontMgr_FontConfigInterface.cpp
@@ -281,28 +281,6 @@
         return stream ? this->makeFromStream(std::move(stream), ttcIndex) : nullptr;
     }
 
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData> fontData) const override {
-        SkStreamAsset* stream(fontData->getStream());
-        const size_t length = stream->getLength();
-        if (!length) {
-            return nullptr;
-        }
-        if (length >= 1024 * 1024 * 1024) {
-            return nullptr;  // don't accept too large fonts (>= 1GB) for safety.
-        }
-
-        const int ttcIndex = fontData->getIndex();
-        SkString name;
-        SkFontStyle style;
-        bool isFixedPitch = false;
-        if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, nullptr)) {
-            return nullptr;
-        }
-
-        return sk_sp<SkTypeface>(SkTypeface_FCI::Create(std::move(fontData), std::move(name),
-                                                        style, isFixedPitch));
-    }
-
     sk_sp<SkTypeface> onLegacyMakeTypeface(const char requestedFamilyName[],
                                            SkFontStyle requestedStyle) const override
     {
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp
index 89c3dbd..3ef7e10 100644
--- a/src/ports/SkFontMgr_android.cpp
+++ b/src/ports/SkFontMgr_android.cpp
@@ -476,18 +476,6 @@
                                                               style, isFixedPitch, name));
     }
 
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData> data) const override {
-        SkStreamAsset* stream(data->getStream());
-        bool isFixedPitch;
-        SkFontStyle style;
-        SkString name;
-        if (!fScanner.scanFont(stream, data->getIndex(), &name, &style, &isFixedPitch, nullptr)) {
-            return nullptr;
-        }
-        return sk_sp<SkTypeface>(new SkTypeface_AndroidStream(std::move(data),
-                                                              style, isFixedPitch, name));
-    }
-
     sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const override {
         if (familyName) {
             // On Android, we must return nullptr when we can't find the requested
diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp
index c0b72de..695c04d 100644
--- a/src/ports/SkFontMgr_custom.cpp
+++ b/src/ports/SkFontMgr_custom.cpp
@@ -254,17 +254,6 @@
     return sk_sp<SkTypeface>(new SkTypeface_Stream(std::move(data), style, isFixedPitch, false, name));
 }
 
-sk_sp<SkTypeface> SkFontMgr_Custom::onMakeFromFontData(std::unique_ptr<SkFontData> data) const {
-    bool isFixedPitch;
-    SkFontStyle style;
-    SkString name;
-    if (!fScanner.scanFont(data->getStream(), data->getIndex(),
-                            &name, &style, &isFixedPitch, nullptr)) {
-        return nullptr;
-    }
-    return sk_sp<SkTypeface>(new SkTypeface_Stream(std::move(data), style, isFixedPitch, false, name));
-}
-
 sk_sp<SkTypeface> SkFontMgr_Custom::onMakeFromFile(const char path[], int ttcIndex) const {
     std::unique_ptr<SkStreamAsset> stream = SkStream::MakeFromFile(path);
     return stream ? this->makeFromStream(std::move(stream), ttcIndex) : nullptr;
diff --git a/src/ports/SkFontMgr_custom.h b/src/ports/SkFontMgr_custom.h
index de02a26..8a70c6e 100644
--- a/src/ports/SkFontMgr_custom.h
+++ b/src/ports/SkFontMgr_custom.h
@@ -148,7 +148,6 @@
     sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData> data, int ttcIndex) const override;
     sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset>, int ttcIndex) const override;
     sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>, const SkFontArguments&) const override;
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData> data) const override;
     sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override;
     sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const override;
 
diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp
index b8e7f59..9e4e047 100644
--- a/src/ports/SkFontMgr_fontconfig.cpp
+++ b/src/ports/SkFontMgr_fontconfig.cpp
@@ -1002,25 +1002,6 @@
         return this->makeFromStream(SkStream::MakeFromFile(path), ttcIndex);
     }
 
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData> fontData) const override {
-        SkStreamAsset* stream(fontData->getStream());
-        const size_t length = stream->getLength();
-        if (length <= 0 || (1u << 30) < length) {
-            return nullptr;
-        }
-
-        const int ttcIndex = fontData->getIndex();
-        SkString name;
-        SkFontStyle style;
-        bool isFixedWidth = false;
-        if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedWidth, nullptr)) {
-            return nullptr;
-        }
-
-        return sk_sp<SkTypeface>(new SkTypeface_stream(std::move(fontData), std::move(name),
-                                                       style, isFixedWidth));
-    }
-
     sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const override {
         sk_sp<SkTypeface> typeface(this->matchFamilyStyle(familyName, style));
         if (typeface) {
diff --git a/src/ports/SkFontMgr_mac_ct.cpp b/src/ports/SkFontMgr_mac_ct.cpp
index bb62ccf..adfca81 100644
--- a/src/ports/SkFontMgr_mac_ct.cpp
+++ b/src/ports/SkFontMgr_mac_ct.cpp
@@ -198,78 +198,6 @@
 
 namespace {
 
-/** Creates a dictionary suitable for setting the axes on a CTFont. */
-static CTFontVariation ctvariation_from_skfontdata(CTFontRef ct, SkFontData* fontData) {
-    // In macOS 10.15 CTFontCreate* overrides any 'opsz' variation with the 'size'.
-    // Track the 'opsz' and return it, since it is an out of band axis.
-    OpszVariation opsz;
-    constexpr const SkFourByteTag opszTag = SkSetFourByteTag('o','p','s','z');
-
-    SkUniqueCFRef<CFArrayRef> ctAxes(CTFontCopyVariationAxes(ct));
-    if (!ctAxes) {
-        return CTFontVariation();
-    }
-
-    CFIndex axisCount = CFArrayGetCount(ctAxes.get());
-    if (0 == axisCount || axisCount != fontData->getAxisCount()) {
-        return CTFontVariation();
-    }
-
-    SkUniqueCFRef<CFMutableDictionaryRef> dict(
-            CFDictionaryCreateMutable(kCFAllocatorDefault, axisCount,
-                                      &kCFTypeDictionaryKeyCallBacks,
-                                      &kCFTypeDictionaryValueCallBacks));
-
-    for (int i = 0; i < fontData->getAxisCount(); ++i) {
-        CFTypeRef axisInfo = CFArrayGetValueAtIndex(ctAxes.get(), i);
-        if (CFDictionaryGetTypeID() != CFGetTypeID(axisInfo)) {
-            return CTFontVariation();
-        }
-        CFDictionaryRef axisInfoDict = static_cast<CFDictionaryRef>(axisInfo);
-
-        CFTypeRef tag = CFDictionaryGetValue(axisInfoDict,
-                                             kCTFontVariationAxisIdentifierKey);
-        if (!tag || CFGetTypeID(tag) != CFNumberGetTypeID()) {
-            return CTFontVariation();
-        }
-        CFNumberRef tagNumber = static_cast<CFNumberRef>(tag);
-        int64_t tagLong;
-        if (!CFNumberGetValue(tagNumber, kCFNumberSInt64Type, &tagLong)) {
-            return CTFontVariation();
-        }
-
-        // The variation axes can be set to any value, but cg will effectively pin them.
-        // Pin them here to normalize.
-        CFTypeRef min = CFDictionaryGetValue(axisInfoDict, kCTFontVariationAxisMinimumValueKey);
-        CFTypeRef max = CFDictionaryGetValue(axisInfoDict, kCTFontVariationAxisMaximumValueKey);
-        if (!min || CFGetTypeID(min) != CFNumberGetTypeID() ||
-            !max || CFGetTypeID(max) != CFNumberGetTypeID())
-        {
-            return CTFontVariation();
-        }
-        CFNumberRef minNumber = static_cast<CFNumberRef>(min);
-        CFNumberRef maxNumber = static_cast<CFNumberRef>(max);
-        double minDouble;
-        double maxDouble;
-        if (!CFNumberGetValue(minNumber, kCFNumberDoubleType, &minDouble) ||
-            !CFNumberGetValue(maxNumber, kCFNumberDoubleType, &maxDouble))
-        {
-            return CTFontVariation();
-        }
-        double value = SkTPin(SkFixedToDouble(fontData->getAxis()[i]), minDouble, maxDouble);
-
-        if (tagLong == opszTag) {
-            opsz.isSet = true;
-            opsz.value = value;
-        }
-
-        SkUniqueCFRef<CFNumberRef> valueNumber(
-                CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value));
-        CFDictionaryAddValue(dict.get(), tagNumber, valueNumber.get());
-    }
-    return { SkUniqueCFRef<CFDictionaryRef>(std::move(dict)), nullptr, opsz };
-}
-
 static sk_sp<SkData> skdata_from_skstreamasset(std::unique_ptr<SkStreamAsset> stream) {
     size_t size = stream->getLength();
     if (const void* base = stream->getMemoryBase()) {
@@ -630,45 +558,6 @@
         return SkTypeface_Mac::Make(std::move(ctVariant), ctVariation.opsz, std::move(stream));
     }
 
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData> fontData) const override {
-        // TODO: Use CTFontManagerCreateFontDescriptorsFromData when available.
-        if (fontData->getIndex() != 0) {
-            return nullptr;
-        }
-
-        sk_sp<SkData> data = skdata_from_skstreamasset(fontData->getStream()->duplicate());
-        if (!data) {
-            return nullptr;
-        }
-        SkUniqueCFRef<CTFontRef> ct = ctfont_from_skdata(std::move(data), fontData->getIndex());
-        if (!ct) {
-            return nullptr;
-        }
-
-        CTFontVariation ctVariation = ctvariation_from_skfontdata(ct.get(), fontData.get());
-
-        SkUniqueCFRef<CTFontRef> ctVariant;
-        if (ctVariation.variation) {
-            SkUniqueCFRef<CFMutableDictionaryRef> attributes(
-                    CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
-                                              &kCFTypeDictionaryKeyCallBacks,
-                                              &kCFTypeDictionaryValueCallBacks));
-            CFDictionaryAddValue(attributes.get(),
-                                 kCTFontVariationAttribute, ctVariation.variation.get());
-            SkUniqueCFRef<CTFontDescriptorRef> varDesc(
-                    CTFontDescriptorCreateWithAttributes(attributes.get()));
-            ctVariant.reset(CTFontCreateCopyWithAttributes(ct.get(), 0, nullptr, varDesc.get()));
-        } else {
-            ctVariant.reset(ct.release());
-        }
-        if (!ctVariant) {
-            return nullptr;
-        }
-
-        return SkTypeface_Mac::Make(std::move(ctVariant), ctVariation.opsz,
-                                    fontData->detachStream());
-    }
-
     sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override {
         if (ttcIndex != 0) {
             return nullptr;
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index 1ff23d1..2a20a2d 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -296,7 +296,6 @@
     sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>, const SkFontArguments&) const override;
     sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData>, int ttcIndex) const override;
     sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override;
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const override;
     sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle) const override;
 
 private:
@@ -1018,123 +1017,6 @@
     return this->makeFromStream(SkStream::MakeFromFile(path), ttcIndex);
 }
 
-static HRESULT apply_fontdata_variation(SkTScopedComPtr<IDWriteFontFace>& fontFace,
-                                        const std::unique_ptr<SkFontData>& data)
-{
-#if defined(NTDDI_WIN10_RS3) && NTDDI_VERSION >= NTDDI_WIN10_RS3
-    SkTScopedComPtr<IDWriteFontFace5> fontFace5;
-    if (FAILED(fontFace->QueryInterface(&fontFace5)) || !fontFace5->HasVariations()) {
-        return S_OK;
-    }
-
-    // Unfortunately the value returned by GetFontAxisValueCount is a lie, in the sense
-    // that it does not reflect the number of axes in the underlying font data.
-    // DirectWrite makes up some 'static' axes for 'wght', 'wdth', 'ital', 'slnt', and
-    // possibly others if not already present in the font.
-    // Be consistent with DWriteFontTypeface::onGetVariationDesignPosition.
-    UINT32 fontAxisCount = fontFace5->GetFontAxisValueCount();
-
-    SkTScopedComPtr<IDWriteFontResource> fontResource;
-    HR(fontFace5->GetFontResource(&fontResource));
-
-    int variableAxisCount = 0;
-    for (UINT32 i = 0; i < fontAxisCount; ++i) {
-        if (fontResource->GetFontAxisAttributes(i) & DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE) {
-            ++variableAxisCount;
-        }
-    }
-
-    if (variableAxisCount != data->getAxisCount()) {
-        return S_OK;
-    }
-
-    SkAutoSTMalloc<8, DWRITE_FONT_AXIS_VALUE> variation(fontAxisCount);
-    HR(fontResource->GetDefaultFontAxisValues(variation, fontAxisCount));
-
-    SkAutoSTMalloc<8, DWRITE_FONT_AXIS_RANGE> axisRanges(fontAxisCount);
-    HR(fontResource->GetFontAxisRanges(axisRanges, fontAxisCount));
-
-    UINT32 variableAxisIndex = 0;
-    for (UINT32 i = 0; i < fontAxisCount; ++i) {
-        if (fontResource->GetFontAxisAttributes(i) & DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE) {
-            DWRITE_FONT_AXIS_VALUE& coordinate = variation[i];
-            const DWRITE_FONT_AXIS_RANGE& axisRange = axisRanges[i];
-            coordinate.axisTag = axisRange.axisTag;
-            coordinate.value = SkTPin(SkFixedToFloat(data->getAxis()[variableAxisIndex]),
-                                      axisRange.minValue, axisRange.maxValue);
-            ++variableAxisIndex;
-        }
-    }
-
-    SkTScopedComPtr<IDWriteFontFace5> fontFace5_Out;
-    HR(fontResource->CreateFontFace(DWRITE_FONT_SIMULATIONS_NONE,
-                                    variation.get(), fontAxisCount,
-                                    &fontFace5_Out));
-    fontFace.reset();
-    HR(fontFace5_Out->QueryInterface(&fontFace));
-#endif
-    return S_OK;
-}
-sk_sp<SkTypeface> SkFontMgr_DirectWrite::onMakeFromFontData(std::unique_ptr<SkFontData> data) const{
-    if (!data->hasStream()) {
-        return nullptr;
-    }
-
-    SkTScopedComPtr<StreamFontFileLoader> fontFileLoader;
-    HRN(StreamFontFileLoader::Create(data->detachStream(), &fontFileLoader));
-    HRN(fFactory->RegisterFontFileLoader(fontFileLoader.get()));
-    SkAutoIDWriteUnregister<StreamFontFileLoader> autoUnregisterFontFileLoader(
-        fFactory.get(), fontFileLoader.get());
-
-    SkTScopedComPtr<StreamFontCollectionLoader> fontCollectionLoader;
-    HRN(StreamFontCollectionLoader::Create(fontFileLoader.get(), &fontCollectionLoader));
-    HRN(fFactory->RegisterFontCollectionLoader(fontCollectionLoader.get()));
-    SkAutoIDWriteUnregister<StreamFontCollectionLoader> autoUnregisterFontCollectionLoader(
-        fFactory.get(), fontCollectionLoader.get());
-
-    SkTScopedComPtr<IDWriteFontCollection> fontCollection;
-    HRN(fFactory->CreateCustomFontCollection(fontCollectionLoader.get(), nullptr, 0,
-        &fontCollection));
-
-    // Find the first non-simulated font which has the given ttc index.
-    UINT32 familyCount = fontCollection->GetFontFamilyCount();
-    for (UINT32 familyIndex = 0; familyIndex < familyCount; ++familyIndex) {
-        SkTScopedComPtr<IDWriteFontFamily> fontFamily;
-        HRN(fontCollection->GetFontFamily(familyIndex, &fontFamily));
-
-        UINT32 fontCount = fontFamily->GetFontCount();
-        for (UINT32 fontIndex = 0; fontIndex < fontCount; ++fontIndex) {
-            SkTScopedComPtr<IDWriteFont> font;
-            HRN(fontFamily->GetFont(fontIndex, &font));
-
-            // Skip if the current font is simulated
-            if (font->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) {
-                continue;
-            }
-            SkTScopedComPtr<IDWriteFontFace> fontFace;
-            HRN(font->CreateFontFace(&fontFace));
-            int faceIndex = fontFace->GetIndex();
-            int ttcIndex = data->getIndex();
-
-            // Skip if the current face index does not match the ttcIndex
-            if (faceIndex != ttcIndex) {
-                continue;
-            }
-
-            HRN(apply_fontdata_variation(fontFace, data));
-
-            return DWriteFontTypeface::Make(
-                fFactory.get(), fontFace.get(), font.get(), fontFamily.get(),
-                sk_make_sp<DWriteFontTypeface::Loaders>(
-                    fFactory.get(),
-                    autoUnregisterFontFileLoader.detatch(),
-                    autoUnregisterFontCollectionLoader.detatch()));
-        }
-    }
-
-    return nullptr;
-}
-
 HRESULT SkFontMgr_DirectWrite::getByFamilyName(const WCHAR wideFamilyName[],
                                                IDWriteFontFamily** fontFamily) const {
     UINT32 index;
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 8c6a019..a84beff 100755
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -92,56 +92,10 @@
     kLast = kUseCubicResampler,
 };
 
-sk_sp<SkFlattenable> SkImageShader::PreSamplingCreate(SkReadBuffer& buffer) {
-    SkASSERT(buffer.isVersionLT(SkPicturePriv::kSamplingInImageShader_Version));
-
-    auto tmx = buffer.read32LE<SkTileMode>(SkTileMode::kLastTileMode);
-    auto tmy = buffer.read32LE<SkTileMode>(SkTileMode::kLastTileMode);
-
-    LegacyFilterEnum fe = LegacyFilterEnum::kInheritFromPaint;
-    if (!buffer.isVersionLT(SkPicturePriv::kFilterEnumInImageShader_Version)) {
-        fe = buffer.read32LE<LegacyFilterEnum>(LegacyFilterEnum::kLast);
-    }
-
-    SkSamplingOptions op;
-
-    if (buffer.isVersionLT(SkPicturePriv::kCubicResamplerImageShader_Version)) {
-        if (!buffer.isVersionLT(SkPicturePriv::kFilterOptionsInImageShader_Version)) {
-            auto filter = buffer.read32LE<SkFilterMode>(SkFilterMode::kLinear);
-            auto mipmap = buffer.read32LE<SkMipmapMode>(SkMipmapMode::kLinear);
-            op = SkSamplingOptions(filter, mipmap);
-        }
-    } else {
-        switch (fe) {
-            case LegacyFilterEnum::kUseFilterOptions: {
-                auto filter = buffer.read32LE<SkFilterMode>(SkFilterMode::kLinear);
-                auto mipmap = buffer.read32LE<SkMipmapMode>(SkMipmapMode::kLinear);
-                op = SkSamplingOptions(filter, mipmap);
-            } break;
-            case LegacyFilterEnum::kUseCubicResampler: {
-                SkScalar B = buffer.readScalar(),
-                         C = buffer.readScalar();
-                op = SkSamplingOptions({B,C});
-            } break;
-            default:
-                break;
-        }
-    }
-
-    SkMatrix localMatrix;
-    buffer.readMatrix(&localMatrix);
-    sk_sp<SkImage> img = buffer.readImage();
-    return img ? SkImageShader::Make(std::move(img), tmx, tmy, op, &localMatrix) : nullptr;
-}
-
 // fClampAsIfUnpremul is always false when constructed through public APIs,
 // so there's no need to read or write it here.
 
 sk_sp<SkFlattenable> SkImageShader::CreateProc(SkReadBuffer& buffer) {
-    if (buffer.isVersionLT(SkPicturePriv::kSamplingInImageShader_Version)) {
-        return PreSamplingCreate(buffer);
-    }
-
     auto tmx = buffer.read32LE<SkTileMode>(SkTileMode::kLastTileMode);
     auto tmy = buffer.read32LE<SkTileMode>(SkTileMode::kLastTileMode);
 
diff --git a/src/shaders/SkImageShader.h b/src/shaders/SkImageShader.h
index 67202cb..acbc342 100644
--- a/src/shaders/SkImageShader.h
+++ b/src/shaders/SkImageShader.h
@@ -65,9 +65,6 @@
 
     friend class SkShaderBase;
     using INHERITED = SkShaderBase;
-
-    // for legacy unflattening
-    static sk_sp<SkFlattenable> PreSamplingCreate(SkReadBuffer&);
 };
 
 #endif
diff --git a/src/utils/SkOrderedFontMgr.cpp b/src/utils/SkOrderedFontMgr.cpp
index b105b4b..7c2fabd 100644
--- a/src/utils/SkOrderedFontMgr.cpp
+++ b/src/utils/SkOrderedFontMgr.cpp
@@ -91,10 +91,6 @@
     return nullptr;
 }
 
-sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromFontData(std::unique_ptr<SkFontData>) const {
-    return nullptr;
-}
-
 sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromFile(const char path[], int ttcIndex) const {
     return nullptr;
 }
diff --git a/tests/TypefaceTest.cpp b/tests/TypefaceTest.cpp
index 8558ca0..53d6412 100644
--- a/tests/TypefaceTest.cpp
+++ b/tests/TypefaceTest.cpp
@@ -149,28 +149,6 @@
     REPORTER_ASSERT(reporter, descD.getVariation()[0].value == -1.0f);
 };
 
-DEF_TEST(FontDescriptorDeserializeOldFormat, reporter) {
-    // From ossfuzz:26254
-    const uint8_t old_serialized_desc[] = {
-        0x0, //style
-        0xff, 0xfb, 0x0, 0x0, 0x0, // kFontAxes
-        0x0, // coordinateCount
-        0xff, 0xff, 0x0, 0x0, 0x0, // kSentinel
-        0x0, // data length
-    };
-
-    SkMemoryStream stream(old_serialized_desc, sizeof(old_serialized_desc), false);
-    SkFontDescriptor desc;
-    if (!SkFontDescriptor::Deserialize(&stream, &desc)) {
-        REPORT_FAILURE(reporter, "!SkFontDescriptor::Deserialize(&stream, &desc)",
-                       SkString("bytes should be recognized unless removing support"));
-        return;
-    }
-    // This call should not crash and should not return a valid SkFontData.
-    std::unique_ptr<SkFontData> data = desc.maybeAsSkFontData();
-    REPORTER_ASSERT(reporter, !data);
-};
-
 DEF_TEST(TypefaceAxes, reporter) {
     using Variation = SkFontArguments::VariationPosition;
     // In DWrite in at least up to 1901 18363.1198 IDWriteFontFace5::GetFontAxisValues and
diff --git a/tools/fonts/TestFontMgr.cpp b/tools/fonts/TestFontMgr.cpp
index e759f6c..023e43c 100644
--- a/tools/fonts/TestFontMgr.cpp
+++ b/tools/fonts/TestFontMgr.cpp
@@ -166,9 +166,6 @@
                                            const SkFontArguments&) const override {
         return nullptr;
     }
-    sk_sp<SkTypeface> onMakeFromFontData(std::unique_ptr<SkFontData>) const override {
-        return nullptr;
-    }
     sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override {
         return nullptr;
     }