aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-12-07 12:33:05 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-07 17:56:59 +0000
commit384fab467e2a5f1754ec26eecde946ce28046d20 (patch)
treec19ad170f2932c666c937736be71237c335e79b3
parent1cfb6bc9b63e9840d198a1ea8b1a20da2bfde818 (diff)
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>
-rw-r--r--example/SkiaSDLExample.cpp2
-rw-r--r--include/gpu/GrContext.h14
-rw-r--r--src/gpu/GrContext.cpp26
-rw-r--r--src/gpu/GrGpu.h3
-rw-r--r--src/gpu/GrGpuFactory.cpp14
-rw-r--r--src/gpu/gl/GrGLGpu.cpp29
-rw-r--r--src/gpu/gl/GrGLGpu.h8
-rw-r--r--src/gpu/mock/GrMockGpu.cpp12
-rw-r--r--src/gpu/mock/GrMockGpu.h4
-rw-r--r--src/gpu/mtl/GrMtlGpu.h4
-rw-r--r--src/gpu/mtl/GrMtlGpu.mm6
-rw-r--r--src/gpu/mtl/GrMtlTrampoline.h9
-rw-r--r--src/gpu/mtl/GrMtlTrampoline.mm16
-rw-r--r--src/gpu/vk/GrVkGpu.cpp45
-rw-r--r--src/gpu/vk/GrVkGpu.h10
-rw-r--r--tests/EGLImageTest.cpp2
-rw-r--r--tests/GpuSampleLocationsTest.cpp6
-rw-r--r--tools/gpu/gl/GLTestContext.cpp2
-rw-r--r--tools/gpu/gl/GLTestContext.h2
-rw-r--r--tools/gpu/vk/VkTestContext.cpp2
-rw-r--r--tools/sk_app/GLWindowContext.cpp2
-rw-r--r--tools/sk_app/VulkanWindowContext.cpp2
22 files changed, 108 insertions, 112 deletions
diff --git a/example/SkiaSDLExample.cpp b/example/SkiaSDLExample.cpp
index 3878cc7f95..ab181cb1c1 100644
--- a/example/SkiaSDLExample.cpp
+++ b/example/SkiaSDLExample.cpp
@@ -192,7 +192,7 @@ int main(int argc, char** argv) {
sk_sp<const GrGLInterface> interface(GrGLCreateNativeInterface());
// setup contexts
- sk_sp<GrContext> grContext(GrContext::MakeGL(interface.get()));
+ sk_sp<GrContext> grContext(GrContext::MakeGL(interface));
SkASSERT(grContext);
// Wrap the frame buffer object attached to the screen in a Skia render target so Skia can
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 7b87b0a879..4aafab8cb6 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -56,12 +56,12 @@ public:
static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions& options);
static GrContext* Create(GrBackend, GrBackendContext);
- static sk_sp<GrContext> MakeGL(const GrGLInterface*, const GrContextOptions&);
- static sk_sp<GrContext> MakeGL(const GrGLInterface*);
+ static sk_sp<GrContext> MakeGL(sk_sp<const GrGLInterface>, const GrContextOptions&);
+ static sk_sp<GrContext> MakeGL(sk_sp<const GrGLInterface>);
#ifdef SK_VULKAN
- static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext*, const GrContextOptions&);
- static sk_sp<GrContext> MakeVulkan(const GrVkBackendContext*);
+ static sk_sp<GrContext> MakeVulkan(sk_sp<const GrVkBackendContext>, const GrContextOptions&);
+ static sk_sp<GrContext> MakeVulkan(sk_sp<const GrVkBackendContext>);
#endif
#ifdef SK_METAL
@@ -291,8 +291,8 @@ public:
///////////////////////////////////////////////////////////////////////////
// Functions intended for internal use only.
- GrGpu* getGpu() { return fGpu; }
- const GrGpu* getGpu() const { return fGpu; }
+ GrGpu* getGpu() { return fGpu.get(); }
+ const GrGpu* getGpu() const { return fGpu.get(); }
GrAtlasGlyphCache* getAtlasGlyphCache() { return fAtlasGlyphCache; }
GrTextBlobCache* getTextBlobCache() { return fTextBlobCache.get(); }
bool abandoned() const;
@@ -344,7 +344,7 @@ public:
const GrContextPriv contextPriv() const;
private:
- GrGpu* fGpu;
+ sk_sp<GrGpu> fGpu;
const GrCaps* fCaps;
GrResourceCache* fResourceCache;
GrResourceProvider* fResourceProvider;
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 2b185c4ebc..e8f5c4b889 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -75,15 +75,15 @@ GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
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) {
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 @@ sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions,
}
#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) {
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 @@ static int32_t next_id() {
}
GrContext::GrContext() : fUniqueID(next_id()) {
- fGpu = nullptr;
fCaps = nullptr;
fResourceCache = nullptr;
fResourceProvider = nullptr;
@@ -178,7 +177,7 @@ bool GrContext::init(GrBackend backend, GrBackendContext backendContext,
fBackend = backend;
- fGpu = GrGpu::Create(backend, backendContext, options, this);
+ fGpu = GrGpu::Make(backend, backendContext, options, this);
if (!fGpu) {
return false;
}
@@ -189,7 +188,7 @@ bool GrContext::init(const GrContextOptions& options) {
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 @@ GrContext::~GrContext() {
delete fResourceCache;
delete fAtlasGlyphCache;
- fGpu->unref();
fCaps->unref();
}
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 676b3b0811..18ea772f23 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -55,7 +55,8 @@ public:
* not supported (at compile-time or run-time) this returns nullptr. The context will not be
* fully constructed and should not be used by GrGpu until after this function returns.
*/
- static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, GrContext* context);
+ static sk_sp<GrGpu> Make(GrBackend, GrBackendContext, const GrContextOptions&,
+ GrContext* context);
////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp
index 1fc19c144a..eb3c2928b6 100644
--- a/src/gpu/GrGpuFactory.cpp
+++ b/src/gpu/GrGpuFactory.cpp
@@ -13,19 +13,19 @@
#include "vk/GrVkGpu.h"
#endif
-GrGpu* GrGpu::Create(GrBackend backend,
- GrBackendContext backendContext,
- const GrContextOptions& options,
- GrContext* context) {
+sk_sp<GrGpu> GrGpu::Make(GrBackend backend,
+ GrBackendContext backendContext,
+ const GrContextOptions& options,
+ GrContext* context) {
switch (backend) {
case kOpenGL_GrBackend:
- return GrGLGpu::Create(backendContext, options, context);
+ return GrGLGpu::Make(backendContext, options, context);
#ifdef SK_VULKAN
case kVulkan_GrBackend:
- return GrVkGpu::Create(backendContext, options, context);
+ return GrVkGpu::Make(backendContext, options, context);
#endif
case kMock_GrBackend:
- return GrMockGpu::Create(backendContext, options, context);
+ return GrMockGpu::Make(backendContext, options, context);
default:
return nullptr;
}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 8bf6389fb6..33096160a4 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -182,29 +182,26 @@ bool GrGLGpu::BlendCoeffReferencesConstant(GrBlendCoeff coeff) {
///////////////////////////////////////////////////////////////////////////////
-
-GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options,
- GrContext* context) {
- return Create(reinterpret_cast<const GrGLInterface*>(backendContext), options, context);
+sk_sp<GrGpu> GrGLGpu::Make(GrBackendContext backendContext, const GrContextOptions& options,
+ GrContext* context) {
+ const auto* interface = reinterpret_cast<const GrGLInterface*>(backendContext);
+ return Make(sk_ref_sp(interface), options, context);
}
-GrGpu* GrGLGpu::Create(const GrGLInterface* interface, const GrContextOptions& options,
- GrContext* context) {
- sk_sp<const GrGLInterface> glInterface(interface);
- if (!glInterface) {
- glInterface.reset(GrGLDefaultInterface());
- } else {
- glInterface->ref();
- }
- if (!glInterface) {
- return nullptr;
+sk_sp<GrGpu> GrGLGpu::Make(sk_sp<const GrGLInterface> interface, const GrContextOptions& options,
+ GrContext* context) {
+ if (!interface) {
+ interface.reset(GrGLDefaultInterface());
+ if (!interface) {
+ return nullptr;
+ }
}
#ifdef USE_NSIGHT
const_cast<GrContextOptions&>(options).fSuppressPathRendering = true;
#endif
- GrGLContext* glContext = GrGLContext::Create(glInterface.get(), options);
+ GrGLContext* glContext = GrGLContext::Create(interface.get(), options);
if (glContext) {
- return new GrGLGpu(glContext, context);
+ return sk_sp<GrGpu>(new GrGLGpu(glContext, context));
}
return nullptr;
}
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 4d8b056bc7..5c26924dec 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -36,10 +36,10 @@ namespace gr_instanced { class GLInstancedRendering; }
class GrGLGpu final : public GrGpu, private GrMesh::SendToGpuImpl {
public:
- static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions& options,
- GrContext* context);
- static GrGpu* Create(const GrGLInterface*, const GrContextOptions& options,
- GrContext* context);
+ static sk_sp<GrGpu> Make(GrBackendContext backendContext, const GrContextOptions& options,
+ GrContext* context);
+ static sk_sp<GrGpu> Make(sk_sp<const GrGLInterface>, const GrContextOptions& options,
+ GrContext* context);
~GrGLGpu() override;
void disconnect(DisconnectType) override;
diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp
index a21991fabe..5969f2f1d2 100644
--- a/src/gpu/mock/GrMockGpu.cpp
+++ b/src/gpu/mock/GrMockGpu.cpp
@@ -24,18 +24,18 @@ int GrMockGpu::NextExternalTextureID() {
return sk_atomic_dec(&gID) - 1;
}
-GrGpu* GrMockGpu::Create(GrBackendContext backendContext, const GrContextOptions& contextOptions,
- GrContext* context) {
- return Create(reinterpret_cast<const GrMockOptions*>(backendContext), contextOptions, context);
+sk_sp<GrGpu> GrMockGpu::Make(GrBackendContext backendContext,
+ const GrContextOptions& contextOptions, GrContext* context) {
+ return Make(reinterpret_cast<const GrMockOptions*>(backendContext), contextOptions, context);
}
-GrGpu* GrMockGpu::Create(const GrMockOptions* mockOptions, const GrContextOptions& contextOptions,
- GrContext* context) {
+sk_sp<GrGpu> GrMockGpu::Make(const GrMockOptions* mockOptions,
+ const GrContextOptions& contextOptions, GrContext* context) {
static const GrMockOptions kDefaultOptions = GrMockOptions();
if (!mockOptions) {
mockOptions = &kDefaultOptions;
}
- return new GrMockGpu(context, *mockOptions, contextOptions);
+ return sk_sp<GrGpu>(new GrMockGpu(context, *mockOptions, contextOptions));
}
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
index 574906ea3d..49a52ff183 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -20,8 +20,8 @@ class GrPipeline;
class GrMockGpu : public GrGpu {
public:
- static GrGpu* Create(GrBackendContext, const GrContextOptions&, GrContext*);
- static GrGpu* Create(const GrMockOptions*, const GrContextOptions&, GrContext*);
+ static sk_sp<GrGpu> Make(GrBackendContext, const GrContextOptions&, GrContext*);
+ static sk_sp<GrGpu> Make(const GrMockOptions*, const GrContextOptions&, GrContext*);
~GrMockGpu() override {}
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index fb2c368102..cb2744f0aa 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -22,8 +22,8 @@ struct GrMtlBackendContext;
class GrMtlGpu : public GrGpu {
public:
- static GrGpu* Create(GrContext* context, const GrContextOptions& options,
- id<MTLDevice> device, id<MTLCommandQueue> queue);
+ static sk_sp<GrGpu> Make(GrContext* context, const GrContextOptions& options,
+ id<MTLDevice> device, id<MTLCommandQueue> queue);
~GrMtlGpu() override {}
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm
index a830959bdd..149e56220e 100644
--- a/src/gpu/mtl/GrMtlGpu.mm
+++ b/src/gpu/mtl/GrMtlGpu.mm
@@ -69,8 +69,8 @@ static bool get_feature_set(id<MTLDevice> device, MTLFeatureSet* featureSet) {
return false;
}
-GrGpu* GrMtlGpu::Create(GrContext* context, const GrContextOptions& options,
- id<MTLDevice> device, id<MTLCommandQueue> queue) {
+sk_sp<GrGpu> GrMtlGpu::Make(GrContext* context, const GrContextOptions& options,
+ id<MTLDevice> device, id<MTLCommandQueue> queue) {
if (!device || !queue) {
return nullptr;
}
@@ -78,7 +78,7 @@ GrGpu* GrMtlGpu::Create(GrContext* context, const GrContextOptions& options,
if (!get_feature_set(device, &featureSet)) {
return nullptr;
}
- return new GrMtlGpu(context, options, device, queue, featureSet);
+ return sk_sp<GrGpu>(new GrMtlGpu(context, options, device, queue, featureSet));
}
GrMtlGpu::GrMtlGpu(GrContext* context, const GrContextOptions& options,
diff --git a/src/gpu/mtl/GrMtlTrampoline.h b/src/gpu/mtl/GrMtlTrampoline.h
index 531a4ce00c..29a5bf3a1e 100644
--- a/src/gpu/mtl/GrMtlTrampoline.h
+++ b/src/gpu/mtl/GrMtlTrampoline.h
@@ -9,6 +9,7 @@
#define GrMtlTrampoline_DEFINED
#include "GrTypes.h"
+#include "SkRefCnt.h"
class GrContext;
class GrGpu;
@@ -20,10 +21,10 @@ struct GrContextOptions;
*/
class GrMtlTrampoline {
public:
- static GrGpu* CreateGpu(GrContext* context,
- const GrContextOptions& options,
- void* device,
- void* queue);
+ static sk_sp<GrGpu> MakeGpu(GrContext* context,
+ const GrContextOptions& options,
+ void* device,
+ void* queue);
};
#endif
diff --git a/src/gpu/mtl/GrMtlTrampoline.mm b/src/gpu/mtl/GrMtlTrampoline.mm
index 0f112e4da5..516ac52fe0 100644
--- a/src/gpu/mtl/GrMtlTrampoline.mm
+++ b/src/gpu/mtl/GrMtlTrampoline.mm
@@ -9,13 +9,13 @@
#include "GrMtlGpu.h"
-GrGpu* GrMtlTrampoline::CreateGpu(GrContext* context,
- const GrContextOptions& options,
- void* device,
- void* queue) {
- return GrMtlGpu::Create(context,
- options,
- (__bridge_transfer id<MTLDevice>)device,
- (__bridge_transfer id<MTLCommandQueue>)queue);
+sk_sp<GrGpu> GrMtlTrampoline::MakeGpu(GrContext* context,
+ const GrContextOptions& options,
+ void* device,
+ void* queue) {
+ return GrMtlGpu::Make(context,
+ options,
+ (__bridge_transfer id<MTLDevice>)device,
+ (__bridge_transfer id<MTLCommandQueue>)queue);
}
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index a87c344d9a..0a642346f2 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -73,40 +73,38 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(
}
#endif
-GrGpu* GrVkGpu::Create(GrBackendContext backendContext, const GrContextOptions& options,
- GrContext* context) {
- return Create(reinterpret_cast<const GrVkBackendContext*>(backendContext), options, context);
+sk_sp<GrGpu> GrVkGpu::Make(GrBackendContext backendContext, const GrContextOptions& options,
+ GrContext* context) {
+ const auto* backend = reinterpret_cast<const GrVkBackendContext*>(backendContext);
+ return Make(sk_ref_sp(backend), options, context);
}
-GrGpu* GrVkGpu::Create(const GrVkBackendContext* backendContext, const GrContextOptions& options,
- GrContext* context) {
+sk_sp<GrGpu> GrVkGpu::Make(sk_sp<const GrVkBackendContext> backendContext,
+ const GrContextOptions& options, GrContext* context) {
if (!backendContext) {
return nullptr;
- } else {
- backendContext->ref();
}
if (!backendContext->fInterface->validate(backendContext->fExtensions)) {
return nullptr;
}
- return new GrVkGpu(context, options, backendContext);
+ return sk_sp<GrGpu>(new GrVkGpu(context, options, std::move(backendContext)));
}
////////////////////////////////////////////////////////////////////////////////
GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
- const GrVkBackendContext* backendCtx)
- : INHERITED(context)
- , fDevice(backendCtx->fDevice)
- , fQueue(backendCtx->fQueue)
- , fResourceProvider(this)
- , fDisconnected(false) {
- fBackendContext.reset(backendCtx);
-
+ sk_sp<const GrVkBackendContext> backendCtx)
+ : INHERITED(context)
+ , fBackendContext(std::move(backendCtx))
+ , fDevice(fBackendContext->fDevice)
+ , fQueue(fBackendContext->fQueue)
+ , fResourceProvider(this)
+ , fDisconnected(false) {
#ifdef SK_ENABLE_VK_LAYERS
fCallback = VK_NULL_HANDLE;
- if (backendCtx->fExtensions & kEXT_debug_report_GrVkExtensionFlag) {
+ if (fBackendContext->fExtensions & kEXT_debug_report_GrVkExtensionFlag) {
// Setup callback creation information
VkDebugReportCallbackCreateInfoEXT callbackCreateInfo;
callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
@@ -120,25 +118,26 @@ GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options,
callbackCreateInfo.pUserData = nullptr;
// Register the callback
- GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateDebugReportCallbackEXT(
- backendCtx->fInstance, &callbackCreateInfo, nullptr, &fCallback));
+ GR_VK_CALL_ERRCHECK(this->vkInterface(),
+ CreateDebugReportCallbackEXT(fBackendContext->fInstance,
+ &callbackCreateInfo, nullptr, &fCallback));
}
#endif
fCompiler = new SkSL::Compiler();
- fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendCtx->fPhysicalDevice,
- backendCtx->fFeatures, backendCtx->fExtensions));
+ fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), fBackendContext->fPhysicalDevice,
+ fBackendContext->fFeatures, fBackendContext->fExtensions));
fCaps.reset(SkRef(fVkCaps.get()));
- VK_CALL(GetPhysicalDeviceMemoryProperties(backendCtx->fPhysicalDevice, &fPhysDevMemProps));
+ VK_CALL(GetPhysicalDeviceMemoryProperties(fBackendContext->fPhysicalDevice, &fPhysDevMemProps));
const VkCommandPoolCreateInfo cmdPoolInfo = {
VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType
nullptr, // pNext
VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // CmdPoolCreateFlags
- backendCtx->fGraphicsQueueIndex, // queueFamilyIndex
+ fBackendContext->fGraphicsQueueIndex, // queueFamilyIndex
};
GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateCommandPool(fDevice, &cmdPoolInfo, nullptr,
&fCmdPool));
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 1d2aca3673..8e6f39195a 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -38,10 +38,10 @@ namespace SkSL {
class GrVkGpu : public GrGpu {
public:
- static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions& options,
- GrContext* context);
- static GrGpu* Create(const GrVkBackendContext*, const GrContextOptions& options,
- GrContext* context);
+ static sk_sp<GrGpu> Make(GrBackendContext backendContext, const GrContextOptions& options,
+ GrContext* context);
+ static sk_sp<GrGpu> Make(sk_sp<const GrVkBackendContext>, const GrContextOptions& options,
+ GrContext* context);
~GrVkGpu() override;
@@ -174,7 +174,7 @@ public:
private:
GrVkGpu(GrContext* context, const GrContextOptions& options,
- const GrVkBackendContext* backendContext);
+ sk_sp<const GrVkBackendContext> backendContext);
void onResetContext(uint32_t resetBits) override {}
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 82e4c4bb55..53ff6f94f5 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -63,7 +63,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
if (!glCtx1) {
return;
}
- sk_sp<GrContext> context1 = GrContext::MakeGL(glCtx1->gl());
+ sk_sp<GrContext> context1 = GrContext::MakeGL(sk_ref_sp(glCtx1->gl()));
const GrGLTextureInfo* backendTexture1 = nullptr;
GrEGLImage image = GR_EGL_NO_IMAGE;
GrGLTextureInfo externalTexture;
diff --git a/tests/GpuSampleLocationsTest.cpp b/tests/GpuSampleLocationsTest.cpp
index e78006344c..de15e03389 100644
--- a/tests/GpuSampleLocationsTest.cpp
+++ b/tests/GpuSampleLocationsTest.cpp
@@ -185,15 +185,15 @@ private:
};
DEF_GPUTEST(GLSampleLocations, reporter, /* options */) {
- GLTestSampleLocationsInterface testInterface;
- sk_sp<GrContext> ctx(GrContext::MakeGL(&testInterface));
+ auto testInterface = sk_make_sp<GLTestSampleLocationsInterface>();
+ sk_sp<GrContext> ctx(GrContext::MakeGL(testInterface));
// This test relies on at least 2 samples.
int supportedSample = ctx->caps()->getSampleCount(2, kRGBA_8888_GrPixelConfig);
if (supportedSample < 2) {
return;
}
- test_sampleLocations(reporter, &testInterface, ctx.get());
+ test_sampleLocations(reporter, testInterface.get(), ctx.get());
}
#endif
diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp
index 76e38b71b4..2c1d977b76 100644
--- a/tools/gpu/gl/GLTestContext.cpp
+++ b/tools/gpu/gl/GLTestContext.cpp
@@ -344,7 +344,7 @@ GrGLint GLTestContext::createTextureRectangle(int width, int height, GrGLenum in
}
sk_sp<GrContext> GLTestContext::makeGrContext(const GrContextOptions& options) {
- return GrContext::MakeGL(fGL.get(), options);
+ return GrContext::MakeGL(fGL, options);
}
} // namespace sk_gpu_test
diff --git a/tools/gpu/gl/GLTestContext.h b/tools/gpu/gl/GLTestContext.h
index b5dd9acf8a..02fe78e33e 100644
--- a/tools/gpu/gl/GLTestContext.h
+++ b/tools/gpu/gl/GLTestContext.h
@@ -27,7 +27,7 @@ public:
bool isValid() const { return SkToBool(this->gl()); }
- const GrGLInterface *gl() const { return fGL.get(); }
+ const GrGLInterface* gl() const { return fGL.get(); }
/** Used for testing EGLImage integration. Take a GL_TEXTURE_2D and wraps it in an EGL Image */
virtual GrEGLImage texture2DToEGLImage(GrGLuint /*texID*/) const { return nullptr; }
diff --git a/tools/gpu/vk/VkTestContext.cpp b/tools/gpu/vk/VkTestContext.cpp
index fa40c7374a..25069fe521 100644
--- a/tools/gpu/vk/VkTestContext.cpp
+++ b/tools/gpu/vk/VkTestContext.cpp
@@ -137,7 +137,7 @@ public:
void finish() override {}
sk_sp<GrContext> makeGrContext(const GrContextOptions& options) override {
- return GrContext::MakeVulkan(fVk.get(), options);
+ return GrContext::MakeVulkan(fVk, options);
}
protected:
diff --git a/tools/sk_app/GLWindowContext.cpp b/tools/sk_app/GLWindowContext.cpp
index bdfa12a8ec..d928a7bf43 100644
--- a/tools/sk_app/GLWindowContext.cpp
+++ b/tools/sk_app/GLWindowContext.cpp
@@ -33,7 +33,7 @@ void GLWindowContext::initializeContext() {
SkASSERT(!fContext);
fBackendContext = this->onInitializeContext();
- fContext = GrContext::MakeGL(fBackendContext.get(), fDisplayParams.fGrContextOptions);
+ fContext = GrContext::MakeGL(fBackendContext, fDisplayParams.fGrContextOptions);
if (!fContext && fDisplayParams.fMSAASampleCount) {
fDisplayParams.fMSAASampleCount /= 2;
this->initializeContext();
diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp
index 5e0f12412e..35177494f7 100644
--- a/tools/sk_app/VulkanWindowContext.cpp
+++ b/tools/sk_app/VulkanWindowContext.cpp
@@ -72,7 +72,7 @@ void VulkanWindowContext::initializeContext() {
GET_DEV_PROC(QueuePresentKHR);
GET_DEV_PROC(GetDeviceQueue);
- fContext = GrContext::MakeVulkan(fBackendContext.get(), fDisplayParams.fGrContextOptions);
+ fContext = GrContext::MakeVulkan(fBackendContext, fDisplayParams.fGrContextOptions);
fSurface = fCreateVkSurfaceFn(instance);
if (VK_NULL_HANDLE == fSurface) {