Split GrDDL- & GrDirect- Contexts into their own files
Following up on an prior CLs TODO Change-Id: I99397d4ffa5cc67b39726900f48b399e38fdbdd9 Reviewed-on: https://skia-review.googlesource.com/113201 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
1eb5ca41d9
commit
a3457b8452
@ -72,10 +72,12 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/GrContext.cpp",
|
||||
"$_src/gpu/GrContextPriv.h",
|
||||
"$_src/gpu/GrCoordTransform.h",
|
||||
"$_src/gpu/GrDDLContext.cpp",
|
||||
"$_src/gpu/GrDefaultGeoProcFactory.cpp",
|
||||
"$_src/gpu/GrDefaultGeoProcFactory.h",
|
||||
"$_src/gpu/GrDeferredProxyUploader.h",
|
||||
"$_src/gpu/GrDeferredUpload.h",
|
||||
"$_src/gpu/GrDirectContext.cpp",
|
||||
"$_src/gpu/GrDistanceFieldGenFromVector.cpp",
|
||||
"$_src/gpu/GrDistanceFieldGenFromVector.h",
|
||||
"$_src/gpu/GrDrawingManager.cpp",
|
||||
|
@ -34,15 +34,7 @@
|
||||
#include "SkTaskGroup.h"
|
||||
#include "SkUnPreMultiplyPriv.h"
|
||||
#include "effects/GrConfigConversionEffect.h"
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "mock/GrMockGpu.h"
|
||||
#include "text/GrTextBlobCache.h"
|
||||
#ifdef SK_METAL
|
||||
#include "mtl/GrMtlTrampoline.h"
|
||||
#endif
|
||||
#ifdef SK_VULKAN
|
||||
#include "vk/GrVkGpu.h"
|
||||
#endif
|
||||
|
||||
#define ASSERT_OWNED_PROXY(P) \
|
||||
SkASSERT(!(P) || !((P)->priv().peekTexture()) || (P)->priv().peekTexture()->getContext() == this)
|
||||
@ -62,250 +54,6 @@ SkASSERT(!(P) || !((P)->priv().peekTexture()) || (P)->priv().peekTexture()->getC
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class SK_API GrDirectContext : public GrContext {
|
||||
public:
|
||||
GrDirectContext(GrBackend backend)
|
||||
: INHERITED(backend)
|
||||
, fAtlasManager(nullptr) {
|
||||
}
|
||||
|
||||
~GrDirectContext() override {
|
||||
// this if-test protects against the case where the context is being destroyed
|
||||
// before having been fully created
|
||||
if (this->contextPriv().getGpu()) {
|
||||
this->flush();
|
||||
}
|
||||
|
||||
delete fAtlasManager;
|
||||
}
|
||||
|
||||
void abandonContext() override {
|
||||
INHERITED::abandonContext();
|
||||
fAtlasManager->freeAll();
|
||||
}
|
||||
|
||||
void releaseResourcesAndAbandonContext() override {
|
||||
INHERITED::releaseResourcesAndAbandonContext();
|
||||
fAtlasManager->freeAll();
|
||||
}
|
||||
|
||||
void freeGpuResources() override {
|
||||
this->flush();
|
||||
fAtlasManager->freeAll();
|
||||
|
||||
INHERITED::freeGpuResources();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool init(const GrContextOptions& options) override {
|
||||
SkASSERT(fCaps); // should've been set in ctor
|
||||
SkASSERT(!fThreadSafeProxy);
|
||||
|
||||
fThreadSafeProxy.reset(new GrContextThreadSafeProxy(fCaps, this->uniqueID(),
|
||||
fBackend, options));
|
||||
|
||||
if (!INHERITED::initCommon(options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GrDrawOpAtlas::AllowMultitexturing allowMultitexturing;
|
||||
if (GrContextOptions::Enable::kNo == options.fAllowMultipleGlyphCacheTextures ||
|
||||
// multitexturing supported only if range can represent the index + texcoords fully
|
||||
!(fCaps->shaderCaps()->floatIs32Bits() || fCaps->shaderCaps()->integerSupport())) {
|
||||
allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kNo;
|
||||
} else {
|
||||
allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kYes;
|
||||
}
|
||||
|
||||
GrGlyphCache* glyphCache = this->contextPriv().getGlyphCache();
|
||||
GrProxyProvider* proxyProvider = this->contextPriv().proxyProvider();
|
||||
|
||||
fAtlasManager = new GrAtlasManager(proxyProvider, glyphCache,
|
||||
options.fGlyphCacheTextureMaximumBytes,
|
||||
allowMultitexturing);
|
||||
this->contextPriv().addOnFlushCallbackObject(fAtlasManager);
|
||||
|
||||
SkASSERT(glyphCache->getGlyphSizeLimit() == fAtlasManager->getGlyphSizeLimit());
|
||||
return true;
|
||||
}
|
||||
|
||||
GrAtlasManager* onGetAtlasManager() override { return fAtlasManager; }
|
||||
|
||||
private:
|
||||
GrAtlasManager* fAtlasManager;
|
||||
|
||||
typedef GrContext INHERITED;
|
||||
};
|
||||
|
||||
/**
|
||||
* The DDL Context is the one in effect during DDL Recording. It isn't backed by a GrGPU and
|
||||
* cannot allocate any GPU resources.
|
||||
*/
|
||||
class SK_API GrDDLContext : public GrContext {
|
||||
public:
|
||||
GrDDLContext(sk_sp<GrContextThreadSafeProxy> proxy)
|
||||
: INHERITED(proxy->fBackend, proxy->fContextUniqueID) {
|
||||
fCaps = proxy->fCaps;
|
||||
fThreadSafeProxy = std::move(proxy);
|
||||
}
|
||||
|
||||
~GrDDLContext() override {
|
||||
// The GrDDLContext doesn't actually own the fRestrictedAtlasManager so don't delete it
|
||||
}
|
||||
|
||||
void abandonContext() override {
|
||||
SkASSERT(0); // abandoning in a DDL Recorder doesn't make a whole lot of sense
|
||||
INHERITED::abandonContext();
|
||||
}
|
||||
|
||||
void releaseResourcesAndAbandonContext() override {
|
||||
SkASSERT(0); // abandoning in a DDL Recorder doesn't make a whole lot of sense
|
||||
INHERITED::releaseResourcesAndAbandonContext();
|
||||
}
|
||||
|
||||
void freeGpuResources() override {
|
||||
SkASSERT(0); // freeing resources in a DDL Recorder doesn't make a whole lot of sense
|
||||
INHERITED::freeGpuResources();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool init(const GrContextOptions& options) override {
|
||||
SkASSERT(fCaps); // should've been set in ctor
|
||||
SkASSERT(fThreadSafeProxy); // should've been set in the ctor
|
||||
|
||||
if (!INHERITED::initCommon(options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GrAtlasManager* onGetAtlasManager() override {
|
||||
SkASSERT(0); // the DDL Recorders should never invoke this
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef GrContext INHERITED;
|
||||
};
|
||||
|
||||
GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
|
||||
GrContextOptions defaultOptions;
|
||||
return Create(backend, backendContext, defaultOptions);
|
||||
}
|
||||
|
||||
GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
|
||||
const GrContextOptions& options) {
|
||||
|
||||
sk_sp<GrContext> context(new GrDirectContext(backend));
|
||||
|
||||
context->fGpu = GrGpu::Make(backend, backendContext, options, context.get());
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context->fCaps = context->fGpu->refCaps();
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return context.release();
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface) {
|
||||
GrContextOptions defaultOptions;
|
||||
return MakeGL(std::move(interface), defaultOptions);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface,
|
||||
const GrContextOptions& options) {
|
||||
sk_sp<GrContext> context(new GrDirectContext(kOpenGL_GrBackend));
|
||||
|
||||
context->fGpu = GrGLGpu::Make(std::move(interface), options, context.get());
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context->fCaps = context->fGpu->refCaps();
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeGL(const GrGLInterface* interface) {
|
||||
return MakeGL(sk_ref_sp(interface));
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeGL(const GrGLInterface* interface,
|
||||
const GrContextOptions& options) {
|
||||
return MakeGL(sk_ref_sp(interface), options);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions) {
|
||||
GrContextOptions defaultOptions;
|
||||
return MakeMock(mockOptions, defaultOptions);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions,
|
||||
const GrContextOptions& options) {
|
||||
sk_sp<GrContext> context(new GrDirectContext(kMock_GrBackend));
|
||||
|
||||
context->fGpu = GrMockGpu::Make(mockOptions, options, context.get());
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context->fCaps = context->fGpu->refCaps();
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
#ifdef SK_VULKAN
|
||||
sk_sp<GrContext> GrContext::MakeVulkan(sk_sp<const GrVkBackendContext> backendContext) {
|
||||
GrContextOptions defaultOptions;
|
||||
return MakeVulkan(std::move(backendContext), defaultOptions);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeVulkan(sk_sp<const GrVkBackendContext> backendContext,
|
||||
const GrContextOptions& options) {
|
||||
sk_sp<GrContext> context(new GrDirectContext(kVulkan_GrBackend));
|
||||
|
||||
context->fGpu = GrVkGpu::Make(std::move(backendContext), options, context.get());
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context->fCaps = context->fGpu->refCaps();
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SK_METAL
|
||||
sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue) {
|
||||
GrContextOptions defaultOptions;
|
||||
return MakeMetal(device, queue, defaultOptions);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue, const GrContextOptions& options) {
|
||||
sk_sp<GrContext> context(new GrDirectContext(kMetal_GrBackend));
|
||||
|
||||
context->fGpu = GrMtlTrampoline::MakeGpu(context.get(), options, device, queue);
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t gNextID = 1;
|
||||
static int32_t next_id() {
|
||||
int32_t id;
|
||||
@ -315,17 +63,6 @@ static int32_t next_id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContextPriv::MakeDDL(sk_sp<GrContextThreadSafeProxy> proxy) {
|
||||
sk_sp<GrContext> context(new GrDDLContext(proxy));
|
||||
|
||||
// Note: we aren't creating a Gpu here. This causes the resource provider & cache to
|
||||
// also not be created
|
||||
if (!context->init(proxy->fOptions)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
GrContext::GrContext(GrBackend backend, int32_t id)
|
||||
: fBackend(backend)
|
||||
, fUniqueID(SK_InvalidGenID == id ? next_id() : id) {
|
||||
|
73
src/gpu/GrDDLContext.cpp
Normal file
73
src/gpu/GrDDLContext.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "GrContext.h"
|
||||
|
||||
#include "GrContextPriv.h"
|
||||
|
||||
/**
|
||||
* The DDL Context is the one in effect during DDL Recording. It isn't backed by a GrGPU and
|
||||
* cannot allocate any GPU resources.
|
||||
*/
|
||||
class SK_API GrDDLContext : public GrContext {
|
||||
public:
|
||||
GrDDLContext(sk_sp<GrContextThreadSafeProxy> proxy)
|
||||
: INHERITED(proxy->fBackend, proxy->fContextUniqueID) {
|
||||
fCaps = proxy->fCaps;
|
||||
fThreadSafeProxy = std::move(proxy);
|
||||
}
|
||||
|
||||
~GrDDLContext() override {
|
||||
// The GrDDLContext doesn't actually own the fRestrictedAtlasManager so don't delete it
|
||||
}
|
||||
|
||||
void abandonContext() override {
|
||||
SkASSERT(0); // abandoning in a DDL Recorder doesn't make a whole lot of sense
|
||||
INHERITED::abandonContext();
|
||||
}
|
||||
|
||||
void releaseResourcesAndAbandonContext() override {
|
||||
SkASSERT(0); // abandoning in a DDL Recorder doesn't make a whole lot of sense
|
||||
INHERITED::releaseResourcesAndAbandonContext();
|
||||
}
|
||||
|
||||
void freeGpuResources() override {
|
||||
SkASSERT(0); // freeing resources in a DDL Recorder doesn't make a whole lot of sense
|
||||
INHERITED::freeGpuResources();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool init(const GrContextOptions& options) override {
|
||||
SkASSERT(fCaps); // should've been set in ctor
|
||||
SkASSERT(fThreadSafeProxy); // should've been set in the ctor
|
||||
|
||||
if (!INHERITED::initCommon(options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GrAtlasManager* onGetAtlasManager() override {
|
||||
SkASSERT(0); // the DDL Recorders should never invoke this
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef GrContext INHERITED;
|
||||
};
|
||||
|
||||
sk_sp<GrContext> GrContextPriv::MakeDDL(sk_sp<GrContextThreadSafeProxy> proxy) {
|
||||
sk_sp<GrContext> context(new GrDDLContext(proxy));
|
||||
|
||||
// Note: we aren't creating a Gpu here. This causes the resource provider & cache to
|
||||
// also not be created
|
||||
if (!context->init(proxy->fOptions)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
214
src/gpu/GrDirectContext.cpp
Normal file
214
src/gpu/GrDirectContext.cpp
Normal file
@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "GrContext.h"
|
||||
|
||||
#include "GrContextPriv.h"
|
||||
#include "GrGpu.h"
|
||||
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "mock/GrMockGpu.h"
|
||||
#include "text/GrGlyphCache.h"
|
||||
#ifdef SK_METAL
|
||||
#include "mtl/GrMtlTrampoline.h"
|
||||
#endif
|
||||
#ifdef SK_VULKAN
|
||||
#include "vk/GrVkGpu.h"
|
||||
#endif
|
||||
|
||||
class SK_API GrDirectContext : public GrContext {
|
||||
public:
|
||||
GrDirectContext(GrBackend backend)
|
||||
: INHERITED(backend)
|
||||
, fAtlasManager(nullptr) {
|
||||
}
|
||||
|
||||
~GrDirectContext() override {
|
||||
// this if-test protects against the case where the context is being destroyed
|
||||
// before having been fully created
|
||||
if (this->contextPriv().getGpu()) {
|
||||
this->flush();
|
||||
}
|
||||
|
||||
delete fAtlasManager;
|
||||
}
|
||||
|
||||
void abandonContext() override {
|
||||
INHERITED::abandonContext();
|
||||
fAtlasManager->freeAll();
|
||||
}
|
||||
|
||||
void releaseResourcesAndAbandonContext() override {
|
||||
INHERITED::releaseResourcesAndAbandonContext();
|
||||
fAtlasManager->freeAll();
|
||||
}
|
||||
|
||||
void freeGpuResources() override {
|
||||
this->flush();
|
||||
fAtlasManager->freeAll();
|
||||
|
||||
INHERITED::freeGpuResources();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool init(const GrContextOptions& options) override {
|
||||
SkASSERT(fCaps); // should've been set in ctor
|
||||
SkASSERT(!fThreadSafeProxy);
|
||||
|
||||
fThreadSafeProxy.reset(new GrContextThreadSafeProxy(fCaps, this->uniqueID(),
|
||||
fBackend, options));
|
||||
|
||||
if (!INHERITED::initCommon(options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GrDrawOpAtlas::AllowMultitexturing allowMultitexturing;
|
||||
if (GrContextOptions::Enable::kNo == options.fAllowMultipleGlyphCacheTextures ||
|
||||
// multitexturing supported only if range can represent the index + texcoords fully
|
||||
!(fCaps->shaderCaps()->floatIs32Bits() || fCaps->shaderCaps()->integerSupport())) {
|
||||
allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kNo;
|
||||
} else {
|
||||
allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kYes;
|
||||
}
|
||||
|
||||
GrGlyphCache* glyphCache = this->contextPriv().getGlyphCache();
|
||||
GrProxyProvider* proxyProvider = this->contextPriv().proxyProvider();
|
||||
|
||||
fAtlasManager = new GrAtlasManager(proxyProvider, glyphCache,
|
||||
options.fGlyphCacheTextureMaximumBytes,
|
||||
allowMultitexturing);
|
||||
this->contextPriv().addOnFlushCallbackObject(fAtlasManager);
|
||||
|
||||
SkASSERT(glyphCache->getGlyphSizeLimit() == fAtlasManager->getGlyphSizeLimit());
|
||||
return true;
|
||||
}
|
||||
|
||||
GrAtlasManager* onGetAtlasManager() override { return fAtlasManager; }
|
||||
|
||||
private:
|
||||
GrAtlasManager* fAtlasManager;
|
||||
|
||||
typedef GrContext INHERITED;
|
||||
};
|
||||
|
||||
GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
|
||||
GrContextOptions defaultOptions;
|
||||
return Create(backend, backendContext, defaultOptions);
|
||||
}
|
||||
|
||||
GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
|
||||
const GrContextOptions& options) {
|
||||
|
||||
sk_sp<GrContext> context(new GrDirectContext(backend));
|
||||
|
||||
context->fGpu = GrGpu::Make(backend, backendContext, options, context.get());
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context->fCaps = context->fGpu->refCaps();
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return context.release();
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface) {
|
||||
GrContextOptions defaultOptions;
|
||||
return MakeGL(std::move(interface), defaultOptions);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeGL(const GrGLInterface* interface) {
|
||||
return MakeGL(sk_ref_sp(interface));
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeGL(const GrGLInterface* interface,
|
||||
const GrContextOptions& options) {
|
||||
return MakeGL(sk_ref_sp(interface), options);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface,
|
||||
const GrContextOptions& options) {
|
||||
sk_sp<GrContext> context(new GrDirectContext(kOpenGL_GrBackend));
|
||||
|
||||
context->fGpu = GrGLGpu::Make(std::move(interface), options, context.get());
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context->fCaps = context->fGpu->refCaps();
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions) {
|
||||
GrContextOptions defaultOptions;
|
||||
return MakeMock(mockOptions, defaultOptions);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions,
|
||||
const GrContextOptions& options) {
|
||||
sk_sp<GrContext> context(new GrDirectContext(kMock_GrBackend));
|
||||
|
||||
context->fGpu = GrMockGpu::Make(mockOptions, options, context.get());
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context->fCaps = context->fGpu->refCaps();
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
#ifdef SK_VULKAN
|
||||
sk_sp<GrContext> GrContext::MakeVulkan(sk_sp<const GrVkBackendContext> backendContext) {
|
||||
GrContextOptions defaultOptions;
|
||||
return MakeVulkan(std::move(backendContext), defaultOptions);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeVulkan(sk_sp<const GrVkBackendContext> backendContext,
|
||||
const GrContextOptions& options) {
|
||||
sk_sp<GrContext> context(new GrDirectContext(kVulkan_GrBackend));
|
||||
|
||||
context->fGpu = GrVkGpu::Make(std::move(backendContext), options, context.get());
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
context->fCaps = context->fGpu->refCaps();
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SK_METAL
|
||||
sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue) {
|
||||
GrContextOptions defaultOptions;
|
||||
return MakeMetal(device, queue, defaultOptions);
|
||||
}
|
||||
|
||||
sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue, const GrContextOptions& options) {
|
||||
sk_sp<GrContext> context(new GrDirectContext(kMetal_GrBackend));
|
||||
|
||||
context->fGpu = GrMtlTrampoline::MakeGpu(context.get(), options, device, queue);
|
||||
if (!context->fGpu) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!context->init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user