Revert "Revert "Remove MakeForLocalSpace since picture image is sufficient""

This reverts commit fc45998242b6e95ff610fd2c4edcf72c10e536ab.

Reason for revert: google3 updated (I think)

Original change's description:
> Revert "Remove MakeForLocalSpace since picture image is sufficient"
> 
> This reverts commit 0d8766c84c80537f323947089cc196c3cca106f4.
> 
> Reason for revert: broke google3
> 
> Original change's description:
> > Remove MakeForLocalSpace since picture image is sufficient
> > 
> > Bug: skia:
> > Change-Id: If38e702c418e93141311490edf447d1f09ed4434
> > Reviewed-on: https://skia-review.googlesource.com/68640
> > Commit-Queue: Mike Reed <reed@google.com>
> > Reviewed-by: Florin Malita <fmalita@chromium.org>
> 
> TBR=robertphillips@google.com,fmalita@chromium.org,reed@google.com
> 
> Change-Id: I3dec3d2c704e02b4db5977c27cc3e6d9f1c68ed5
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/69500
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=robertphillips@google.com,fmalita@chromium.org,reed@google.com

Change-Id: I5751fa637d280f361dea0f248a43c1f7e9bd8bdc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/69661
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp
index 3b3715f..064d38a 100644
--- a/fuzz/FuzzCanvas.cpp
+++ b/fuzz/FuzzCanvas.cpp
@@ -920,20 +920,12 @@
             return SkPictureImageFilter::Make(std::move(picture), cropRect);
         }
         case 22: {
-            SkRect cropRect;
-            SkFilterQuality filterQuality;
-            fuzz->next(&cropRect, &filterQuality);
-            sk_sp<SkPicture> picture = make_fuzz_picture(fuzz, depth - 1);
-            return SkPictureImageFilter::MakeForLocalSpace(std::move(picture), cropRect,
-                                                           filterQuality);
-        }
-        case 23: {
             SkRect src, dst;
             fuzz->next(&src, &dst);
             sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1);
             return SkTileImageFilter::Make(src, dst, std::move(input));
         }
