Merge latest Skia into master (7 commits)

https://skia.googlesource.com/skia.git/+log/d1e67e7..2229d44

Test: Presubmit checks will test this change.
Change-Id: Ief2bb8c7acf14d4f2f611e871323bc2465a71db8
diff --git a/Android.bp b/Android.bp
index 0e166c7..3250a8c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -402,6 +402,7 @@
         "src/gpu/GrPathRenderingRenderTargetContext.cpp",
         "src/gpu/GrPathUtils.cpp",
         "src/gpu/GrPipeline.cpp",
+        "src/gpu/GrPreFlushResourceProvider.cpp",
         "src/gpu/GrPrimitiveProcessor.cpp",
         "src/gpu/GrProcOptInfo.cpp",
         "src/gpu/GrProcessor.cpp",
@@ -1432,6 +1433,7 @@
         "tests/PixelRefTest.cpp",
         "tests/Point3Test.cpp",
         "tests/PointTest.cpp",
+        "tests/PreFlushCallbackTest.cpp",
         "tests/PremulAlphaRoundTripTest.cpp",
         "tests/PrimitiveProcessorTest.cpp",
         "tests/ProcessorTest.cpp",
diff --git a/gm/vertices.cpp b/gm/vertices.cpp
index 0d79827..864ac3d 100644
--- a/gm/vertices.cpp
+++ b/gm/vertices.cpp
@@ -214,8 +214,7 @@
     // Triangle fans can't batch so we convert to regular triangles,
     static constexpr int kNumTris = kMeshIndexCnt - 2;
     SkVertices::Builder builder(SkCanvas::kTriangles_VertexMode, kMeshVertexCnt, 3 * kNumTris,
-                                SkVertices::kHasColors_BuilderFlag |
-                                SkVertices::kHasTexCoords_BuilderFlag);
+                                SkVertices::kHasColors_Flag | SkVertices::kHasTexs_Flag);
 
     SkPoint* pts = builder.positions();
     SkPoint* texs = builder.texCoords();
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 6dc08a4..3046be8 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -131,6 +131,8 @@
   "$_src/gpu/GrPathUtils.cpp",
   "$_src/gpu/GrPathUtils.h",
   "$_src/gpu/GrPendingProgramElement.h",
+  "$_src/gpu/GrPreFlushResourceProvider.cpp",
+  "$_src/gpu/GrPreFlushResourceProvider.h",
   "$_src/gpu/GrPipeline.cpp",
   "$_src/gpu/GrPipeline.h",
   "$_src/gpu/GrPipelineBuilder.h",
diff --git a/gn/tests.gni b/gn/tests.gni
index b2a814e..e086e0a 100644
--- a/gn/tests.gni
+++ b/gn/tests.gni
@@ -152,6 +152,7 @@
   "$_tests/PDFMetadataAttributeTest.cpp",
   "$_tests/PDFOpaqueSrcModeToSrcOverTest.cpp",
   "$_tests/PDFPrimitivesTest.cpp",
+  "$_tests/PreFlushCallbackTest.cpp",
   "$_tests/PictureBBHTest.cpp",
   "$_tests/PictureShaderTest.cpp",
   "$_tests/PictureTest.cpp",
diff --git a/include/core/SkVertices.h b/include/core/SkVertices.h
index 8d6f211..af4e3bc 100644
--- a/include/core/SkVertices.h
+++ b/include/core/SkVertices.h
@@ -16,10 +16,14 @@
 #include "SkRefCnt.h"
 
 /**
- * An immutable set of vertex data that can be used with SkCanvas::drawVertices.
+ * An immutable set of vertex data that can be used with SkCanvas::drawVertices. Clients are
+ * encouraged to provide a bounds on the vertex positions if they can compute one more cheaply than
+ * looping over the positions.
  */
 class SkVertices : public SkNVRefCnt<SkVertices> {
 public:
+    ~SkVertices() { sk_free((void*)fPositions); }
+
     /**
      *  Create a vertices by copying the specified arrays. texs and colors may be nullptr,
      *  and indices is ignored if indexCount == 0.
@@ -38,93 +42,72 @@
         return MakeCopy(mode, vertexCount, positions, texs, colors, 0, nullptr);
     }
 
-    struct Sizes;
-
-    enum BuilderFlags {
-        kHasTexCoords_BuilderFlag   = 1 << 0,
-        kHasColors_BuilderFlag      = 1 << 1,
+    enum Flags {
+        kHasTexs_Flag    = 1 << 0,
+        kHasColors_Flag  = 1 << 1,
     };
     class Builder {
     public:
         Builder(SkCanvas::VertexMode mode, int vertexCount, int indexCount, uint32_t flags);
+        ~Builder();
 
-        bool isValid() const { return fVertices != nullptr; }
+        bool isValid() const { return fPositions != nullptr; }
 
-        // if the builder is invalid, these will return 0
-        int vertexCount() const;
-        int indexCount() const;
-        SkPoint* positions();
-        SkPoint* texCoords();   // returns null if there are no texCoords
-        SkColor* colors();      // returns null if there are no colors
-        uint16_t* indices();    // returns null if there are no indices
+        int vertexCount() const { return fVertexCnt; }
+        int indexCount() const { return fIndexCnt; }
+        SkPoint* positions() { return fPositions; }
+        SkPoint* texCoords() { return fTexs; }
+        SkColor* colors() { return fColors; }
+        uint16_t* indices() { return fIndices; }
 
-        // Detach the built vertices object. After the first call, this will always return null.
         sk_sp<SkVertices> detach();
 
     private:
-        Builder(SkCanvas::VertexMode mode, int vertexCount, int indexCount, const Sizes&);
-
-        void init(SkCanvas::VertexMode mode, int vertexCount, int indexCount, const Sizes&);
-
-        // holds a partially complete object. only completed in detach()
-        sk_sp<SkVertices> fVertices;
-
-        friend class SkVertices;
+        SkPoint* fPositions;  // owner of storage, use sk_free
+        SkPoint* fTexs;
+        SkColor* fColors;
+        uint16_t* fIndices;
+        int fVertexCnt;
+        int fIndexCnt;
+        SkCanvas::VertexMode fMode;
     };
 
-    uint32_t uniqueID() const { return fUniqueID; }
     SkCanvas::VertexMode mode() const { return fMode; }
-    const SkRect& bounds() const { return fBounds; }
 
-    bool hasColors() const { return SkToBool(this->colors()); }
-    bool hasTexCoords() const { return SkToBool(this->texCoords()); }
-    bool hasIndices() const { return SkToBool(this->indices()); }
-
+    uint32_t uniqueID() const { return fUniqueID; }
     int vertexCount() const { return fVertexCnt; }
+    bool hasColors() const { return SkToBool(fColors); }
+    bool hasTexCoords() const { return SkToBool(fTexs); }
     const SkPoint* positions() const { return fPositions; }
     const SkPoint* texCoords() const { return fTexs; }
     const SkColor* colors() const { return fColors; }
 
+    bool isIndexed() const { return SkToBool(fIndexCnt); }
     int indexCount() const { return fIndexCnt; }
     const uint16_t* indices() const { return fIndices; }
 
-    // returns approximate byte size of the vertices object
-    size_t approximateSize() const;
+    size_t size() const {
+        return fVertexCnt * (sizeof(SkPoint) * (this->hasTexCoords() ? 2 : 1) + sizeof(SkColor)) +
+               fIndexCnt * sizeof(uint16_t);
+    }
 
-    /**
-     *  Recreate a vertices from a buffer previously created by calling encode().
-     *  Returns null if the data is corrupt or the length is incorrect for the contents.
-     */
-    static sk_sp<SkVertices> Decode(const void* buffer, size_t length);
+    const SkRect& bounds() const { return fBounds; }
 
-    /**
-     *  Pack the vertices object into a byte buffer. This can be used to recreate the vertices
-     *  by calling Decode() with the buffer.
-     */
+    static sk_sp<SkVertices> Decode(const void*, size_t);
     sk_sp<SkData> encode() const;
 
 private:
     SkVertices() {}
 
-    static sk_sp<SkVertices> Alloc(int vCount, int iCount, uint32_t builderFlags,
-                                   size_t* arraySize);
-
-    // we store this first, to pair with the refcnt in our base-class, so we don't have an
-    // unnecessary pad between it and the (possibly 8-byte aligned) ptrs.
+    const SkPoint* fPositions;  // owner of storage, use sk_free
+    const SkPoint* fTexs;
+    const SkColor* fColors;
+    const uint16_t* fIndices;
+    SkRect fBounds;
     uint32_t fUniqueID;
-
-    // these point inside our allocation, so none of these can be "freed"
-    SkPoint*    fPositions;
-    SkPoint*    fTexs;
-    SkColor*    fColors;
-    uint16_t*   fIndices;
-
-    SkRect  fBounds;    // computed to be the union of the fPositions[]
-    int     fVertexCnt;
-    int     fIndexCnt;
-
+    int fVertexCnt;
+    int fIndexCnt;
     SkCanvas::VertexMode fMode;
-    // below here is where the actual array data is stored.
 };
 
 #endif
diff --git a/infra/bots/assets/svg/VERSION b/infra/bots/assets/svg/VERSION
index bf0d87a..7813681 100644
--- a/infra/bots/assets/svg/VERSION
+++ b/infra/bots/assets/svg/VERSION
@@ -1 +1 @@
-4
\ No newline at end of file
+5
\ No newline at end of file
diff --git a/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-x86_64-Release-Vulkan.json b/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-x86_64-Release-Vulkan.json
index 030204e..7a47920 100644
--- a/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-x86_64-Release-Vulkan.json
+++ b/infra/bots/recipe_modules/compile/example.expected/Build-Ubuntu-Clang-x86_64-Release-Vulkan.json
@@ -99,7 +99,7 @@
       "[CUSTOM_/_B_WORK]/skia/bin/gn",
       "gen",
       "[CUSTOM_/_B_WORK]/skia/out/Build-Ubuntu-Clang-x86_64-Release-Vulkan/Release",
