Cleanup resource flags

Converts GrResourceProvider::Flags and GrResourceCache::ScratchFlags
to "enum class" and fixes a case where we were accidentally using the
wrong type of flag. Makes sure to allocate GrSWMaskHelper proxies with
kNoPendingIO.

Bug: skia:8351
Change-Id: Ibcaa26314a53d0cb31ae22915ab94ab0fc07e76d
Reviewed-on: https://skia-review.googlesource.com/157280
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 0fbf9dc..852a040 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -106,7 +106,15 @@
         return nullptr;
     }
 
-    return context->contextPriv().proxyProvider()->createTextureProxy(std::move(img),
-                                                                      kNone_GrSurfaceFlags, 1,
-                                                                      SkBudgeted::kYes, fit);
+    // TODO: http://skbug.com/8422: Although this fixes http://skbug.com/8351, it seems like these
+    // should just participate in the normal allocation process and not need the pending IO flag.
+    auto surfaceFlags = GrInternalSurfaceFlags::kNone;
+    if (!context->contextPriv().resourceProvider()) {
+        // In DDL mode, this texture proxy will be instantiated at flush time, therfore it cannot
+        // have pending IO.
+        surfaceFlags |= GrInternalSurfaceFlags::kNoPendingIO;
+    }
+
+    return context->contextPriv().proxyProvider()->createTextureProxy(
+            std::move(img), kNone_GrSurfaceFlags, 1, SkBudgeted::kYes, fit, surfaceFlags);
 }