-        case 24: {
+        case 23: {
             SkBlendMode blendMode;
             bool useCropRect;
             fuzz->next(&useCropRect, &blendMode);
diff --git a/gm/pictureimagefilter.cpp b/gm/pictureimagefilter.cpp
index 587ed37..c9a0d39 100644
--- a/gm/pictureimagefilter.cpp
+++ b/gm/pictureimagefilter.cpp
@@ -11,6 +11,9 @@
 #include "SkPictureImageFilter.h"
 #include "SkPictureRecorder.h"
 
+#include "SkImage.h"
+#include "SkImageSource.h"
+
 // This GM exercises the SkPictureImageFilter ImageFilter class.
 
 static void fill_rect_filtered(SkCanvas* canvas,
@@ -70,6 +73,16 @@
         fLCDPicture = make_LCD_picture();
     }
 
+    sk_sp<SkImageFilter> make(sk_sp<SkPicture> pic, SkRect r, SkFilterQuality fq) {
+        SkISize dim = { SkScalarRoundToInt(r.width()), SkScalarRoundToInt(r.height()) };
+        auto img = SkImage::MakeFromPicture(pic, dim, nullptr, nullptr,
+                                            SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB());
+        return SkImageSource::Make(img, r, r, fq);
+    }
+    sk_sp<SkImageFilter> make(SkFilterQuality fq) {
+        return make(fPicture, fPicture->cullRect(), fq);
+    }
+
     void onDraw(SkCanvas* canvas) override {
         canvas->clear(SK_ColorGRAY);
         {
@@ -81,14 +94,8 @@
                                                                                  srcRect));
             sk_sp<SkImageFilter> pictureSourceEmptyRect(SkPictureImageFilter::Make(fPicture,
                                                                                    emptyRect));
-            sk_sp<SkImageFilter> pictureSourceResampled(SkPictureImageFilter::MakeForLocalSpace(
-                                                                           fPicture,
-                                                                           fPicture->cullRect(),
-                                                                           kLow_SkFilterQuality));
-            sk_sp<SkImageFilter> pictureSourcePixelated(SkPictureImageFilter::MakeForLocalSpace(
-                                                                           fPicture,
-                                                                           fPicture->cullRect(),
-                                                                           kNone_SkFilterQuality));
+            sk_sp<SkImageFilter> pictureSourceResampled = make(kLow_SkFilterQuality);
+            sk_sp<SkImageFilter> pictureSourcePixelated = make(kNone_SkFilterQuality);
 
             canvas->save();
             // Draw the picture unscaled.
@@ -111,10 +118,7 @@
                 canvas->drawRect(bounds, stroke);
 
                 SkPaint paint;
-                paint.setImageFilter(SkPictureImageFilter::MakeForLocalSpace(
-                                                                        fLCDPicture,
-                                                                        fPicture->cullRect(),
-                                                                        kNone_SkFilterQuality));
+                paint.setImageFilter(make(fLCDPicture, fPicture->cullRect(), kNone_SkFilterQuality));
 
                 canvas->scale(4, 4);
                 canvas->translate(-0.9f*srcRect.fLeft, -2.45f*srcRect.fTop);
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index a5f2047..b3bc96b 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -201,10 +201,11 @@
     // V56: Add TileMode in SkBlurImageFilter.
     // V57: Sweep tiling info.
     // V58: No more 2pt conical flipping.
+    // V59: No more LocalSpace option on PictureImageFilter
 
     // Only SKPs within the min/current picture version range (inclusive) can be read.
     static const uint32_t     MIN_PICTURE_VERSION = 51;     // Produced by Chrome ~M56.
-    static const uint32_t CURRENT_PICTURE_VERSION = 58;
+    static const uint32_t CURRENT_PICTURE_VERSION = 59;
 
     static bool IsValidPictInfo(const SkPictInfo& info);
     static sk_sp<SkPicture> Forwardport(const SkPictInfo&,
diff --git a/include/effects/SkPictureImageFilter.h b/include/effects/SkPictureImageFilter.h
index 13bf66a..76e7b63 100644
--- a/include/effects/SkPictureImageFilter.h
+++ b/include/effects/SkPictureImageFilter.h
@@ -24,17 +24,6 @@
      */
     static sk_sp<SkImageFilter> Make(sk_sp<SkPicture> picture, const SkRect& cropRect);
 
-    /**
-     *  Refs the passed-in picture. The picture is rasterized at a resolution that matches the
-     *  local coordinate space. If the picture needs to be resampled for drawing it into the
-     *  destination canvas, bilinear filtering will be used. cropRect can be used to crop or
-     *  expand the destination rect when the picture is drawn. (No scaling is implied by the
-     *  dest rect; only the CTM is applied.)
-     */
-    static sk_sp<SkImageFilter> MakeForLocalSpace(sk_sp<SkPicture> picture,
-                                                  const SkRect& cropRect,
-                                                  SkFilterQuality filterQuality);
-
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
 
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index ab9ec7f..f7b724d 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -76,6 +76,7 @@
         kTileModeInBlurImageFilter_Version = 56,
         kTileInfoInSweepGradient_Version   = 57,
         k2PtConicalNoFlip_Version          = 58,
+        kRemovePictureImageFilterLocalSpace = 59,
     };
 
     /**
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index c335474..5611900 100644
--- a/src/effects/SkPictureImageFilter.cpp
+++ b/src/effects/SkPictureImageFilter.cpp
@@ -29,16 +29,6 @@
                                                          nullptr));
 }
 
-sk_sp<SkImageFilter> SkPictureImageFilter::MakeForLocalSpace(sk_sp<SkPicture> picture,
-                                                             const SkRect& cropRect,
-                                                             SkFilterQuality filterQuality) {
-    return sk_sp<SkImageFilter>(new SkPictureImageFilter(std::move(picture),
-                                                         cropRect,
-                                                         kLocalSpace_PictureResolution,
-                                                         filterQuality,
-                                                         nullptr));
-}
-
 SkPictureImageFilter::SkPictureImageFilter(sk_sp<SkPicture> picture)
     : INHERITED(nullptr, 0, nullptr)
     , fPicture(std::move(picture))
@@ -71,14 +61,25 @@
         }
     }
     buffer.readRect(&cropRect);
-    PictureResolution pictureResolution = (PictureResolution)buffer.readInt();
 
-    if (kLocalSpace_PictureResolution == pictureResolution) {
-        //filterLevel is only serialized if pictureResolution is LocalSpace
-        SkFilterQuality filterQuality = (SkFilterQuality)buffer.readInt();
-        return MakeForLocalSpace(picture, cropRect, filterQuality);
+    // NOTE: these two fields can be removed from the class once we have out-lived the need
+    // to load pictures older than SkReadBuffer::kRemovePictureImageFilterLocalSpace
+    //
+    PictureResolution pictureResolution = kDeviceSpace_PictureResolution;
+    SkFilterQuality filterQuality = kNone_SkFilterQuality;
+
+    if (buffer.isVersionLT(SkReadBuffer::kRemovePictureImageFilterLocalSpace)) {
+        pictureResolution = (PictureResolution)buffer.readInt();
+        if (kLocalSpace_PictureResolution == pictureResolution) {
+            //filterLevel is only serialized if pictureResolution is LocalSpace
+            filterQuality = (SkFilterQuality)buffer.readInt();
+        }
     }
-    return Make(picture, cropRect);
+    return sk_sp<SkImageFilter>(new SkPictureImageFilter(picture,
+                                                         cropRect,
+                                                         pictureResolution,
+                                                         filterQuality,
+                                                         nullptr));
 }
 
 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
@@ -92,10 +93,6 @@
         }
     }
     buffer.writeRect(fCropRect);
-    buffer.writeInt(fPictureResolution);
-    if (kLocalSpace_PictureResolution == fPictureResolution) {
-        buffer.writeInt(fFilterQuality);
-    }
 }
 
 sk_sp<SkSpecialImage> SkPictureImageFilter::onFilterImage(SkSpecialImage* source,