-      "--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_ldflags=[\"-fuse-ld=lld\"] is_debug=false skia_vulkan_sdk=\"[START_DIR]/linux_vulkan_sdk\" target_cpu=\"x86_64\""
+      "--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_ldflags=[\"-fuse-ld=lld\"] is_debug=false skia_enable_vulkan_debug_layers=false skia_vulkan_sdk=\"[START_DIR]/linux_vulkan_sdk\" target_cpu=\"x86_64\""
     ],
     "cwd": "[CUSTOM_/_B_WORK]/skia",
     "env": {
diff --git a/infra/bots/recipe_modules/compile/example.expected/Build-Win-MSVC-x86_64-Release-Vulkan.json b/infra/bots/recipe_modules/compile/example.expected/Build-Win-MSVC-x86_64-Release-Vulkan.json
index dc8e4d4..db8a677 100644
--- a/infra/bots/recipe_modules/compile/example.expected/Build-Win-MSVC-x86_64-Release-Vulkan.json
+++ b/infra/bots/recipe_modules/compile/example.expected/Build-Win-MSVC-x86_64-Release-Vulkan.json
@@ -99,7 +99,7 @@
       "[CUSTOM_C:\\_B_WORK]\\skia\\bin\\gn.exe",
       "gen",
       "[CUSTOM_C:\\_B_WORK]\\skia\\out\\Build-Win-MSVC-x86_64-Release-Vulkan\\Release_x64",
-      "--args=is_debug=false skia_vulkan_sdk=\"[START_DIR]\\win_vulkan_sdk\" target_cpu=\"x86_64\" windk=\"[START_DIR]\\t\\depot_tools\\win_toolchain\\vs_files\\d3cb0e37bdd120ad0ac4650b674b09e81be45616\""
+      "--args=is_debug=false skia_enable_vulkan_debug_layers=false skia_vulkan_sdk=\"[START_DIR]\\win_vulkan_sdk\" target_cpu=\"x86_64\" windk=\"[START_DIR]\\t\\depot_tools\\win_toolchain\\vs_files\\d3cb0e37bdd120ad0ac4650b674b09e81be45616\""
     ],
     "cwd": "[CUSTOM_C:\\_B_WORK]\\skia",
     "env": {
diff --git a/infra/bots/recipe_modules/compile/example.expected/alternate_repo.json b/infra/bots/recipe_modules/compile/example.expected/alternate_repo.json
index ebf96a4..c4ec810 100644
--- a/infra/bots/recipe_modules/compile/example.expected/alternate_repo.json
+++ b/infra/bots/recipe_modules/compile/example.expected/alternate_repo.json
@@ -99,7 +99,7 @@
       "[CUSTOM_C:\\_B_WORK]/skia/bin/gn.exe",
       "gen",
       "[CUSTOM_C:\\_B_WORK]/skia/out/Build-Win-MSVC-x86_64-Release-Vulkan/Release_x64",
-      "--args=is_debug=false skia_vulkan_sdk=\"[START_DIR]/win_vulkan_sdk\" target_cpu=\"x86_64\" windk=\"[START_DIR]/t/depot_tools/win_toolchain/vs_files/d3cb0e37bdd120ad0ac4650b674b09e81be45616\""
+      "--args=is_debug=false skia_enable_vulkan_debug_layers=false skia_vulkan_sdk=\"[START_DIR]/win_vulkan_sdk\" target_cpu=\"x86_64\" windk=\"[START_DIR]/t/depot_tools/win_toolchain/vs_files/d3cb0e37bdd120ad0ac4650b674b09e81be45616\""
     ],
     "cwd": "[CUSTOM_C:\\_B_WORK]/skia",
     "env": {
diff --git a/infra/bots/recipe_modules/flavor/gn_flavor.py b/infra/bots/recipe_modules/flavor/gn_flavor.py
index bfff36e..864bd9d 100644
--- a/infra/bots/recipe_modules/flavor/gn_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_flavor.py
@@ -95,6 +95,7 @@
     if extra_config == 'Shared':
       args['is_component_build'] = 'true'
     if extra_config == 'Vulkan':
+      args['skia_enable_vulkan_debug_layers'] = 'false'
       if os == 'Ubuntu':
         args['skia_vulkan_sdk'] = '"%s"' % linux_vulkan_sdk
       if 'Win' in os:
diff --git a/infra/bots/tasks.json b/infra/bots/tasks.json
index 35fd03c..6f7678f 100644
--- a/infra/bots/tasks.json
+++ b/infra/bots/tasks.json
@@ -4047,7 +4047,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4097,7 +4097,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4147,7 +4147,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4197,7 +4197,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4247,7 +4247,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4297,7 +4297,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4347,7 +4347,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4397,7 +4397,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4447,7 +4447,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4497,7 +4497,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4547,7 +4547,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4597,7 +4597,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4647,7 +4647,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4697,7 +4697,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4747,7 +4747,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4797,7 +4797,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4847,7 +4847,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4897,7 +4897,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4947,7 +4947,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -4997,7 +4997,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5047,7 +5047,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5097,7 +5097,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5147,7 +5147,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5197,7 +5197,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5247,7 +5247,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5297,7 +5297,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5347,7 +5347,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5397,7 +5397,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5447,7 +5447,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5497,7 +5497,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5547,7 +5547,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5597,7 +5597,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5647,7 +5647,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5697,7 +5697,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5747,7 +5747,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5797,7 +5797,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5847,7 +5847,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -5977,7 +5977,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6026,7 +6026,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6075,7 +6075,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6125,7 +6125,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6175,7 +6175,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6224,7 +6224,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6273,7 +6273,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6322,7 +6322,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6372,7 +6372,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -6427,7 +6427,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -6482,7 +6482,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6532,7 +6532,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -6587,7 +6587,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6637,7 +6637,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -6691,7 +6691,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -6745,7 +6745,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6795,7 +6795,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6845,7 +6845,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6895,7 +6895,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -6995,7 +6995,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -7044,7 +7044,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -7093,7 +7093,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -7142,7 +7142,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -7289,7 +7289,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_debug",
@@ -7343,7 +7343,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_release",
@@ -7397,7 +7397,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_debug",
@@ -7451,7 +7451,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_sdk",
@@ -7510,7 +7510,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_release",
@@ -7564,7 +7564,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_sdk",
@@ -7623,7 +7623,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_debug",
@@ -7677,7 +7677,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_release",
@@ -7731,7 +7731,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -7780,7 +7780,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -7829,7 +7829,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -7878,7 +7878,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -7927,7 +7927,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -7976,7 +7976,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8025,7 +8025,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8074,7 +8074,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8123,7 +8123,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8172,7 +8172,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8221,7 +8221,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8270,7 +8270,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8319,7 +8319,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8368,7 +8368,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8417,7 +8417,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8466,7 +8466,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8516,7 +8516,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8566,7 +8566,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8615,7 +8615,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8664,7 +8664,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8713,7 +8713,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8762,7 +8762,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8811,7 +8811,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8860,7 +8860,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8909,7 +8909,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -8958,7 +8958,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9008,7 +9008,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9058,7 +9058,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9108,7 +9108,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9158,7 +9158,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9207,7 +9207,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9256,7 +9256,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9305,7 +9305,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9354,7 +9354,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9403,7 +9403,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9452,7 +9452,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9502,7 +9502,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9552,7 +9552,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9602,7 +9602,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9652,7 +9652,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9701,7 +9701,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9750,7 +9750,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9800,7 +9800,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9850,7 +9850,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9900,7 +9900,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -9950,7 +9950,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10000,7 +10000,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10050,7 +10050,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10100,7 +10100,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10150,7 +10150,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10200,7 +10200,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10250,7 +10250,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10300,7 +10300,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10350,7 +10350,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10400,7 +10400,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10450,7 +10450,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10500,7 +10500,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10550,7 +10550,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10600,7 +10600,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10650,7 +10650,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10700,7 +10700,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10750,7 +10750,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10800,7 +10800,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10850,7 +10850,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10900,7 +10900,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -10950,7 +10950,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11000,7 +11000,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11050,7 +11050,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11100,7 +11100,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11150,7 +11150,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11200,7 +11200,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11250,7 +11250,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11300,7 +11300,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11350,7 +11350,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11400,7 +11400,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11450,7 +11450,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11500,7 +11500,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11550,7 +11550,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11600,7 +11600,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11650,7 +11650,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11700,7 +11700,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11750,7 +11750,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11800,7 +11800,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11849,7 +11849,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11898,7 +11898,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11948,7 +11948,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -11998,7 +11998,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12047,7 +12047,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12096,7 +12096,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12145,7 +12145,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12195,7 +12195,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -12250,7 +12250,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -12305,7 +12305,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12355,7 +12355,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -12410,7 +12410,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12460,7 +12460,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -12515,7 +12515,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -12569,7 +12569,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -12623,7 +12623,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/clang_linux",
@@ -12677,7 +12677,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12727,7 +12727,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12852,7 +12852,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12902,7 +12902,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -12952,7 +12952,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13002,7 +13002,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13051,7 +13051,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13100,7 +13100,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13149,7 +13149,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13198,7 +13198,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13345,7 +13345,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_debug",
@@ -13399,7 +13399,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_release",
@@ -13453,7 +13453,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_debug",
@@ -13507,7 +13507,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_sdk",
@@ -13566,7 +13566,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_release",
@@ -13620,7 +13620,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_sdk",
@@ -13679,7 +13679,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_debug",
@@ -13733,7 +13733,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         },
         {
           "name": "skia/bots/linux_vulkan_intel_driver_release",
@@ -13787,7 +13787,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13836,7 +13836,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13885,7 +13885,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13934,7 +13934,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -13983,7 +13983,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14032,7 +14032,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14081,7 +14081,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14130,7 +14130,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14179,7 +14179,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14228,7 +14228,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14277,7 +14277,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14326,7 +14326,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14375,7 +14375,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14424,7 +14424,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14473,7 +14473,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14522,7 +14522,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14572,7 +14572,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14622,7 +14622,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14671,7 +14671,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14720,7 +14720,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14769,7 +14769,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14818,7 +14818,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14867,7 +14867,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14916,7 +14916,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -14965,7 +14965,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15015,7 +15015,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15065,7 +15065,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15115,7 +15115,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15165,7 +15165,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15214,7 +15214,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15263,7 +15263,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15312,7 +15312,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15361,7 +15361,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15410,7 +15410,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15459,7 +15459,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15509,7 +15509,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15559,7 +15559,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15609,7 +15609,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15659,7 +15659,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15709,7 +15709,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15759,7 +15759,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
@@ -15808,7 +15808,7 @@
         {
           "name": "skia/bots/svg",
           "path": "svg",
-          "version": "version:4"
+          "version": "version:5"
         }
       ],
       "dependencies": [
diff --git a/src/core/SkReader32.h b/src/core/SkReader32.h
index 7e31fb9..1f027f7 100644
--- a/src/core/SkReader32.h
+++ b/src/core/SkReader32.h
@@ -96,7 +96,7 @@
     void read(void* dst, size_t size) {
         SkASSERT(0 == size || dst != nullptr);
         SkASSERT(ptr_align_4(fCurr));
-        memcpy(dst, fCurr, size);
+        sk_careful_memcpy(dst, fCurr, size);
         fCurr += SkAlign4(size);
         SkASSERT(fCurr <= fStop);
     }
diff --git a/src/core/SkVertices.cpp b/src/core/SkVertices.cpp
index 1980b7e..936d70d 100644
--- a/src/core/SkVertices.cpp
+++ b/src/core/SkVertices.cpp
@@ -20,199 +20,202 @@
     return id;
 }
 
