Remove another writePixels instance

This converts the GrSWMaskHelper to being DDL compatible

Change-Id: Ic0c7f95a7ed6d2936118b4127c2cfce94a2ec0da
Reviewed-on: https://skia-review.googlesource.com/122788
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkAutoPixmapStorage.cpp b/src/core/SkAutoPixmapStorage.cpp
index 7219423..600f68a 100644
--- a/src/core/SkAutoPixmapStorage.cpp
+++ b/src/core/SkAutoPixmapStorage.cpp
@@ -53,14 +53,14 @@
     SkASSERT_RELEASE(this->tryAlloc(info));
 }
 
-const SkData* SkAutoPixmapStorage::detachPixelsAsData() {
+sk_sp<SkData> SkAutoPixmapStorage::detachPixelsAsData() {
     if (!fStorage) {
         return nullptr;
     }
 
-    auto data = SkData::MakeFromMalloc(fStorage, this->computeByteSize());
+    sk_sp<SkData> data = SkData::MakeFromMalloc(fStorage, this->computeByteSize());
     fStorage = nullptr;
     this->INHERITED::reset();
 
-    return data.release();
+    return data;
 }
diff --git a/src/core/SkAutoPixmapStorage.h b/src/core/SkAutoPixmapStorage.h
index aedbdc6..c0e01da 100644
--- a/src/core/SkAutoPixmapStorage.h
+++ b/src/core/SkAutoPixmapStorage.h
@@ -49,7 +49,7 @@
     *  Returns an SkData object wrapping the allocated pixels memory, and resets the pixmap.
     *  If the storage hasn't been allocated, the result is NULL.
     */
-    const SkData* SK_WARN_UNUSED_RESULT detachPixelsAsData();
+    sk_sp<SkData> SK_WARN_UNUSED_RESULT detachPixelsAsData();
 
     // We wrap these so we can clear our internal storage
 
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index bae0f43..0fbf9dc 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -9,6 +9,7 @@
 
 #include "GrContext.h"
 #include "GrContextPriv.h"
+#include "GrProxyProvider.h"
 #include "GrShape.h"
 #include "GrSurfaceContext.h"
 #include "GrTextureProxy.h"
@@ -92,21 +93,20 @@
 }
 
 sk_sp<GrTextureProxy> GrSWMaskHelper::toTextureProxy(GrContext* context, SkBackingFit fit) {
-    GrSurfaceDesc desc;
-    desc.fWidth = fPixels->width();
-    desc.fHeight = fPixels->height();
-    desc.fConfig = kAlpha_8_GrPixelConfig;
+    SkImageInfo ii = SkImageInfo::MakeA8(fPixels->width(), fPixels->height());
+    size_t rowBytes = fPixels->rowBytes();
 
-    sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeDeferredSurfaceContext(
-            desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, fit, SkBudgeted::kYes);
-    if (!sContext || !sContext->asTextureProxy()) {
+    sk_sp<SkData> data = fPixels->detachPixelsAsData();
+    if (!data) {
         return nullptr;
     }
 
-    SkImageInfo ii = SkImageInfo::MakeA8(desc.fWidth, desc.fHeight);
-    if (!sContext->writePixels(ii, fPixels->addr(), fPixels->rowBytes(), 0, 0)) {
+    sk_sp<SkImage> img = SkImage::MakeRasterData(ii, std::move(data), rowBytes);
+    if (!img) {
         return nullptr;
     }
 
-    return sContext->asTextureProxyRef();
+    return context->contextPriv().proxyProvider()->createTextureProxy(std::move(img),
+                                                                      kNone_GrSurfaceFlags, 1,
+                                                                      SkBudgeted::kYes, fit);
 }