sk_spification of GrGpu creation.

Make GrContext::MakeGL take interface as sk_sp.

Make GrContext::MakeVulkan take GrVkBackendContext as sk_sp.

Change-Id: I13c22a57bd281c51738f503d9ed3418d35a466df
Reviewed-on: https://skia-review.googlesource.com/81842
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 2b185c4..e8f5c4b 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -75,15 +75,15 @@
     return context.release();
 }
 
-sk_sp<GrContext> GrContext::MakeGL(const GrGLInterface* interface) {
+sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface) {
     GrContextOptions defaultOptions;
-    return MakeGL(interface, defaultOptions);
+    return MakeGL(std::move(interface), defaultOptions);
 }
 
-sk_sp<GrContext> GrContext::MakeGL(const GrGLInterface* interface,
+sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface,
                                    const GrContextOptions& options) {
     sk_sp<GrContext> context(new GrContext);
-    context->fGpu = GrGLGpu::Create(interface, options, context.get());
+    context->fGpu = GrGLGpu::Make(std::move(interface), options, context.get());
     if (!context->fGpu) {
         return nullptr;
     }
@@ -102,7 +102,7 @@
 sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions,
                                      const GrContextOptions& options) {
     sk_sp<GrContext> context(new GrContext);
-    context->fGpu = GrMockGpu::Create(mockOptions, options, context.get());
+    context->fGpu = GrMockGpu::Make(mockOptions, options, context.get());
     if (!context->fGpu) {
         return nullptr;
     }
@@ -114,15 +114,15 @@
 }
 
 #ifdef SK_VULKAN
-sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext* backendContext) {
+sk_sp<GrContext> GrContext::MakeVulkan(sk_sp<const GrVkBackendContext> backendContext) {
     GrContextOptions defaultOptions;
-    return MakeVulkan(backendContext, defaultOptions);
+    return MakeVulkan(std::move(backendContext), defaultOptions);
 }
 
-sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext* backendContext,
+sk_sp<GrContext> GrContext::MakeVulkan(sk_sp<const GrVkBackendContext> backendContext,
                                        const GrContextOptions& options) {
     sk_sp<GrContext> context(new GrContext);
-    context->fGpu = GrVkGpu::Create(backendContext, options, context.get());
+    context->fGpu = GrVkGpu::Make(std::move(backendContext), options, context.get());
     if (!context->fGpu) {
         return nullptr;
     }
@@ -142,7 +142,7 @@
 
 sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue, const GrContextOptions& options) {
     sk_sp<GrContext> context(new GrContext);
-    context->fGpu = GrMtlTrampoline::CreateGpu(context.get(), options, device, queue);
+    context->fGpu = GrMtlTrampoline::MakeGpu(context.get(), options, device, queue);
     if (!context->fGpu) {
         return nullptr;
     }
@@ -164,7 +164,6 @@
 }
 
 GrContext::GrContext() : fUniqueID(next_id()) {
-    fGpu = nullptr;
     fCaps = nullptr;
     fResourceCache = nullptr;
     fResourceProvider = nullptr;
@@ -178,7 +177,7 @@
 
     fBackend = backend;
 
-    fGpu = GrGpu::Create(backend, backendContext, options, this);
+    fGpu = GrGpu::Make(backend, backendContext, options, this);
     if (!fGpu) {
         return false;
     }
@@ -189,7 +188,7 @@
     ASSERT_SINGLE_OWNER
     fCaps = SkRef(fGpu->caps());
     fResourceCache = new GrResourceCache(fCaps, fUniqueID);
-    fResourceProvider = new GrResourceProvider(fGpu, fResourceCache, &fSingleOwner);
+    fResourceProvider = new GrResourceProvider(fGpu.get(), fResourceCache, &fSingleOwner);
 
     fDisableGpuYUVConversion = options.fDisableGpuYUVConversion;
     fDidTestPMConversions = false;
@@ -261,7 +260,6 @@
     delete fResourceCache;
     delete fAtlasGlyphCache;
 
-    fGpu->unref();
     fCaps->unref();
 }