-struct SkVertices::Sizes {
-    Sizes(int vertexCount, int indexCount, bool hasTexs, bool hasColors) {
-        int64_t vSize = (int64_t)vertexCount * sizeof(SkPoint);
-        int64_t tSize = hasTexs ? (int64_t)vertexCount * sizeof(SkPoint) : 0;
-        int64_t cSize = hasColors ? (int64_t)vertexCount * sizeof(SkColor) : 0;
-        int64_t iSize = (int64_t)indexCount * sizeof(uint16_t);
-
-        int64_t total = sizeof(SkVertices) + vSize + tSize + cSize + iSize;
-        if (!sk_64_isS32(total)) {
-            sk_bzero(this, sizeof(*this));
-        } else {
-            fTotal = SkToSizeT(total);
-            fVSize = SkToSizeT(vSize);
-            fTSize = SkToSizeT(tSize);
-            fCSize = SkToSizeT(cSize);
-            fISize = SkToSizeT(iSize);
-            fArrays = fTotal - sizeof(SkVertices);  // just the sum of the arrays
-        }
+static size_t compute_arrays_size(int vertexCount, int indexCount, uint32_t builderFlags) {
+    if (vertexCount < 0 || indexCount < 0) {
+        return 0;   // signal error
     }
 
-    bool isValid() const { return fTotal != 0; }
-
-    size_t fTotal;  // size of entire SkVertices allocation (obj + arrays)
-    size_t fArrays; // size of all the arrays (V + T + C + I)
-    size_t fVSize;
-    size_t fTSize;
-    size_t fCSize;
-    size_t fISize;
-};
-
-SkVertices::Builder::Builder(SkCanvas::VertexMode mode, int vertexCount, int indexCount,
-                             uint32_t builderFlags) {
-    bool hasTexs = SkToBool(builderFlags & SkVertices::kHasTexCoords_BuilderFlag);
-    bool hasColors = SkToBool(builderFlags & SkVertices::kHasColors_BuilderFlag);
-    this->init(mode, vertexCount, indexCount,
-               SkVertices::Sizes(vertexCount, indexCount, hasTexs, hasColors));
+    uint64_t size = vertexCount * sizeof(SkPoint);
+    if (builderFlags & SkVertices::kHasTexs_Flag) {
+        size += vertexCount * sizeof(SkPoint);
+    }
+    if (builderFlags & SkVertices::kHasColors_Flag) {
+        size += vertexCount * sizeof(SkColor);
+    }
+    size += indexCount * sizeof(uint16_t);
+    if (!sk_64_isS32(size)) {
+        return 0;   // signal error
+    }
+    return (size_t)size;
 }
 
 SkVertices::Builder::Builder(SkCanvas::VertexMode mode, int vertexCount, int indexCount,
-                             const SkVertices::Sizes& sizes) {
-    this->init(mode, vertexCount, indexCount, sizes);
-}
+                             uint32_t flags) {
+    fPositions = nullptr;   // signal that we have nothing to cleanup
+    fColors = nullptr;
+    fTexs = nullptr;
+    fIndices = nullptr;
+    fVertexCnt = 0;
+    fIndexCnt = 0;
 
-void SkVertices::Builder::init(SkCanvas::VertexMode mode, int vertexCount, int indexCount,
-                               const SkVertices::Sizes& sizes) {
-    if (!sizes.isValid()) {
-        return; // fVertices will already be null
+    size_t size = compute_arrays_size(vertexCount, indexCount, flags);
+    if (0 == size) {
+        return;
     }
 
-    void* storage = ::operator new (sizes.fTotal);
-    fVertices.reset(new (storage) SkVertices);
+    char* ptr = (char*)sk_malloc_throw(sk_64_asS32(size));
 
-    // need to point past the object to store the arrays
-    char* ptr = (char*)fVertices.get() + sizeof(SkVertices);
+    fMode = mode;
+    fVertexCnt = vertexCount;
+    fIndexCnt = indexCount;
+    fPositions = (SkPoint*)ptr;  // owner
+    ptr += vertexCount * sizeof(SkPoint);
 
-    fVertices->fPositions = (SkPoint*)ptr;                          ptr += sizes.fVSize;
-    fVertices->fTexs = sizes.fTSize ? (SkPoint*)ptr : nullptr;      ptr += sizes.fTSize;
-    fVertices->fColors = sizes.fCSize ? (SkColor*)ptr : nullptr;    ptr += sizes.fCSize;
-    fVertices->fIndices = sizes.fISize ? (uint16_t*)ptr : nullptr;
-    fVertices->fVertexCnt = vertexCount;
-    fVertices->fIndexCnt = indexCount;
-    fVertices->fMode = mode;
-    // We defer assigning fBounds and fUniqueID until detach() is called
+    if (flags & kHasTexs_Flag) {
+        fTexs = (SkPoint*)ptr;
+        ptr += vertexCount * sizeof(SkPoint);
+    }
+    if (flags & kHasColors_Flag) {
+        fColors = (SkColor*)ptr;
+        ptr += vertexCount * sizeof(SkColor);
+    }
+    if (indexCount) {
+        fIndices = (uint16_t*)ptr;
+    }
+}
+
+SkVertices::Builder::~Builder() {
+    sk_free(fPositions);
 }
 
 sk_sp<SkVertices> SkVertices::Builder::detach() {
-    if (fVertices) {
-        fVertices->fBounds.set(fVertices->fPositions, fVertices->fVertexCnt);
-        fVertices->fUniqueID = next_id();
-        return std::move(fVertices);        // this will null fVertices after the return
+    if (!fPositions) {
+        return nullptr;
     }
-    return nullptr;
-}
 
-int SkVertices::Builder::vertexCount() const {
-    return fVertices ? fVertices->vertexCount() : 0;
-}
+    SkVertices* obj = new SkVertices;
+    obj->fPositions = fPositions;  // owner of storage, use sk_free
+    obj->fTexs = fTexs;
+    obj->fColors = fColors;
+    obj->fIndices = fIndices;
+    obj->fBounds.set(fPositions, fVertexCnt);
+    obj->fUniqueID = next_id();
+    obj->fVertexCnt = fVertexCnt;
+    obj->fIndexCnt = fIndexCnt;
+    obj->fMode = fMode;
 
-int SkVertices::Builder::indexCount() const {
-    return fVertices ? fVertices->indexCount() : 0;
-}
+    fPositions = nullptr;   // so we don't free the memory, now that obj owns it
 
-SkPoint* SkVertices::Builder::positions() {
-    return fVertices ? const_cast<SkPoint*>(fVertices->positions()) : nullptr;
+    return sk_sp<SkVertices>(obj);
 }
 
-SkPoint* SkVertices::Builder::texCoords() {
-    return fVertices ? const_cast<SkPoint*>(fVertices->texCoords()) : nullptr;
-}
-
-SkColor* SkVertices::Builder::colors() {
-    return fVertices ? const_cast<SkColor*>(fVertices->colors()) : nullptr;
-}
-
-uint16_t* SkVertices::Builder::indices() {
-    return fVertices ? const_cast<uint16_t*>(fVertices->indices()) : nullptr;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
 sk_sp<SkVertices> SkVertices::MakeCopy(SkCanvas::VertexMode mode, int vertexCount,
                                        const SkPoint pos[], const SkPoint texs[],
                                        const SkColor colors[], int indexCount,
                                        const uint16_t indices[]) {
-    Sizes sizes(vertexCount, indexCount, texs != nullptr, colors != nullptr);
-    if (!sizes.isValid()) {
+    uint32_t flags = 0;
+    if (texs) {
+        flags |= kHasTexs_Flag;
+    }
+    if (colors) {
+        flags |= kHasColors_Flag;
+    }
+    Builder builder(mode, vertexCount, indexCount, flags);
+    if (!builder.isValid()) {
         return nullptr;
     }
 
-    Builder builder(mode, vertexCount, indexCount, sizes);
-    SkASSERT(builder.isValid());
-
-    sk_careful_memcpy(builder.positions(), pos, sizes.fVSize);
-    sk_careful_memcpy(builder.texCoords(), texs, sizes.fTSize);
-    sk_careful_memcpy(builder.colors(), colors, sizes.fCSize);
-    sk_careful_memcpy(builder.indices(), indices, sizes.fISize);
-
+    memcpy(builder.positions(), pos, vertexCount * sizeof(SkPoint));
+    if (texs) {
+        memcpy(builder.texCoords(), texs, vertexCount * sizeof(SkPoint));
+    }
+    if (colors) {
+        memcpy(builder.colors(), colors, vertexCount * sizeof(SkColor));
+    }
+    if (indices) {
+        memcpy(builder.indices(), indices, indexCount * sizeof(uint16_t));
+    }
     return builder.detach();
 }
 
-size_t SkVertices::approximateSize() const {
-    Sizes sizes(fVertexCnt, fIndexCnt, this->hasTexCoords(), this->hasColors());
-    SkASSERT(sizes.isValid());
-    return sizeof(SkVertices) + sizes.fArrays;
-}
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-// storage = packed | vertex_count | index_count | pos[] | texs[] | colors[] | indices[]
-//         = header + arrays
+// storage = flags | vertex_count | index_count | pos[] | texs[] | colors[] | indices[]
 
 #define kMode_Mask          0x0FF
 #define kHasTexs_Mask       0x100
 #define kHasColors_Mask     0x200
-#define kHeaderSize         (3 * sizeof(uint32_t))
 
 sk_sp<SkData> SkVertices::encode() const {
-    // packed has room for addtional flags in the future (e.g. versioning)
-    uint32_t packed = static_cast<uint32_t>(fMode);
-    SkASSERT((packed & ~kMode_Mask) == 0);  // our mode fits in the mask bits
-    if (this->hasTexCoords()) {
-        packed |= kHasTexs_Mask;
+    uint32_t flags = static_cast<uint32_t>(fMode);
+    SkASSERT((flags & ~kMode_Mask) == 0);
+    if (fTexs) {
+        flags |= kHasTexs_Mask;
     }
-    if (this->hasColors()) {
-        packed |= kHasColors_Mask;
+    if (fColors) {
+        flags |= kHasColors_Mask;
     }
 
-    Sizes sizes(fVertexCnt, fIndexCnt, this->hasTexCoords(), this->hasColors());
-    SkASSERT(sizes.isValid());
-    const size_t size = kHeaderSize + sizes.fArrays;
+    size_t size = sizeof(uint32_t) * 3; // flags | verts_count | indices_count
+    size += fVertexCnt * sizeof(SkPoint);
+    if (fTexs) {
+        size += fVertexCnt * sizeof(SkPoint);
+    }
+    if (fColors) {
+        size += fVertexCnt * sizeof(SkColor);
+    }
+    size += fIndexCnt * sizeof(uint16_t);
 
     sk_sp<SkData> data = SkData::MakeUninitialized(size);
     SkWriter32 writer(data->writable_data(), data->size());
 
-    writer.write32(packed);
+    writer.write32(flags);
     writer.write32(fVertexCnt);
     writer.write32(fIndexCnt);
-    writer.write(fPositions, sizes.fVSize);
-    writer.write(fTexs, sizes.fTSize);
-    writer.write(fColors, sizes.fCSize);
-    writer.write(fIndices, sizes.fISize);
+    writer.write(fPositions, fVertexCnt * sizeof(SkPoint));
+    if (fTexs) {
+        writer.write(fTexs, fVertexCnt * sizeof(SkPoint));
+    }
+    if (fColors) {
+        writer.write(fColors, fVertexCnt * sizeof(SkColor));
+    }
+    writer.write(fIndices, fIndexCnt * sizeof(uint16_t));
 
     return data;
 }
 
 sk_sp<SkVertices> SkVertices::Decode(const void* data, size_t length) {
-    if (length < kHeaderSize) {
-        return nullptr;
+    if (length < 3 * sizeof(uint32_t)) {
+        return nullptr; // buffer too small
     }
 
     SkReader32 reader(data, length);
 
-    const uint32_t packed = reader.readInt();
-    const int vertexCount = reader.readInt();
-    const int indexCount = reader.readInt();
-
-    const SkCanvas::VertexMode mode = static_cast<SkCanvas::VertexMode>(packed & kMode_Mask);
-    const bool hasTexs = SkToBool(packed & kHasTexs_Mask);
-    const bool hasColors = SkToBool(packed & kHasColors_Mask);
-    Sizes sizes(vertexCount, indexCount, hasTexs, hasColors);
-    if (!sizes.isValid()) {
-        return nullptr;
+    uint32_t storageFlags = reader.readInt();
+    SkCanvas::VertexMode mode = static_cast<SkCanvas::VertexMode>(storageFlags & kMode_Mask);
+    int vertexCount = reader.readInt();
+    int indexCount = reader.readInt();
+    uint32_t builderFlags = 0;
+    if (storageFlags & kHasTexs_Mask) {
+        builderFlags |= SkVertices::kHasTexs_Flag;
     }
-    if (kHeaderSize + sizes.fArrays != length) {
+    if (storageFlags & kHasColors_Mask) {
+        builderFlags |= SkVertices::kHasColors_Flag;
+    }
+
+    size_t size = compute_arrays_size(vertexCount, indexCount, builderFlags);
+    if (0 == size) {
         return nullptr;
     }
 
-    Builder builder(mode, vertexCount, indexCount, sizes);
+    length -= 3 * sizeof(uint32_t); // already read the header
+    if (length < size) {    // buffer too small
+        return nullptr;
+    }
 
-    reader.read(builder.positions(), sizes.fVSize);
-    reader.read(builder.texCoords(), sizes.fTSize);
-    reader.read(builder.colors(), sizes.fCSize);
-    reader.read(builder.indices(), sizes.fISize);
+    Builder builder(mode, vertexCount, indexCount, builderFlags);
+    if (!builder.isValid()) {
+        return nullptr;
+    }
+
+    reader.read(builder.positions(), vertexCount * sizeof(SkPoint));
+    if (builderFlags & SkVertices::kHasTexs_Flag) {
+        reader.read(builder.texCoords(), vertexCount * sizeof(SkPoint));
+    }
+    if (builderFlags & SkVertices::kHasColors_Flag) {
+        reader.read(builder.colors(), vertexCount * sizeof(SkColor));
+    }
+    reader.read(builder.indices(), indexCount * sizeof(uint16_t));
     
     return builder.detach();
 }
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index c0d63a3..bcb93b3 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -711,6 +711,11 @@
                                                            surfaceProps);
 }
 
+void GrContextPriv::addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject> preFlushCBObject) {
+    fContext->fDrawingManager->addPreFlushCallbackObject(std::move(preFlushCBObject));
+}
+
+
 static inline GrPixelConfig GrPixelConfigFallback(GrPixelConfig config) {
     switch (config) {
         case kAlpha_8_GrPixelConfig:
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index c70381f..3357636 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -13,6 +13,7 @@
 
 class GrSemaphore;
 class GrSurfaceProxy;
+class GrPreFlushCallbackObject;
 
 /** Class that adds methods to GrContext that are only intended for use internal to Skia.
     This class is purely a privileged window into GrContext. It should never have additional
@@ -58,9 +59,15 @@
 
     bool disableGpuYUVConversion() const { return fContext->fDisableGpuYUVConversion; }
 
+    /*
+     * A ref will be taken on the preFlushCallbackObject which will be removed when the
+     * context is destroyed.
+     */
+    void addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject>);
+
 private:
     explicit GrContextPriv(GrContext* context) : fContext(context) {}
-    GrContextPriv(const GrContextPriv&) {} // unimpl
+    GrContextPriv(const GrContextPriv&); // unimpl
     GrContextPriv& operator=(const GrContextPriv&); // unimpl
 
     // No taking addresses of this type.
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index d670e16..449cae6 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -75,10 +75,53 @@
     }
     fFlushing = true;
     bool flushed = false;
+
+    for (int i = 0; i < fOpLists.count(); ++i) {
+        // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh
+        // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed
+        // but need to be flushed anyway. Closing such GrOpLists here will mean new
+        // GrOpLists will be created to replace them if the SkGpuDevice(s) write to them again.
+        fOpLists[i]->makeClosed();
+    }
+
     SkDEBUGCODE(bool result =)
                         SkTTopoSort<GrOpList, GrOpList::TopoSortTraits>(&fOpLists);
     SkASSERT(result);
 
+    GrPreFlushResourceProvider preFlushProvider(this);
+
+    if (fPreFlushCBObjects.count()) {
+        // MDB TODO: pre-MDB '1' is the correct pre-allocated size. Post-MDB it will need
+        // to be larger.
+        SkAutoSTArray<1, uint32_t> opListIds(fOpLists.count());
+        for (int i = 0; i < fOpLists.count(); ++i) {
+            opListIds[i] = fOpLists[i]->uniqueID();
+        }
+
+        SkSTArray<1, sk_sp<GrRenderTargetContext>> renderTargetContexts;
+        for (int i = 0; i < fPreFlushCBObjects.count(); ++i) {
+            fPreFlushCBObjects[i]->preFlush(&preFlushProvider,
+                                            opListIds.get(), opListIds.count(),
+                                            &renderTargetContexts);
+            if (!renderTargetContexts.count()) {
+                continue;       // This is fine. No atlases of this type are required for this flush
+            }
+
+            for (int j = 0; j < renderTargetContexts.count(); ++j) {
+                GrRenderTargetOpList* opList = renderTargetContexts[j]->getOpList();
+                if (!opList) {
+                    continue;   // Odd - but not a big deal
+                }
+                SkDEBUGCODE(opList->validateTargetsSingleRenderTarget());
+                opList->prepareOps(&fFlushState);
+                if (!opList->executeOps(&fFlushState)) {
+                    continue;         // This is bad
+                }
+            }
+            renderTargetContexts.reset();
+        }
+    }
+
     for (int i = 0; i < fOpLists.count(); ++i) {
         fOpLists[i]->prepareOps(&fFlushState);
     }
@@ -145,6 +188,10 @@
     }
 }
 
+void GrDrawingManager::addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject> preFlushCBObject) {
+    fPreFlushCBObjects.push_back(preFlushCBObject);
+}
+
 GrRenderTargetOpList* GrDrawingManager::newOpList(GrRenderTargetProxy* rtp) {
     SkASSERT(fContext);
 
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 061e878..d914b03 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -11,9 +11,10 @@
 #include "GrOpFlushState.h"
 #include "GrPathRenderer.h"
 #include "GrPathRendererChain.h"
+#include "GrPreFlushResourceProvider.h"
 #include "GrRenderTargetOpList.h"
 #include "GrResourceCache.h"
-#include "SkTDArray.h"
+#include "SkTArray.h"
 #include "text/GrAtlasTextContext.h"
 
 class GrContext;
@@ -67,6 +68,8 @@
 
     void prepareSurfaceForExternalIO(GrSurface*);
 
+    void addPreFlushCallbackObject(sk_sp<GrPreFlushCallbackObject> preFlushCBObject);
+
 private:
     GrDrawingManager(GrContext* context,
                      const GrRenderTargetOpList::Options& optionsForOpLists,
@@ -92,6 +95,7 @@
     void internalFlush(GrResourceCache::FlushType);
 
     friend class GrContext;  // for access to: ctor, abandon, reset & flush
+    friend class GrPreFlushResourceProvider; // this is just a shallow wrapper around this class
 
     static const int kNumPixelGeometries = 5; // The different pixel geometries
     static const int kNumDFTOptions = 2;      // DFT or no DFT
@@ -115,6 +119,8 @@
     bool                              fFlushing;
 
     bool                              fIsImmediateMode;
+
+    SkTArray<sk_sp<GrPreFlushCallbackObject>> fPreFlushCBObjects;
 };
 
 #endif
diff --git a/src/gpu/GrPreFlushResourceProvider.cpp b/src/gpu/GrPreFlushResourceProvider.cpp
new file mode 100644
index 0000000..e907f39
--- /dev/null
+++ b/src/gpu/GrPreFlushResourceProvider.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrPreFlushResourceProvider.h"
+
+#include "GrDrawingManager.h"
+#include "GrSurfaceProxy.h"
+
+sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext(
+                                                        const GrSurfaceDesc& desc,
+                                                        sk_sp<SkColorSpace> colorSpace,
+                                                        const SkSurfaceProps* props) {
+    GrSurfaceDesc tmpDesc = desc;
+    tmpDesc.fFlags |= kRenderTarget_GrSurfaceFlag;
+
+    // Because this is being allocated at the start of a flush we must ensure the proxy
+    // will, when instantiated, have no pending IO.
+    // TODO: fold the kNoPendingIO_Flag into GrSurfaceFlags?
+    sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(
+                                                    fDrawingMgr->getContext()->resourceProvider(),
+                                                    tmpDesc,
+                                                    SkBackingFit::kExact,
+                                                    SkBudgeted::kYes,
+                                                    GrResourceProvider::kNoPendingIO_Flag);
+    if (!proxy->asRenderTargetProxy()) {
+        return nullptr;
+    }
+
+    sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(
+                                                    proxy->asRenderTargetProxy(),
+                                                    fDrawingMgr->fContext->getGpu(),
+                                                    fDrawingMgr->fContext->resourceProvider(),
+                                                    fDrawingMgr->fContext->getAuditTrail(),
+                                                    fDrawingMgr->fOptionsForOpLists));
+    proxy->setLastOpList(opList.get());
+
+    return fDrawingMgr->makeRenderTargetContext(std::move(proxy),
+                                                std::move(colorSpace),
+                                                props);
+}
+
+// TODO: we only need this entry point as long as we have to pre-allocate the atlas.
+// Remove it ASAP.
+sk_sp<GrRenderTargetContext> GrPreFlushResourceProvider::makeRenderTargetContext(
+                                                        sk_sp<GrSurfaceProxy> proxy,
+                                                        sk_sp<SkColorSpace> colorSpace,
+                                                        const SkSurfaceProps* props) {
+
+    sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(
+                                                    proxy->asRenderTargetProxy(),
+                                                    fDrawingMgr->fContext->getGpu(),
+                                                    fDrawingMgr->fContext->resourceProvider(),
+                                                    fDrawingMgr->fContext->getAuditTrail(),
+                                                    fDrawingMgr->fOptionsForOpLists));
+    proxy->setLastOpList(opList.get());
+
+    return fDrawingMgr->makeRenderTargetContext(std::move(proxy),
+                                                std::move(colorSpace),
+                                                props);
+}
+
diff --git a/src/gpu/GrPreFlushResourceProvider.h b/src/gpu/GrPreFlushResourceProvider.h
new file mode 100644
index 0000000..86a299a
--- /dev/null
+++ b/src/gpu/GrPreFlushResourceProvider.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrPreFlushResourceProvider_DEFINED
+#define GrPreFlushResourceProvider_DEFINED
+
+#include "GrTypes.h"
+#include "GrNonAtomicRef.h"
+
+// These two are just for GrPreFlushCallbackObject
+#include "SkRefCnt.h"
+#include "SkTDArray.h"
+
+class GrDrawingManager;
+class GrOpList;
+class GrPreFlushResourceProvider;
+class GrRenderTargetOpList;
+class GrRenderTargetContext;
+class GrSurfaceProxy;
+
+class SkColorSpace;
+class SkSurfaceProps;
+
+/*
+ * This is the base class from which all per-flush callback objects must be derived. It
+ * provides the "preFlush" interface.
+ */
+class GrPreFlushCallbackObject : public GrNonAtomicRef<GrPreFlushCallbackObject> {
+public:
+    virtual ~GrPreFlushCallbackObject() { }
+
+    /*
+     * The preFlush callback allows subsystems (e.g., text, path renderers) to create atlases
+     * for a specific flush. All the GrOpList IDs required for the flush are passed into the
+     * callback. The callback should return the render target contexts used to render the atlases
+     * in 'results'.
+     */
+    virtual void preFlush(GrPreFlushResourceProvider*,
+                          const uint32_t* opListIDs, int numOpListIDs,
+                          SkTArray<sk_sp<GrRenderTargetContext>>* results) = 0;
+
+private:
+    typedef SkRefCnt INHERITED;
+};
+
+/*
+ * This class is a shallow wrapper around the drawing manager. It is passed into the
+ * preFlush callbacks and is intended to limit the functionality available to them.
+ * It should never have additional data members or virtual methods.
+ */
+class GrPreFlushResourceProvider {
+public:
+    sk_sp<GrRenderTargetContext> makeRenderTargetContext(const GrSurfaceDesc& desc,
+                                                         sk_sp<SkColorSpace> colorSpace,
+                                                         const SkSurfaceProps* props);
+
+    // TODO: we only need this entry point as long as we have to pre-allocate the atlas.
+    // Remove it ASAP.
+    sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy> proxy,
+                                                         sk_sp<SkColorSpace> colorSpace,
+                                                         const SkSurfaceProps* props);
+
+private:
+    explicit GrPreFlushResourceProvider(GrDrawingManager* drawingMgr) : fDrawingMgr(drawingMgr) {}
+    GrPreFlushResourceProvider(const GrPreFlushResourceProvider&); // unimpl
+    GrPreFlushResourceProvider& operator=(const GrPreFlushResourceProvider&); // unimpl
+
+    GrDrawingManager* fDrawingMgr;
+
+    friend class GrDrawingManager; // to construct this type.
+};
+
+#endif
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 1c98353..8d47fff 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -70,14 +70,25 @@
         }
     }
 }
