Bump min picture to 7+ months ago

Delete lots of support code, including need for SkXfermode objects
which are no longer used anywhere else.

Bug: skia:
Change-Id: Id6b7ef0f529691041ff2b206c35e336e8a4c974d
Reviewed-on: https://skia-review.googlesource.com/19059
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 70f2acb..9f14f80 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -203,24 +203,9 @@
     // V53: SaveLayerRec clip mask
 
     // Only SKPs within the min/current picture version range (inclusive) can be read.
-    static const uint32_t     MIN_PICTURE_VERSION = 35;     // Produced by Chrome M39.
+    static const uint32_t     MIN_PICTURE_VERSION = 51;     // Produced by Chrome ~M56.
     static const uint32_t CURRENT_PICTURE_VERSION = 53;
 
-    static_assert(MIN_PICTURE_VERSION <= 41,
-                  "Remove kFontFileName and related code from SkFontDescriptor.cpp.");
-
-    static_assert(MIN_PICTURE_VERSION <= 42,
-                  "Remove COMMENT API handlers from SkPicturePlayback.cpp");
-
-    static_assert(MIN_PICTURE_VERSION <= 43,
-                  "Remove SkBitmapSourceDeserializer.");
-
-    static_assert(MIN_PICTURE_VERSION <= 45,
-                  "Remove decoding of old SkTypeface::Style from SkFontDescriptor.cpp.");
-
-    static_assert(MIN_PICTURE_VERSION <= 48,
-                  "Remove legacy gradient deserialization code from SkGradientShader.cpp.");
-
     static bool IsValidPictInfo(const SkPictInfo& info);
     static sk_sp<SkPicture> Forwardport(const SkPictInfo&,
                                         const SkPictureData*,
diff --git a/src/core/SkColorTable.cpp b/src/core/SkColorTable.cpp
index 928f515..2816de9 100644
--- a/src/core/SkColorTable.cpp
+++ b/src/core/SkColorTable.cpp
@@ -92,10 +92,6 @@
 }
 
 sk_sp<SkColorTable> SkColorTable::Create(SkReadBuffer& buffer) {
-    if (buffer.isVersionLT(SkReadBuffer::kRemoveColorTableAlpha_Version)) {
-        /*fAlphaType = */buffer.readUInt();
-    }
-
     const int count = buffer.getArrayCount();
     if (0 == count) {
         return sk_sp<SkColorTable>(new SkColorTable(nullptr, 0));
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index a0d3df7..453bcfd 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -140,10 +140,6 @@
 
     uint32_t flags = buffer.readUInt();
     fCropRect = CropRect(rect, flags);
-    if (buffer.isVersionLT(SkReadBuffer::kImageFilterNoUniqueID_Version)) {
-
-        (void) buffer.readUInt();
-    }
     return buffer.isValid();
 }
 
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 7875495..dcd29d6 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1917,14 +1917,9 @@
     uint32_t tmp = buffer.readUInt();
     this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF));
     this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF));
-    if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode_Version)) {
-        this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF));
-        this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF));
-    } else {
-        this->setStyle(static_cast<Style>((tmp >> 12) & 0xF));
-        this->setTextEncoding(static_cast<TextEncoding>((tmp >> 8) & 0xF));
-        this->setBlendMode((SkBlendMode)(tmp & 0xFF));
-    }
+    this->setStyle(static_cast<Style>((tmp >> 12) & 0xF));
+    this->setTextEncoding(static_cast<TextEncoding>((tmp >> 8) & 0xF));
+    this->setBlendMode((SkBlendMode)(tmp & 0xFF));
 
     if (flatFlags & kHasTypeface_FlatFlag) {
         this->setTypeface(buffer.readTypeface());
@@ -1935,25 +1930,11 @@
     if (flatFlags & kHasEffects_FlatFlag) {
         this->setPathEffect(buffer.readPathEffect());
         this->setShader(buffer.readShader());
-        if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode_Version)) {
-            sk_sp<SkXfermode> xfer = buffer.readXfermode();
-            this->setBlendMode(xfer ? xfer->blend() : SkBlendMode::kSrcOver);
-        }
         this->setMaskFilter(buffer.readMaskFilter());
         this->setColorFilter(buffer.readColorFilter());
         this->setRasterizer(buffer.readRasterizer());
         this->setLooper(buffer.readDrawLooper());
         this->setImageFilter(buffer.readImageFilter());