+
+void GrRenderTargetOpList::validateTargetsSingleRenderTarget() const {
+    GrRenderTarget* rt = nullptr;
+    for (int i = 0; i < fRecordedOps.count(); ++i) {
+        if (!fRecordedOps[i].fOp) {
+            continue;       // combined forward
+        }
+
+        if (!rt) {
+            rt = fRecordedOps[i].fRenderTarget.get();
+        } else {
+            SkASSERT(fRecordedOps[i].fRenderTarget.get() == rt);
+        }
+    }
+}
 #endif
 
 void GrRenderTargetOpList::prepareOps(GrOpFlushState* flushState) {
-    // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh
-    // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed
-    // but need to be flushed anyway. Closing such GrOpLists here will mean new
-    // GrOpLists will be created to replace them if the SkGpuDevice(s) write to them again.
-    this->makeClosed();
+    // MDB TODO: add SkASSERT(this->isClosed());
 
     // Loop over the ops that haven't yet been prepared.
     for (int i = 0; i < fRecordedOps.count(); ++i) {
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index f4458b5..ab744f3 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -102,6 +102,8 @@
 
     SkDEBUGCODE(void dump() const override;)
 
+    SkDEBUGCODE(void validateTargetsSingleRenderTarget() const;)
+
 private:
     friend class GrRenderTargetContextPriv; // for clearStencilClip and stencil clip state.
 
diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp
index d70daa2..d396b2a 100644
--- a/src/gpu/GrTextureOpList.cpp
+++ b/src/gpu/GrTextureOpList.cpp
@@ -45,11 +45,7 @@
 #endif
 
 void GrTextureOpList::prepareOps(GrOpFlushState* flushState) {
-    // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh
-    // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed
-    // but need to be flushed anyway. Closing such GrOpLists here will mean new
-    // GrOpLists will be created to replace them if the SkGpuDevice(s) write to them again.
-    this->makeClosed();
+    // MDB TODO: add SkASSERT(this->isClosed());
 
     // Loop over the ops that haven't yet generated their geometry
     for (int i = 0; i < fRecordedOps.count(); ++i) {
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index aa13cae..5d88378 100644
--- a/src/gpu/ops/GrDrawVerticesOp.cpp
+++ b/src/gpu/ops/GrDrawVerticesOp.cpp
@@ -257,7 +257,7 @@
         return false;
     }
 
-    if (fMeshes[0].fVertices->hasIndices() != that->fMeshes[0].fVertices->hasIndices()) {
+    if (fMeshes[0].fVertices->isIndexed() != that->fMeshes[0].fVertices->isIndexed()) {
         return false;
     }
 
diff --git a/src/gpu/ops/GrDrawVerticesOp.h b/src/gpu/ops/GrDrawVerticesOp.h
index eddf201..c837734 100644
--- a/src/gpu/ops/GrDrawVerticesOp.h
+++ b/src/gpu/ops/GrDrawVerticesOp.h
@@ -97,7 +97,7 @@
 
     bool isIndexed() const {
         // Consistency enforced in onCombineIfPossible.
-        return fMeshes[0].fVertices->hasIndices();
+        return fMeshes[0].fVertices->isIndexed();
     }
 
     bool requiresPerVertexColors() const {
diff --git a/src/gpu/ops/GrTestMeshDrawOp.h b/src/gpu/ops/GrTestMeshDrawOp.h
index d78d3e9..039f88d 100644
--- a/src/gpu/ops/GrTestMeshDrawOp.h
+++ b/src/gpu/ops/GrTestMeshDrawOp.h
@@ -19,7 +19,7 @@
  */
 class GrTestMeshDrawOp : public GrMeshDrawOp {
 public:
-    virtual const char* name() const override = 0;
+    const char* name() const override = 0;
 
 protected:
     GrTestMeshDrawOp(uint32_t classID, const SkRect& bounds, GrColor color)
diff --git a/src/utils/SkShadowUtils.cpp b/src/utils/SkShadowUtils.cpp
index 402dca5..eb015aa 100644
--- a/src/utils/SkShadowUtils.cpp
+++ b/src/utils/SkShadowUtils.cpp
@@ -232,12 +232,12 @@
                 i = fCount++;
             } else {
                 i = gRandom.nextULessThan(MAX_ENTRIES);
-                fSize -= fEntries[i].fVertices->approximateSize();
+                fSize -= fEntries[i].fVertices->size();
             }
             fEntries[i].fFactory = factory;
             fEntries[i].fVertices = vertices;
             fEntries[i].fMatrix = matrix;
-            fSize += vertices->approximateSize();
+            fSize += vertices->size();
             return vertices;
         }
 
diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm
index 7f4aacd..64c02ca 100644
--- a/src/views/mac/SkNSView.mm
+++ b/src/views/mac/SkNSView.mm
@@ -15,8 +15,12 @@
 
 //#define FORCE_REDRAW
 // Can be dropped when we no longer support 10.6.
-#define RETINA_API_AVAILABLE (defined(MAC_OS_X_VERSION_10_7) && \
-                              MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
+#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+    #define RETINA_API_AVAILABLE 1
+#else
+    #define RETINA_API_AVAILABLE 0
+#endif
+
 @implementation SkNSView
 @synthesize fWind, fTitle, fOptionsDelegate, fGLContext;
 
diff --git a/tests/PreFlushCallbackTest.cpp b/tests/PreFlushCallbackTest.cpp
new file mode 100644
index 0000000..78f5002
--- /dev/null
+++ b/tests/PreFlushCallbackTest.cpp
@@ -0,0 +1,606 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Test.h"
+
+#if SK_SUPPORT_GPU
+
+#include "GrClip.h"
+#include "GrContextPriv.h"
+#include "GrDefaultGeoProcFactory.h"
+#include "GrPreFlushResourceProvider.h"
+#include "GrRenderTargetContextPriv.h"
+#include "GrResourceProvider.h"
+#include "GrQuad.h"
+#include "effects/GrSimpleTextureEffect.h"
+#include "ops/GrTestMeshDrawOp.h"
+
+// This is a simplified mesh drawing op that can be used in the atlas generation test.
+// Please see AtlasedRectOp below.
+class NonAARectOp : public GrMeshDrawOp {
+public:
+    DEFINE_OP_CLASS_ID
+    const char* name() const override { return "NonAARectOp"; }
+
+    // This creates an instance of a simple non-AA solid color rect-drawing Op
+    static std::unique_ptr<GrDrawOp> Make(const SkRect& r, GrColor color) {
+        return std::unique_ptr<GrDrawOp>(new NonAARectOp(ClassID(), r, color));
+    }
+
+    // This creates an instance of a simple non-AA textured rect-drawing Op
+    static std::unique_ptr<GrDrawOp> Make(const SkRect& r, GrColor color, const SkRect& local) {
+        return std::unique_ptr<GrDrawOp>(new NonAARectOp(ClassID(), r, color, local));
+    }
+
+    GrColor color() const { return fColor; }
+
+protected:
+    NonAARectOp(uint32_t classID, const SkRect& r, GrColor color)
+        : INHERITED(classID)
+        , fColor(color)
+        , fHasLocalRect(false)
+        , fRect(r) {
+        // Choose some conservative values for aa bloat and zero area.
+        this->setBounds(r, HasAABloat::kYes, IsZeroArea::kYes);
+    }
+
+    NonAARectOp(uint32_t classID, const SkRect& r, GrColor color, const SkRect& local)
+        : INHERITED(classID)
+        , fColor(color)
+        , fHasLocalRect(true)
+        , fLocalQuad(local)
+        , fRect(r) {
+        // Choose some conservative values for aa bloat and zero area.
+        this->setBounds(r, HasAABloat::kYes, IsZeroArea::kYes);
+    }
+
+    GrColor fColor;
+    bool    fHasLocalRect;
+    GrQuad  fLocalQuad;
+    SkRect  fRect;
+
+private:
+    void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override {
+        input->colorInput()->setToUnknown();
+        input->coverageInput()->setToUnknown();
+    }
+
+    void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
+        optimizations.getOverrideColorIfSet(&fColor);
+    }
+
+    bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }
+
+    void onPrepareDraws(Target* target) const override {
+        using namespace GrDefaultGeoProcFactory;
+
+        // The vertex attrib order is always pos, color, local coords.
+        static const int kColorOffset = sizeof(SkPoint);
+        static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
+
+        sk_sp<GrGeometryProcessor> gp =
+                GrDefaultGeoProcFactory::Make(Color::kPremulGrColorAttribute_Type,
+                                              Coverage::kSolid_Type,
+                                              fHasLocalRect ? LocalCoords::kHasExplicit_Type
+                                                            : LocalCoords::kUnused_Type,
+                                              SkMatrix::I());
+        if (!gp) {
+            SkDebugf("Couldn't create GrGeometryProcessor for GrAtlasedOp\n");
+            return;
+        }
+
+        size_t vertexStride = gp->getVertexStride();
+
+        SkASSERT(fHasLocalRect
+                    ? vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr)
+                    : vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
+
+        const GrBuffer* indexBuffer;
+        int firstIndex;
+        uint16_t* indices = target->makeIndexSpace(6, &indexBuffer, &firstIndex);
+        if (!indices) {
+            SkDebugf("Indices could not be allocated for GrAtlasedOp.\n");
+            return;
+        }
+
+        const GrBuffer* vertexBuffer;
+        int firstVertex;
+        void* vertices = target->makeVertexSpace(vertexStride, 4, &vertexBuffer, &firstVertex);
+        if (!vertices) {
+            SkDebugf("Vertices could not be allocated for GrAtlasedOp.\n");
+            return;
+        }
+
+        // Setup indices
+        indices[0] = 0;
+        indices[1] = 1;
+        indices[2] = 2;
+        indices[3] = 0;
+        indices[4] = 2;
+        indices[5] = 3;
+
+        // Setup positions
+        SkPoint* position = (SkPoint*) vertices;
+        position->setRectFan(fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom, vertexStride);
+
+        // Setup vertex colors
+        GrColor* color = (GrColor*)((intptr_t)vertices + kColorOffset);
+        for (int i = 0; i < 4; ++i) {
+            *color = fColor;
+            color = (GrColor*)((intptr_t)color + vertexStride);
+        }
+
+        // Setup local coords
+        if (fHasLocalRect) {
+            SkPoint* coords = (SkPoint*)((intptr_t) vertices + kLocalOffset);
+            for (int i = 0; i < 4; i++) {
+                *coords = fLocalQuad.point(i);
+                coords = (SkPoint*)((intptr_t) coords + vertexStride);
+            }
+        }
+
+        GrMesh mesh;
+        mesh.initIndexed(kTriangles_GrPrimitiveType,
+                         vertexBuffer, indexBuffer,
+                         firstVertex, firstIndex,
+                         4, 6);
+
+        target->draw(gp.get(), mesh);
+    }
+
+    typedef GrMeshDrawOp INHERITED;
+};
+
+#ifdef SK_DEBUG
+#include "SkImageEncoder.h"
+#include "sk_tool_utils.h"
+
+static void save_bm(const SkBitmap& bm, const char name[]) {
+    bool result = sk_tool_utils::EncodeImageToFile(name, bm, SkEncodedImageFormat::kPNG, 100);
+    SkASSERT(result);
+}
+#endif
+
+/*
+ * Atlased ops just draw themselves as textured rects with the texture pixels being
+ * pulled out of the atlas. Their color is based on their ID.
+ */
+class AtlasedRectOp final : public NonAARectOp {
+public:
+    DEFINE_OP_CLASS_ID
+
+    ~AtlasedRectOp() override {
+        fID = -1;
+    }
+
+    const char* name() const override { return "AtlasedRectOp"; }
+
+    int id() const { return fID; }
+
+    static std::unique_ptr<AtlasedRectOp> Make(const SkRect& r, int id) {
+        return std::unique_ptr<AtlasedRectOp>(new AtlasedRectOp(r, id));
+    }
+
+    void setColor(GrColor color) { fColor = color; }
+    void setLocalRect(const SkRect& localRect) {
+        SkASSERT(fHasLocalRect);    // This should've been created to anticipate this
+        fLocalQuad.set(localRect);
+    }
+
+    AtlasedRectOp* next() const { return fNext; }
+    void setNext(AtlasedRectOp* next) {
+        fNext = next;
+    }
+
+private:
+    // We set the initial color of the NonAARectOp based on the ID.
+    // Note that we force creation of a NonAARectOp that has local coords in anticipation of
+    // pulling from the atlas.
+    AtlasedRectOp(const SkRect& r, int id)
+        : INHERITED(ClassID(), r, kColors[id], SkRect::MakeEmpty())
+        , fID(id)
+        , fNext(nullptr) {
+        SkASSERT(fID < kMaxIDs);
+    }
+
+    static const int kMaxIDs = 9;
+    static const SkColor kColors[kMaxIDs];
+
+    int            fID;
+    // The Atlased ops have an internal singly-linked list of ops that land in the same opList
+    AtlasedRectOp* fNext;
+
+    typedef NonAARectOp INHERITED;
+};
+
+const GrColor AtlasedRectOp::kColors[kMaxIDs] = {
+    GrColorPackRGBA(255, 0, 0, 255),
+    GrColorPackRGBA(0, 255, 0, 255),
+    GrColorPackRGBA(0, 0, 255, 255),
+    GrColorPackRGBA(0, 255, 255, 255),
+    GrColorPackRGBA(255, 0, 255, 255),
+    GrColorPackRGBA(255, 255, 0, 255),
+    GrColorPackRGBA(0, 0, 0, 255),
+    GrColorPackRGBA(128, 128, 128, 255),
+    GrColorPackRGBA(255, 255, 255, 255)
+};
+
+static const int kDrawnTileSize = 16;
+
+/*
+ * Rather than performing any rect packing, this atlaser just lays out constant-sized
+ * tiles in an Nx1 row
+ */
+static const int kAtlasTileSize = 2;
+
+/*
+ * This class aggregates the op information required for atlasing
+ */
+class AtlasObject final : public GrPreFlushCallbackObject {
+public:
+    AtlasObject() : fDone(false) { }
+
+    ~AtlasObject() override {
+        SkASSERT(fDone);
+    }
+
+    void markAsDone() {
+        fDone = true;
+    }
+
+    // Insert the new op in an internal singly-linked list for 'opListID'
+    void addOp(uint32_t opListID, AtlasedRectOp* op) {
+        LinkedListHeader* header = nullptr;
+        for (int i = 0; i < fOps.count(); ++i) {
+            if (opListID == fOps[i].fID) {
+                header = &(fOps[i]);
+            }
+        }
+
+        if (!header) {
+            fOps.push({opListID, nullptr});
+            header = &(fOps[fOps.count()-1]);
+        }
+
+        op->setNext(header->fHead);
+        header->fHead = op;
+    }
+
+    // For the time being we need to pre-allocate the atlas.
+    void setAtlasDest(sk_sp<GrTextureProxy> atlasDest) {
+        fAtlasDest = atlasDest;
+    }
+
+    void saveRTC(sk_sp<GrRenderTargetContext> rtc) {
+        SkASSERT(!fRTC);
+        fRTC = rtc;
+    }
+
+#ifdef SK_DEBUG
+    void saveAtlasToDisk() {
+        SkBitmap readBack;
+        readBack.allocN32Pixels(fRTC->width(), fRTC->height());
+
+        bool result = fRTC->readPixels(readBack.info(),
+                                       readBack.getPixels(), readBack.rowBytes(), 0, 0);
+        SkASSERT(result);
+        save_bm(readBack, "atlas-real.png");
+    }
+#endif
+
+    /*
+     * This callback back creates the atlas and updates the AtlasedRectOps to read from it
+     */
+    void preFlush(GrPreFlushResourceProvider* resourceProvider,
+                  const uint32_t* opListIDs, int numOpListIDs,
+                  SkTArray<sk_sp<GrRenderTargetContext>>* results) override {
+        SkASSERT(!results->count());
+
+        // Until MDB is landed we will most-likely only have one opList.
+        SkTDArray<LinkedListHeader*> lists;
+        for (int i = 0; i < numOpListIDs; ++i) {
+            if (LinkedListHeader* list = this->getList(opListIDs[i])) {
+                lists.push(list);
+            }
+        }
+
+        if (!lists.count()) {
+            return; // nothing to atlas
+        }
+
+        // TODO: right now we have to pre-allocate the atlas bc the TextureSamplers need a
+        // hard GrTexture
+#if 0
+        GrSurfaceDesc desc;
+        desc.fFlags = kRenderTarget_GrSurfaceFlag;
+        desc.fWidth = this->numOps() * kAtlasTileSize;
+        desc.fHeight = kAtlasTileSize;
+        desc.fConfig = kRGBA_8888_GrPixelConfig;
+
+        sk_sp<GrRenderTargetContext> rtc = resourceProvider->makeRenderTargetContext(desc,
+                                                                                     nullptr,
+                                                                                     nullptr);
+#else
+        // At this point all the GrAtlasedOp's should have lined up to read from 'atlasDest' and
+        // there should either be two writes to clear it or no writes.
+        SkASSERT(9 == fAtlasDest->getPendingReadCnt_TestOnly());
+        SkASSERT(2 == fAtlasDest->getPendingWriteCnt_TestOnly() ||
+                 0 == fAtlasDest->getPendingWriteCnt_TestOnly());
+        sk_sp<GrRenderTargetContext> rtc = resourceProvider->makeRenderTargetContext(
+                                                                           fAtlasDest,
+                                                                           nullptr, nullptr);
+#endif
+
+        rtc->clear(nullptr, 0xFFFFFFFF, true); // clear the atlas
+
+        int blocksInAtlas = 0;
+        for (int i = 0; i < lists.count(); ++i) {
+            for (AtlasedRectOp* op = lists[i]->fHead; op; op = op->next()) {
+                SkIRect r = SkIRect::MakeXYWH(blocksInAtlas*kAtlasTileSize, 0,
+                                              kAtlasTileSize, kAtlasTileSize);
+
+                // For now, we avoid the resource buffer issues and just use clears
+#if 1
+                rtc->clear(&r, op->color(), false);
+#else
+                std::unique_ptr<GrDrawOp> drawOp(GrNonAARectOp::Make(SkRect::Make(r),
+                                                 atlasedOp->color()));
+
+                GrPaint paint;
+                rtc->priv().testingOnly_addDrawOp(std::move(paint),
+                                                  GrAAType::kNone,
+                                                  std::move(drawOp));
+#endif
+                blocksInAtlas++;
+
+                // Set the atlased Op's color to white (so we know we're not using it for
+                // the final draw).
+                op->setColor(0xFFFFFFFF);
+
+                // Set the atlased Op's localRect to point to where it landed in the atlas
+                op->setLocalRect(SkRect::Make(r));
+
+                // TODO: we also need to set the op's GrSuperDeferredSimpleTextureEffect to point
+                // to the rtc's proxy!
+            }
+
+            // We've updated all these ops and we certainly don't want to process them again
+            this->clearOpsFor(lists[i]);
+        }
+
+        // Hide a ref to the RTC in AtlasData so we can check on it later
+        this->saveRTC(rtc);
+
+        results->push_back(std::move(rtc));
+    }
+
+private:
+    typedef struct {
+        uint32_t       fID;
+        AtlasedRectOp* fHead;
+    } LinkedListHeader;
+
+    LinkedListHeader* getList(uint32_t opListID) {
+        for (int i = 0; i < fOps.count(); ++i) {
+            if (opListID == fOps[i].fID) {
+                return &(fOps[i]);
+            }
+        }
+        return nullptr;
+    }
+
+    void clearOpsFor(LinkedListHeader* header) {
+        // The AtlasedRectOps have yet to execute (and this class doesn't own them) so just
+        // forget about them in the laziest way possible.
+        header->fHead = nullptr;
+        header->fID = 0;            // invalid opList ID
+    }
+
+    // Each opList containing AtlasedRectOps gets its own internal singly-linked list
+    SkTDArray<LinkedListHeader>  fOps;
+
+    // The RTC used to create the atlas
+    sk_sp<GrRenderTargetContext> fRTC;
+
+    // For the time being we need to pre-allocate the atlas bc the TextureSamplers require
+    // a GrTexture
+    sk_sp<GrTextureProxy>        fAtlasDest;
+
+    // Set to true when the testing harness expects this object to be no longer used
+    bool                         fDone;
+};
+
+// This creates an off-screen rendertarget whose ops which eventually pull from the atlas.
+static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start,
+                                                 sk_sp<GrTextureProxy> fakeAtlas) {
+
+    sk_sp<GrRenderTargetContext> rtc(context->makeRenderTargetContext(SkBackingFit::kApprox,
+                                                                      3*kDrawnTileSize,
+                                                                      kDrawnTileSize,
+                                                                      kRGBA_8888_GrPixelConfig,
+                                                                      nullptr));
+
+    rtc->clear(nullptr, GrColorPackRGBA(255, 0, 0, 255), true);
+
+    for (int i = 0; i < 3; ++i) {
+        SkRect r = SkRect::MakeXYWH(i*kDrawnTileSize, 0, kDrawnTileSize, kDrawnTileSize);
+
+        std::unique_ptr<AtlasedRectOp> op(AtlasedRectOp::Make(r, start+i));
+
+        // TODO: here is the blocker for deferring creation of the atlas. The TextureSamplers
+        // created here currently require a hard GrTexture.
+        sk_sp<GrFragmentProcessor> fp = GrSimpleTextureEffect::Make(context->resourceProvider(),
+                                                                    fakeAtlas,
+                                                                    nullptr, SkMatrix::I());
+
+        GrPaint paint;
+        paint.addColorFragmentProcessor(std::move(fp));
+        paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
+
+        AtlasedRectOp* sparePtr = op.get();
+
+        uint32_t opListID = rtc->priv().testingOnly_addMeshDrawOp(std::move(paint),
+                                                                  GrAAType::kNone,
+                                                                  std::move(op));
+
+        object->addOp(opListID, sparePtr);
+    }
+
+    return rtc->asTextureProxyRef();
+}
+
+// Enable this if you want to debug the final draws w/o having the atlasCallback create the
+// atlas
+#if 0
+#include "SkGrPriv.h"
+
+sk_sp<GrTextureProxy> pre_create_atlas(GrContext* context) {
+    SkBitmap bm;
+    bm.allocN32Pixels(18, 2, true);
+    bm.erase(SK_ColorRED,     SkIRect::MakeXYWH(0, 0, 2, 2));
+    bm.erase(SK_ColorGREEN,   SkIRect::MakeXYWH(2, 0, 2, 2));
+    bm.erase(SK_ColorBLUE,    SkIRect::MakeXYWH(4, 0, 2, 2));
+    bm.erase(SK_ColorCYAN,    SkIRect::MakeXYWH(6, 0, 2, 2));
+    bm.erase(SK_ColorMAGENTA, SkIRect::MakeXYWH(8, 0, 2, 2));
+    bm.erase(SK_ColorYELLOW,  SkIRect::MakeXYWH(10, 0, 2, 2));
+    bm.erase(SK_ColorBLACK,   SkIRect::MakeXYWH(12, 0, 2, 2));
+    bm.erase(SK_ColorGRAY,    SkIRect::MakeXYWH(14, 0, 2, 2));
+    bm.erase(SK_ColorWHITE,   SkIRect::MakeXYWH(16, 0, 2, 2));
+
+#if 1
+    save_bm(bm, "atlas-fake.png");
+#endif
+
+    GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps());
+    desc.fFlags |= kRenderTarget_GrSurfaceFlag;
+
+    sk_sp<GrSurfaceProxy> tmp = GrSurfaceProxy::MakeDeferred(*context->caps(),
+                                                             context->textureProvider(),
+                                                             desc, SkBudgeted::kYes,
+                                                             bm.getPixels(), bm.rowBytes());
+
+    return sk_ref_sp(tmp->asTextureProxy());
+}
+#else
+// TODO: this is unfortunate and must be removed. We want the atlas to be created later.
+sk_sp<GrTextureProxy> pre_create_atlas(GrContext* context) {
+    GrSurfaceDesc desc;
+    desc.fFlags = kRenderTarget_GrSurfaceFlag;
+    desc.fConfig = kSkia8888_GrPixelConfig;
+    desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
+    desc.fWidth = 32;
+    desc.fHeight = 16;
+    sk_sp<GrSurfaceProxy> atlasDest = GrSurfaceProxy::MakeDeferred(
+                                                            context->resourceProvider(),
+                                                            desc, SkBackingFit::kExact,
+                                                            SkBudgeted::kYes,
+                                                            GrResourceProvider::kNoPendingIO_Flag);
+    return sk_ref_sp(atlasDest->asTextureProxy());
+}
+#endif
+
+static void test_color(skiatest::Reporter* reporter, const SkBitmap& bm, int x, SkColor expected) {
+    SkColor readback = bm.getColor(x, kDrawnTileSize/2);
+    REPORTER_ASSERT(reporter, expected == readback);
+    if (expected != readback) {
+        SkDebugf("Color mismatch: %x %x\n", expected, readback);
+    }
+}
+
+/*
+ * For the atlasing test we make a DAG that looks like:
+ *
+ *    RT1 with ops: 0,1,2       RT2 with ops: 3,4,5       RT3 with ops: 6,7,8
+ *                     \         /
+ *                      \       /
+ *                         RT4
+ * We then flush RT4 and expect only ops 0-5 to be atlased together.
+ * Each op is just a solid colored rect so both the atlas and the final image should appear as:
+ *           R G B C M Y
+ * with the atlas having width = 6*kAtlasTileSize and height = kAtlasTileSize.
+ *
+ * Note: until MDB lands, the atlas will actually have width= 9*kAtlasTileSize and look like:
+ *           R G B C M Y K Grey White
+ */
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PreFlushCallbackTest, reporter, ctxInfo) {
+    static const int kNumProxies = 3;
+
+    GrContext* context = ctxInfo.grContext();
+
+    sk_sp<AtlasObject> object = sk_make_sp<AtlasObject>();
+
+    // For now (until we add a GrSuperDeferredSimpleTextureEffect), we create the final atlas
+    // proxy ahead of time.
+    sk_sp<GrTextureProxy> atlasDest = pre_create_atlas(context);
+
+    object->setAtlasDest(atlasDest);
+
+    context->contextPriv().addPreFlushCallbackObject(object);
+
+    sk_sp<GrTextureProxy> proxies[kNumProxies];
+    for (int i = 0; i < kNumProxies; ++i) {
+        proxies[i] = make_upstream_image(context, object.get(), i*3, atlasDest);
+    }
+
+    static const int kFinalWidth = 6*kDrawnTileSize;
+    static const int kFinalHeight = kDrawnTileSize;
+
+    sk_sp<GrRenderTargetContext> rtc(context->makeRenderTargetContext(SkBackingFit::kApprox,
+                                                                      kFinalWidth,
+                                                                      kFinalHeight,
+                                                                      kRGBA_8888_GrPixelConfig,
+                                                                      nullptr));
+
+    rtc->clear(nullptr, 0xFFFFFFFF, true);
+
+    // Note that this doesn't include the third texture proxy
+    for (int i = 0; i < kNumProxies-1; ++i) {
+        SkRect r = SkRect::MakeXYWH(i*3*kDrawnTileSize, 0, 3*kDrawnTileSize, kDrawnTileSize);
+
+        SkMatrix t = SkMatrix::MakeTrans(-i*3*kDrawnTileSize, 0);
+
+        GrPaint paint;
+        sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(context->resourceProvider(),
+                                                                  std::move(proxies[i]),
+                                                                  nullptr, t));
+        paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
+        paint.addColorFragmentProcessor(std::move(fp));
+
+        rtc->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), r);
+    }
+
+    rtc->prepareForExternalIO();
+
+    SkBitmap readBack;
+    readBack.allocN32Pixels(kFinalWidth, kFinalHeight);
+
+    SkDEBUGCODE(bool result =) rtc->readPixels(readBack.info(), readBack.getPixels(),
+                                               readBack.rowBytes(), 0, 0);
+    SkASSERT(result);
+
+    object->markAsDone();
+
+#if 0
+    save_bm(readBack, "atlas-final-image.png");
+    data.saveAtlasToDisk();
+#endif
+
+    int x = kDrawnTileSize/2;
+    test_color(reporter, readBack, x, SK_ColorRED);
+    x += kDrawnTileSize;
+    test_color(reporter, readBack, x, SK_ColorGREEN);
+    x += kDrawnTileSize;
+    test_color(reporter, readBack, x, SK_ColorBLUE);
+    x += kDrawnTileSize;
+    test_color(reporter, readBack, x, SK_ColorCYAN);
+    x += kDrawnTileSize;
+    test_color(reporter, readBack, x, SK_ColorMAGENTA);
+    x += kDrawnTileSize;
+    test_color(reporter, readBack, x, SK_ColorYELLOW);
+}
+
+#endif
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 5c2efd1..d0f2fae 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -377,7 +377,7 @@
                         if (!legalColorModulation && !legalAlphaModulation) {
                             ERRORF(reporter,
                                    "\"Modulating\" processor %s made color/alpha value larger. "
-                                   "Input: 0x%0x8, Output: 0x%08x.",
+                                   "Input: 0x%08x, Output: 0x%08x.",
                                    fp->name(), input, output);
                             passing = false;
                         }