-
-        if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version)) {
-            // We used to store annotations here (string+skdata) if this bool was true
-            if (buffer.readBool()) {
-                // Annotations have moved to drawAnnotation, so we just drop this one on the floor.
-                SkString key;
-                buffer.readString(&key);
-                (void)buffer.readByteArrayAsData();
-            }
-        }
     } else {
         this->setPathEffect(nullptr);
         this->setShader(nullptr);
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 453d22f..4e61050 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -56,7 +56,6 @@
         kImageFilterUniqueID_Version       = 31,
         kRemoveAndroidPaintOpts_Version    = 32,
         kFlattenCreateProc_Version         = 33,
-        */
         kRemoveColorTableAlpha_Version     = 36,
         kDropShadowMode_Version            = 37,
         kPictureImageFilterResolution_Version = 38,
@@ -71,6 +70,7 @@
         kGradientShaderFloatColor_Version  = 49,
         kXfermodeToBlendMode_Version       = 50,
         kXfermodeToBlendMode2_Version      = 51,
+         */
         kTextBlobImplicitRunCount_Version  = 52,
     };
 
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index a44105d..50a97ff 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -743,11 +743,7 @@
     flags &= SkBlurMaskFilter::kAll_BlurFlag;
 
     SkRect occluder;
-    if (buffer.isVersionLT(SkReadBuffer::kBlurMaskFilterWritesOccluder)) {
-        occluder.setEmpty();
-    } else {
-        buffer.readRect(&occluder);
-    }
+    buffer.readRect(&occluder);
 
     if (style <= kLastEnum_SkBlurStyle) {
         return SkBlurMaskFilter::Make((SkBlurStyle)style, sigma, occluder, flags);
diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp
index 87e465f..9d778e0 100644
--- a/src/effects/SkDropShadowImageFilter.cpp
+++ b/src/effects/SkDropShadowImageFilter.cpp
@@ -46,9 +46,7 @@
     SkScalar sigmaX = buffer.readScalar();
     SkScalar sigmaY = buffer.readScalar();
     SkColor color = buffer.readColor();
-    ShadowMode shadowMode = buffer.isVersionLT(SkReadBuffer::kDropShadowMode_Version) ?
-                            kDrawShadowAndForeground_ShadowMode :
-                            static_cast<ShadowMode>(buffer.readInt());
+    ShadowMode shadowMode = static_cast<ShadowMode>(buffer.readInt());
     return Make(dx, dy, sigmaX, sigmaY, color, shadowMode, common.getInput(0), &common.cropRect());
 }
 
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index 2a86354..d6d433d 100644
--- a/src/effects/SkPictureImageFilter.cpp
+++ b/src/effects/SkPictureImageFilter.cpp
@@ -71,21 +71,11 @@
         }
     }
     buffer.readRect(&cropRect);
-    PictureResolution pictureResolution;
-    if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterResolution_Version)) {
-        pictureResolution = kDeviceSpace_PictureResolution;
-    } else {
-        pictureResolution = (PictureResolution)buffer.readInt();
-    }
+    PictureResolution pictureResolution = (PictureResolution)buffer.readInt();
 
     if (kLocalSpace_PictureResolution == pictureResolution) {
         //filterLevel is only serialized if pictureResolution is LocalSpace
-        SkFilterQuality filterQuality;
-        if (buffer.isVersionLT(SkReadBuffer::kPictureImageFilterLevel_Version)) {
-            filterQuality = kLow_SkFilterQuality;
-        } else {
-            filterQuality = (SkFilterQuality)buffer.readInt();
-        }
+        SkFilterQuality filterQuality = (SkFilterQuality)buffer.readInt();
         return MakeForLocalSpace(picture, cropRect, filterQuality);
     }
     return Make(picture, cropRect);
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 2af6d22..3228d15 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -85,21 +85,9 @@
 {}
 
 static int unflatten_blendmode(SkReadBuffer& buffer, SkArithmeticParams* arith) {
-    if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode_Version)) {
-        sk_sp<SkXfermode> xfer = buffer.readXfermode();
-        if (xfer) {
-            if (xfer->isArithmetic(arith)) {
-                return -1;
-            }
-            return (int)xfer->blend();
-        } else {
-            return (int)SkBlendMode::kSrcOver;
-        }
-    } else {
-        uint32_t mode = buffer.read32();
-        (void)buffer.validate(mode <= (unsigned)SkBlendMode::kLastMode);
-        return mode;
-    }
+    uint32_t mode = buffer.read32();
+    (void)buffer.validate(mode <= (unsigned)SkBlendMode::kLastMode);
+    return mode;
 }
 
 sk_sp<SkFlattenable> SkXfermodeImageFilter_Base::CreateProc(SkReadBuffer& buffer) {
diff --git a/src/shaders/SkComposeShader.cpp b/src/shaders/SkComposeShader.cpp
index 135f91d..75f9cd2 100644
--- a/src/shaders/SkComposeShader.cpp
+++ b/src/shaders/SkComposeShader.cpp
@@ -36,13 +36,8 @@
 sk_sp<SkFlattenable> SkComposeShader::CreateProc(SkReadBuffer& buffer) {
     sk_sp<SkShader> shaderA(buffer.readShader());
     sk_sp<SkShader> shaderB(buffer.readShader());
-    SkBlendMode mode;
-    if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode2_Version)) {
-        sk_sp<SkXfermode> xfer = buffer.readXfermode();
-        mode = xfer ? xfer->blend() : SkBlendMode::kSrcOver;
-    } else {
-        mode = (SkBlendMode)buffer.read32();
-    }
+    SkBlendMode mode = (SkBlendMode)buffer.read32();
+
     if (!shaderA || !shaderB) {
         return nullptr;
     }
diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp
index d6ee941..4bef53d 100644
--- a/src/shaders/SkPictureShader.cpp
+++ b/src/shaders/SkPictureShader.cpp
@@ -137,18 +137,12 @@
     sk_sp<SkPicture> picture;
 
     if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnabled()) {
-        if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Version)) {
-            // Older code blindly serialized pictures.  We don't trust them.
-            buffer.validate(false);
-            return nullptr;
-        }
         // Newer code won't serialize pictures in disallow-cross-process-picture mode.
         // Assert that they didn't serialize anything except a false here.
         buffer.validate(!buffer.readBool());
     } else {
-        // Old code always serialized the picture.  New code writes a 'true' first if it did.
-        if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Version) ||
-            buffer.readBool()) {
+        bool didSerialize = buffer.readBool();
+        if (didSerialize) {
             picture = SkPicture::MakeFromBuffer(buffer);
         }
     }
diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp
index ab774f6..2d21785 100644
--- a/src/shaders/gradients/SkGradientShader.cpp
+++ b/src/shaders/gradients/SkGradientShader.cpp
@@ -67,85 +67,43 @@
 }
 
 bool SkGradientShaderBase::DescriptorScope::unflatten(SkReadBuffer& buffer) {
-    if (buffer.isVersionLT(SkReadBuffer::kGradientShaderFloatColor_Version)) {
-        fCount = buffer.getArrayCount();
-        if (fCount > kStorageCount) {
-            size_t allocSize = (sizeof(SkColor4f) + sizeof(SkScalar)) * fCount;
-            fDynamicStorage.reset(allocSize);
-            fColors = (SkColor4f*)fDynamicStorage.get();
-            fPos = (SkScalar*)(fColors + fCount);
-        } else {
-            fColors = fColorStorage;
-            fPos = fPosStorage;
-        }
+    // New gradient format. Includes floating point color, color space, densely packed flags
+    uint32_t flags = buffer.readUInt();
 
-        // Old gradients serialized SkColor. Read that to a temporary location, then convert.
-        SkSTArray<2, SkColor, true> colors;
-        colors.resize_back(fCount);
-        if (!buffer.readColorArray(colors.begin(), fCount)) {
-            return false;
-        }
-        for (int i = 0; i < fCount; ++i) {
-            mutableColors()[i] = SkColor4f::FromColor(colors[i]);
-        }
+    fTileMode = (SkShader::TileMode)((flags >> kTileModeShift_GSF) & kTileModeMask_GSF);
+    fGradFlags = (flags >> kGradFlagsShift_GSF) & kGradFlagsMask_GSF;
 
-        if (buffer.readBool()) {
-            if (!buffer.readScalarArray(const_cast<SkScalar*>(fPos), fCount)) {
-                return false;
-            }
-        } else {
-            fPos = nullptr;
-        }
-
+    fCount = buffer.getArrayCount();
+    if (fCount > kStorageCount) {
+        size_t allocSize = (sizeof(SkColor4f) + sizeof(SkScalar)) * fCount;
+        fDynamicStorage.reset(allocSize);
+        fColors = (SkColor4f*)fDynamicStorage.get();
+        fPos = (SkScalar*)(fColors + fCount);
+    } else {
+        fColors = fColorStorage;
+        fPos = fPosStorage;
+    }
+    if (!buffer.readColor4fArray(mutableColors(), fCount)) {
+        return false;
+    }
+    if (SkToBool(flags & kHasColorSpace_GSF)) {
+        sk_sp<SkData> data = buffer.readByteArrayAsData();
+        fColorSpace = SkColorSpace::Deserialize(data->data(), data->size());
+    } else {
         fColorSpace = nullptr;
-        fTileMode = (SkShader::TileMode)buffer.read32();
-        fGradFlags = buffer.read32();
-
-        if (buffer.readBool()) {
-            fLocalMatrix = &fLocalMatrixStorage;
-            buffer.readMatrix(&fLocalMatrixStorage);
-        } else {
-            fLocalMatrix = nullptr;
+    }
+    if (SkToBool(flags & kHasPosition_GSF)) {
+        if (!buffer.readScalarArray(mutablePos(), fCount)) {
+            return false;
         }
     } else {
-        // New gradient format. Includes floating point color, color space, densely packed flags
-        uint32_t flags = buffer.readUInt();
-
-        fTileMode = (SkShader::TileMode)((flags >> kTileModeShift_GSF) & kTileModeMask_GSF);
-        fGradFlags = (flags >> kGradFlagsShift_GSF) & kGradFlagsMask_GSF;
-
-        fCount = buffer.getArrayCount();
-        if (fCount > kStorageCount) {
-            size_t allocSize = (sizeof(SkColor4f) + sizeof(SkScalar)) * fCount;
-            fDynamicStorage.reset(allocSize);
-            fColors = (SkColor4f*)fDynamicStorage.get();
-            fPos = (SkScalar*)(fColors + fCount);
-        } else {
-            fColors = fColorStorage;
-            fPos = fPosStorage;
-        }
-        if (!buffer.readColor4fArray(mutableColors(), fCount)) {
-            return false;
-        }
-        if (SkToBool(flags & kHasColorSpace_GSF)) {
-            sk_sp<SkData> data = buffer.readByteArrayAsData();
-            fColorSpace = SkColorSpace::Deserialize(data->data(), data->size());
-        } else {
-            fColorSpace = nullptr;
-        }
-        if (SkToBool(flags & kHasPosition_GSF)) {
-            if (!buffer.readScalarArray(mutablePos(), fCount)) {
-                return false;
-            }
-        } else {
-            fPos = nullptr;
-        }
-        if (SkToBool(flags & kHasLocalMatrix_GSF)) {
-            fLocalMatrix = &fLocalMatrixStorage;
-            buffer.readMatrix(&fLocalMatrixStorage);
-        } else {
-            fLocalMatrix = nullptr;
-        }
+        fPos = nullptr;
+    }
+    if (SkToBool(flags & kHasLocalMatrix_GSF)) {
+        fLocalMatrix = &fLocalMatrixStorage;
+        buffer.readMatrix(&fLocalMatrixStorage);
+    } else {
+        fLocalMatrix = nullptr;
     }
     return buffer.isValid();
 }
diff --git a/src/utils/SkBitmapSourceDeserializer.cpp b/src/utils/SkBitmapSourceDeserializer.cpp
index 1f8cc1c..ccc95ee 100644
--- a/src/utils/SkBitmapSourceDeserializer.cpp
+++ b/src/utils/SkBitmapSourceDeserializer.cpp
@@ -14,12 +14,7 @@
 #include "SkReadBuffer.h"
 
 sk_sp<SkFlattenable> SkBitmapSourceDeserializer::CreateProc(SkReadBuffer& buffer) {
-    SkFilterQuality filterQuality;
-    if (buffer.isVersionLT(SkReadBuffer::kBitmapSourceFilterQuality_Version)) {
-        filterQuality = kHigh_SkFilterQuality;
-    } else {
-        filterQuality = (SkFilterQuality)buffer.readInt();
-    }
+    SkFilterQuality filterQuality = (SkFilterQuality)buffer.readInt();
     SkRect src, dst;
     buffer.readRect(&src);
     buffer.readRect(&dst);