@@ -408,7 +408,7 @@
                         !GrColorIsOpaque(output)) {
                         ERRORF(reporter,
                                "Processor %s claimed opaqueness is preserved but it is not. Input: "
-                               "0x%0x8, Output: 0x%08x.",
+                               "0x%08x, Output: 0x%08x.",
                                fp->name(), input, output);
                         passing = false;
                     }
diff --git a/tests/Reader32Test.cpp b/tests/Reader32Test.cpp
index c49e57c..301f67c 100644
--- a/tests/Reader32Test.cpp
+++ b/tests/Reader32Test.cpp
@@ -78,4 +78,13 @@
     assert_empty(reporter, reader);
     REPORTER_ASSERT(reporter, nullptr == reader.base());
     REPORTER_ASSERT(reporter, nullptr == reader.peek());
+
+    // need to handle read(null, 0) and not get undefined behavior from memcpy
+    {
+        char storage[100];
+        reader.setMemory(storage, sizeof(storage));
+        char buffer[10];
+        reader.read(buffer, 0);     // easy case, since we pass a ptr
+        reader.read(nullptr, 0);    // undef case, read() can't blindly call memcpy
+    }
 }
diff --git a/tests/VerticesTest.cpp b/tests/VerticesTest.cpp
index 9621d80..8cf5514 100644
--- a/tests/VerticesTest.cpp
+++ b/tests/VerticesTest.cpp
@@ -53,8 +53,8 @@
     int vCount = 4;
     int iCount = 6;
 
-    const uint32_t texFlags[] = { 0, SkVertices::kHasTexCoords_BuilderFlag };
-    const uint32_t colFlags[] = { 0, SkVertices::kHasColors_BuilderFlag };
+    const uint32_t texFlags[] = { 0, SkVertices::kHasTexs_Flag };
+    const uint32_t colFlags[] = { 0, SkVertices::kHasColors_Flag };
     for (auto texF : texFlags) {
         for (auto colF : colFlags) {
             uint32_t flags = texF | colF;