Migrate GrGpu to GrDirectContext

Another piece of the Great Recontexting.

Change-Id: Ib089dbdba89e25add407cf816d28c96c7e5dbc05
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301303
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Adlai Holler 2020-07-09 15:35:55 -04:00 committed by Skia Commit-Bot
parent 53ee0fcac7
commit 3d0359a318
33 changed files with 98 additions and 78 deletions

View File

@ -334,7 +334,7 @@ void CCPRGeometryView::updateGpuData() {
void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state, void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state,
const SkRect& chainBounds) { const SkRect& chainBounds) {
GrResourceProvider* rp = state->resourceProvider(); GrResourceProvider* rp = state->resourceProvider();
auto direct = GrAsDirectContext(state->gpu()->getContext()); auto direct = state->gpu()->getContext();
#ifdef SK_GL #ifdef SK_GL
GrGLGpu* glGpu = GrBackendApi::kOpenGL == direct->backend() GrGLGpu* glGpu = GrBackendApi::kOpenGL == direct->backend()
? static_cast<GrGLGpu*>(state->gpu()) ? static_cast<GrGLGpu*>(state->gpu())

View File

@ -5,7 +5,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h" #include "include/gpu/GrTypes.h"
#include "include/private/SkMacros.h" #include "include/private/SkMacros.h"
#include "src/core/SkSafeMath.h" #include "src/core/SkSafeMath.h"

View File

@ -160,9 +160,10 @@ GrGLFunction<GrGLGetErrorFn> make_get_error_with_random_oom(GrGLFunction<GrGLGet
} }
#endif #endif
// CONTEXT TODO: Make* functions should return an sk_sp<GrDirectContext>
sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> glInterface, sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> glInterface,
const GrContextOptions& options) { const GrContextOptions& options) {
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kOpenGL, options)); auto direct = new GrDirectContext(GrBackendApi::kOpenGL, options);
#if GR_TEST_UTILS #if GR_TEST_UTILS
if (options.fRandomGLOOM) { if (options.fRandomGLOOM) {
auto copy = sk_make_sp<GrGLInterface>(*glInterface); auto copy = sk_make_sp<GrGLInterface>(*glInterface);
@ -175,7 +176,8 @@ sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> glInterface,
glInterface = std::move(copy); glInterface = std::move(copy);
} }
#endif #endif
context->fGpu = GrGLGpu::Make(std::move(glInterface), options, context.get()); direct->fGpu = GrGLGpu::Make(std::move(glInterface), options, direct);
sk_sp<GrContext> context(direct);
if (!context->init()) { if (!context->init()) {
return nullptr; return nullptr;
} }
@ -190,9 +192,10 @@ sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions) {
sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions, sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions,
const GrContextOptions& options) { const GrContextOptions& options) {
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kMock, options)); auto direct = new GrDirectContext(GrBackendApi::kMock, options);
context->fGpu = GrMockGpu::Make(mockOptions, options, context.get()); direct->fGpu = GrMockGpu::Make(mockOptions, options, direct);
sk_sp<GrContext> context(direct);
if (!context->init()) { if (!context->init()) {
return nullptr; return nullptr;
} }
@ -212,9 +215,10 @@ sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext)
sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext, sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext,
const GrContextOptions& options) { const GrContextOptions& options) {
#ifdef SK_VULKAN #ifdef SK_VULKAN
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kVulkan, options)); auto direct = new GrDirectContext(GrBackendApi::kVulkan, options);
context->fGpu = GrVkGpu::Make(backendContext, options, context.get()); direct->fGpu = GrVkGpu::Make(backendContext, options, direct);
sk_sp<GrContext> context(direct);
if (!context->init()) { if (!context->init()) {
return nullptr; return nullptr;
} }
@ -232,9 +236,10 @@ sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue) {
} }
sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue, const GrContextOptions& options) { sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue, const GrContextOptions& options) {
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kMetal, options)); auto direct = new GrDirectContext(GrBackendApi::kMetal, options);
context->fGpu = GrMtlTrampoline::MakeGpu(context.get(), options, device, queue); direct->fGpu = GrMtlTrampoline::MakeGpu(direct, options, device, queue);
sk_sp<GrContext> context(direct);
if (!context->init()) { if (!context->init()) {
return nullptr; return nullptr;
} }
@ -251,9 +256,10 @@ sk_sp<GrContext> GrContext::MakeDirect3D(const GrD3DBackendContext& backendConte
sk_sp<GrContext> GrContext::MakeDirect3D(const GrD3DBackendContext& backendContext, sk_sp<GrContext> GrContext::MakeDirect3D(const GrD3DBackendContext& backendContext,
const GrContextOptions& options) { const GrContextOptions& options) {
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kDirect3D, options)); auto direct = new GrDirectContext(GrBackendApi::kDirect3D, options);
context->fGpu = GrD3DGpu::Make(backendContext, options, context.get()); direct->fGpu = GrD3DGpu::Make(backendContext, options, direct);
sk_sp<GrContext> context(direct);
if (!context->init()) { if (!context->init()) {
return nullptr; return nullptr;
} }
@ -269,9 +275,10 @@ sk_sp<GrContext> GrContext::MakeDawn(const wgpu::Device& device) {
} }
sk_sp<GrContext> GrContext::MakeDawn(const wgpu::Device& device, const GrContextOptions& options) { sk_sp<GrContext> GrContext::MakeDawn(const wgpu::Device& device, const GrContextOptions& options) {
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kDawn, options)); auto direct = new GrDirectContext(GrBackendApi::kDawn, options);
context->fGpu = GrDawnGpu::Make(device, options, context.get()); direct->fGpu = GrDawnGpu::Make(device, options, direct);
sk_sp<GrContext> context(direct);
if (!context->init()) { if (!context->init()) {
return nullptr; return nullptr;
} }

View File

@ -10,7 +10,7 @@
#include "include/gpu/GrBackendSemaphore.h" #include "include/gpu/GrBackendSemaphore.h"
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "src/core/SkCompressedDataUtils.h" #include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkMathPriv.h" #include "src/core/SkMathPriv.h"
#include "src/core/SkMipMap.h" #include "src/core/SkMipMap.h"
@ -40,7 +40,7 @@ static const size_t kMinStagingBufferSize = 32 * 1024;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
GrGpu::GrGpu(GrContext* context) : fResetBits(kAll_GrBackendState), fContext(context) {} GrGpu::GrGpu(GrDirectContext* direct) : fResetBits(kAll_GrBackendState), fContext(direct) {}
GrGpu::~GrGpu() { GrGpu::~GrGpu() {
this->callSubmittedProcs(false); this->callSubmittedProcs(false);

View File

@ -20,12 +20,11 @@
#include "src/gpu/GrSwizzle.h" #include "src/gpu/GrSwizzle.h"
#include "src/gpu/GrTextureProducer.h" #include "src/gpu/GrTextureProducer.h"
#include "src/gpu/GrXferProcessor.h" #include "src/gpu/GrXferProcessor.h"
#include <map>
class GrBackendRenderTarget; class GrBackendRenderTarget;
class GrBackendSemaphore; class GrBackendSemaphore;
class GrDirectContext;
class GrGpuBuffer; class GrGpuBuffer;
class GrContext;
struct GrContextOptions; struct GrContextOptions;
class GrGLContext; class GrGLContext;
class GrPath; class GrPath;
@ -44,11 +43,11 @@ class SkJSONWriter;
class GrGpu : public SkRefCnt { class GrGpu : public SkRefCnt {
public: public:
GrGpu(GrContext* context); GrGpu(GrDirectContext* direct);
~GrGpu() override; ~GrGpu() override;
GrContext* getContext() { return fContext; } GrDirectContext* getContext() { return fContext; }
const GrContext* getContext() const { return fContext; } const GrDirectContext* getContext() const { return fContext; }
/** /**
* Gets the capabilities of the draw target. * Gets the capabilities of the draw target.
@ -66,12 +65,12 @@ public:
kCleanup, kCleanup,
}; };
// Called by GrContext when the underlying backend context is already or will be destroyed // Called by context when the underlying backend context is already or will be destroyed
// before GrContext. // before GrDirectContext.
virtual void disconnect(DisconnectType); virtual void disconnect(DisconnectType);
// Called by GrContext::isContextLost. Returns true if the backend Gpu object has gotten into an // Called by GrDirectContext::isContextLost. Returns true if the backend Gpu object has gotten
// unrecoverable, lost state. // into an unrecoverable, lost state.
virtual bool isDeviceLost() const { return false; } virtual bool isDeviceLost() const { return false; }
/** /**
@ -390,7 +389,7 @@ public:
bool checkAndResetOOMed(); bool checkAndResetOOMed();
/** /**
* Put this texture in a safe and known state for use across multiple GrContexts. Depending on * Put this texture in a safe and known state for use across multiple contexts. Depending on
* the backend, this may return a GrSemaphore. If so, other contexts should wait on that * the backend, this may return a GrSemaphore. If so, other contexts should wait on that
* semaphore before using this texture. * semaphore before using this texture.
*/ */
@ -636,7 +635,7 @@ public:
/** /**
* Frees a texture created by createBackendTexture(). If ownership of the backend * Frees a texture created by createBackendTexture(). If ownership of the backend
* texture has been transferred to a GrContext using adopt semantics this should not be called. * texture has been transferred to a context using adopt semantics this should not be called.
*/ */
virtual void deleteBackendTexture(const GrBackendTexture&) = 0; virtual void deleteBackendTexture(const GrBackendTexture&) = 0;
@ -868,7 +867,7 @@ private:
uint32_t fResetBits; uint32_t fResetBits;
// The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu.
GrContext* fContext; GrDirectContext* fContext;
GrSamplePatternDictionary fSamplePatternDictionary; GrSamplePatternDictionary fSamplePatternDictionary;
std::vector<std::unique_ptr<GrStagingBuffer>> fStagingBuffers; std::vector<std::unique_ptr<GrStagingBuffer>> fStagingBuffers;

View File

@ -6,7 +6,7 @@
*/ */
#include "include/core/SkTraceMemoryDump.h" #include "include/core/SkTraceMemoryDump.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrGpu.h" #include "src/gpu/GrGpu.h"
#include "src/gpu/GrGpuResource.h" #include "src/gpu/GrGpuResource.h"

View File

@ -7,6 +7,7 @@
#include "src/gpu/GrOpFlushState.h" #include "src/gpu/GrOpFlushState.h"
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkConvertPixels.h" #include "src/core/SkConvertPixels.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrDataUtils.h" #include "src/gpu/GrDataUtils.h"

View File

@ -29,8 +29,8 @@
#endif #endif
sk_sp<GrGpu> GrD3DGpu::Make(const GrD3DBackendContext& backendContext, sk_sp<GrGpu> GrD3DGpu::Make(const GrD3DBackendContext& backendContext,
const GrContextOptions& contextOptions, GrContext* context) { const GrContextOptions& contextOptions, GrDirectContext* direct) {
return sk_sp<GrGpu>(new GrD3DGpu(context, contextOptions, backendContext)); return sk_sp<GrGpu>(new GrD3DGpu(direct, contextOptions, backendContext));
} }
// This constant determines how many OutstandingCommandLists are allocated together as a block in // This constant determines how many OutstandingCommandLists are allocated together as a block in
@ -39,9 +39,9 @@ sk_sp<GrGpu> GrD3DGpu::Make(const GrD3DBackendContext& backendContext,
// command lists we expect to see. // command lists we expect to see.
static const int kDefaultOutstandingAllocCnt = 8; static const int kDefaultOutstandingAllocCnt = 8;
GrD3DGpu::GrD3DGpu(GrContext* context, const GrContextOptions& contextOptions, GrD3DGpu::GrD3DGpu(GrDirectContext* direct, const GrContextOptions& contextOptions,
const GrD3DBackendContext& backendContext) const GrD3DBackendContext& backendContext)
: INHERITED(context) : INHERITED(direct)
, fDevice(backendContext.fDevice) , fDevice(backendContext.fDevice)
, fQueue(backendContext.fQueue) , fQueue(backendContext.fQueue)

View File

@ -31,7 +31,7 @@ namespace SkSL {
class GrD3DGpu : public GrGpu { class GrD3DGpu : public GrGpu {
public: public:
static sk_sp<GrGpu> Make(const GrD3DBackendContext& backendContext, const GrContextOptions&, static sk_sp<GrGpu> Make(const GrD3DBackendContext& backendContext, const GrContextOptions&,
GrContext*); GrDirectContext*);
~GrD3DGpu() override; ~GrD3DGpu() override;
@ -113,7 +113,7 @@ private:
kSkip kSkip
}; };
GrD3DGpu(GrContext* context, const GrContextOptions&, const GrD3DBackendContext&); GrD3DGpu(GrDirectContext*, const GrContextOptions&, const GrD3DBackendContext&);
void destroyResources(); void destroyResources();

View File

@ -9,7 +9,7 @@
#include "src/gpu/d3d/GrD3DPipelineStateBuilder.h" #include "src/gpu/d3d/GrD3DPipelineStateBuilder.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "include/gpu/d3d/GrD3DTypes.h" #include "include/gpu/d3d/GrD3DTypes.h"
#include "src/core/SkTraceEvent.h" #include "src/core/SkTraceEvent.h"
#include "src/gpu/GrAutoLocaleSetter.h" #include "src/gpu/GrAutoLocaleSetter.h"

View File

@ -8,6 +8,7 @@
#include "src/gpu/d3d/GrD3DResourceProvider.h" #include "src/gpu/d3d/GrD3DResourceProvider.h"
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/d3d/GrD3DBuffer.h" #include "src/gpu/d3d/GrD3DBuffer.h"
#include "src/gpu/d3d/GrD3DCommandList.h" #include "src/gpu/d3d/GrD3DCommandList.h"

View File

@ -10,6 +10,7 @@
#include "include/gpu/GrBackendSemaphore.h" #include "include/gpu/GrBackendSemaphore.h"
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrDataUtils.h" #include "src/gpu/GrDataUtils.h"
#include "src/gpu/GrGeometryProcessor.h" #include "src/gpu/GrGeometryProcessor.h"
#include "src/gpu/GrGpuResourceCacheAccess.h" #include "src/gpu/GrGpuResourceCacheAccess.h"
@ -96,19 +97,19 @@ static wgpu::AddressMode to_dawn_address_mode(GrSamplerState::WrapMode wrapMode)
} }
sk_sp<GrGpu> GrDawnGpu::Make(const wgpu::Device& device, sk_sp<GrGpu> GrDawnGpu::Make(const wgpu::Device& device,
const GrContextOptions& options, GrContext* context) { const GrContextOptions& options, GrDirectContext* direct) {
if (!device) { if (!device) {
return nullptr; return nullptr;
} }
return sk_sp<GrGpu>(new GrDawnGpu(context, options, device)); return sk_sp<GrGpu>(new GrDawnGpu(direct, options, device));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
GrDawnGpu::GrDawnGpu(GrContext* context, const GrContextOptions& options, GrDawnGpu::GrDawnGpu(GrDirectContext* direct, const GrContextOptions& options,
const wgpu::Device& device) const wgpu::Device& device)
: INHERITED(context) : INHERITED(direct)
, fDevice(device) , fDevice(device)
, fQueue(device.GetDefaultQueue()) , fQueue(device.GetDefaultQueue())
, fCompiler(new SkSL::Compiler()) , fCompiler(new SkSL::Compiler())

View File

@ -20,6 +20,7 @@
class GrDawnOpsRenderPass; class GrDawnOpsRenderPass;
class GrDawnStagingBuffer; class GrDawnStagingBuffer;
class GrDirectContext;
class GrPipeline; class GrPipeline;
struct GrDawnProgram; struct GrDawnProgram;
@ -29,8 +30,7 @@ namespace SkSL {
class GrDawnGpu : public GrGpu { class GrDawnGpu : public GrGpu {
public: public:
static sk_sp<GrGpu> Make(const wgpu::Device& device, const GrContextOptions&, GrContext*); static sk_sp<GrGpu> Make(const wgpu::Device&, const GrContextOptions&, GrDirectContext*);
GrDawnGpu(GrContext* context, const GrContextOptions& options, const wgpu::Device& device);
~GrDawnGpu() override; ~GrDawnGpu() override;
@ -98,6 +98,8 @@ public:
void appendCommandBuffer(wgpu::CommandBuffer commandBuffer); void appendCommandBuffer(wgpu::CommandBuffer commandBuffer);
private: private:
GrDawnGpu(GrDirectContext*, const GrContextOptions&, const wgpu::Device&);
void onResetContext(uint32_t resetBits) override {} void onResetContext(uint32_t resetBits) override {}
virtual void querySampleLocations(GrRenderTarget*, SkTArray<SkPoint>*) override {} virtual void querySampleLocations(GrRenderTarget*, SkTArray<SkPoint>*) override {}

View File

@ -10,6 +10,7 @@
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrBackendSemaphore.h" #include "include/gpu/GrBackendSemaphore.h"
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h" #include "include/gpu/GrTypes.h"
#include "include/private/SkHalf.h" #include "include/private/SkHalf.h"
#include "include/private/SkTemplates.h" #include "include/private/SkTemplates.h"
@ -301,7 +302,7 @@ private:
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
sk_sp<GrGpu> GrGLGpu::Make(sk_sp<const GrGLInterface> interface, const GrContextOptions& options, sk_sp<GrGpu> GrGLGpu::Make(sk_sp<const GrGLInterface> interface, const GrContextOptions& options,
GrContext* context) { GrDirectContext* direct) {
if (!interface) { if (!interface) {
interface = GrGLMakeNativeInterface(); interface = GrGLMakeNativeInterface();
// For clients that have written their own GrGLCreateNativeInterface and haven't yet updated // For clients that have written their own GrGLCreateNativeInterface and haven't yet updated
@ -320,11 +321,11 @@ sk_sp<GrGpu> GrGLGpu::Make(sk_sp<const GrGLInterface> interface, const GrContext
if (!glContext) { if (!glContext) {
return nullptr; return nullptr;
} }
return sk_sp<GrGpu>(new GrGLGpu(std::move(glContext), context)); return sk_sp<GrGpu>(new GrGLGpu(std::move(glContext), direct));
} }
GrGLGpu::GrGLGpu(std::unique_ptr<GrGLContext> ctx, GrContext* context) GrGLGpu::GrGLGpu(std::unique_ptr<GrGLContext> ctx, GrDirectContext* direct)
: GrGpu(context) : GrGpu(direct)
, fGLContext(std::move(ctx)) , fGLContext(std::move(ctx))
, fProgramCache(new ProgramCache(this)) , fProgramCache(new ProgramCache(this))
, fHWProgramID(0) , fHWProgramID(0)

View File

@ -32,7 +32,7 @@ class GrSwizzle;
class GrGLGpu final : public GrGpu { class GrGLGpu final : public GrGpu {
public: public:
static sk_sp<GrGpu> Make(sk_sp<const GrGLInterface>, const GrContextOptions&, GrContext*); static sk_sp<GrGpu> Make(sk_sp<const GrGLInterface>, const GrContextOptions&, GrDirectContext*);
~GrGLGpu() override; ~GrGLGpu() override;
void disconnect(DisconnectType) override; void disconnect(DisconnectType) override;
@ -189,7 +189,7 @@ public:
void flushProgram(GrGLuint); void flushProgram(GrGLuint);
private: private:
GrGLGpu(std::unique_ptr<GrGLContext>, GrContext*); GrGLGpu(std::unique_ptr<GrGLContext>, GrDirectContext*);
// GrGpu overrides // GrGpu overrides
GrBackendTexture onCreateBackendTexture(SkISize dimensions, GrBackendTexture onCreateBackendTexture(SkISize dimensions,

View File

@ -8,6 +8,7 @@
#include "src/gpu/gl/GrGLGpu.h" #include "src/gpu/gl/GrGLGpu.h"
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrProcessor.h" #include "src/gpu/GrProcessor.h"
#include "src/gpu/GrProgramDesc.h" #include "src/gpu/GrProgramDesc.h"

View File

@ -6,7 +6,7 @@
*/ */
#include "include/core/SkTraceMemoryDump.h" #include "include/core/SkTraceMemoryDump.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrGpuResourcePriv.h" #include "src/gpu/GrGpuResourcePriv.h"
#include "src/gpu/GrRenderTargetPriv.h" #include "src/gpu/GrRenderTargetPriv.h"

View File

@ -6,7 +6,7 @@
*/ */
#include "include/core/SkTraceMemoryDump.h" #include "include/core/SkTraceMemoryDump.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrTexturePriv.h" #include "src/gpu/GrTexturePriv.h"
#include "src/gpu/gl/GrGLGpu.h" #include "src/gpu/gl/GrGLGpu.h"

View File

@ -7,7 +7,7 @@
#include "src/gpu/gl/builders/GrGLProgramBuilder.h" #include "src/gpu/gl/builders/GrGLProgramBuilder.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "src/core/SkATrace.h" #include "src/core/SkATrace.h"
#include "src/core/SkAutoMalloc.h" #include "src/core/SkAutoMalloc.h"
#include "src/core/SkReadBuffer.h" #include "src/core/SkReadBuffer.h"

View File

@ -44,12 +44,12 @@ int GrMockGpu::NextExternalRenderTargetID() {
} }
sk_sp<GrGpu> GrMockGpu::Make(const GrMockOptions* mockOptions, sk_sp<GrGpu> GrMockGpu::Make(const GrMockOptions* mockOptions,
const GrContextOptions& contextOptions, GrContext* context) { const GrContextOptions& contextOptions, GrDirectContext* direct) {
static const GrMockOptions kDefaultOptions = GrMockOptions(); static const GrMockOptions kDefaultOptions = GrMockOptions();
if (!mockOptions) { if (!mockOptions) {
mockOptions = &kDefaultOptions; mockOptions = &kDefaultOptions;
} }
return sk_sp<GrGpu>(new GrMockGpu(context, *mockOptions, contextOptions)); return sk_sp<GrGpu>(new GrMockGpu(direct, *mockOptions, contextOptions));
} }
GrOpsRenderPass* GrMockGpu::getOpsRenderPass( GrOpsRenderPass* GrMockGpu::getOpsRenderPass(
@ -68,9 +68,9 @@ void GrMockGpu::submit(GrOpsRenderPass* renderPass) {
delete renderPass; delete renderPass;
} }
GrMockGpu::GrMockGpu(GrContext* context, const GrMockOptions& options, GrMockGpu::GrMockGpu(GrDirectContext* direct, const GrMockOptions& options,
const GrContextOptions& contextOptions) const GrContextOptions& contextOptions)
: INHERITED(context) : INHERITED(direct)
, fMockOptions(options) { , fMockOptions(options) {
fCaps.reset(new GrMockCaps(contextOptions, options)); fCaps.reset(new GrMockCaps(contextOptions, options));
} }

View File

@ -20,7 +20,7 @@ class GrPipeline;
class GrMockGpu : public GrGpu { class GrMockGpu : public GrGpu {
public: public:
static sk_sp<GrGpu> Make(const GrMockOptions*, const GrContextOptions&, GrContext*); static sk_sp<GrGpu> Make(const GrMockOptions*, const GrContextOptions&, GrDirectContext*);
~GrMockGpu() override {} ~GrMockGpu() override {}
@ -57,7 +57,7 @@ public:
void checkFinishProcs() override {} void checkFinishProcs() override {}
private: private:
GrMockGpu(GrContext* context, const GrMockOptions&, const GrContextOptions&); GrMockGpu(GrDirectContext*, const GrMockOptions&, const GrContextOptions&);
void onResetContext(uint32_t resetBits) override {} void onResetContext(uint32_t resetBits) override {}

View File

@ -33,8 +33,8 @@ namespace SkSL {
class GrMtlGpu : public GrGpu { class GrMtlGpu : public GrGpu {
public: public:
static sk_sp<GrGpu> Make(GrContext* context, const GrContextOptions& options, static sk_sp<GrGpu> Make(GrDirectContext*, const GrContextOptions&,
id<MTLDevice> device, id<MTLCommandQueue> queue); id<MTLDevice>, id<MTLCommandQueue>);
~GrMtlGpu() override; ~GrMtlGpu() override;
void disconnect(DisconnectType) override; void disconnect(DisconnectType) override;
@ -117,8 +117,8 @@ public:
} }
private: private:
GrMtlGpu(GrContext* context, const GrContextOptions& options, GrMtlGpu(GrDirectContext*, const GrContextOptions&, id<MTLDevice>,
id<MTLDevice> device, id<MTLCommandQueue> queue, MTLFeatureSet featureSet); id<MTLCommandQueue>, MTLFeatureSet);
void destroyResources(); void destroyResources();

View File

@ -100,7 +100,7 @@ static bool get_feature_set(id<MTLDevice> device, MTLFeatureSet* featureSet) {
return false; return false;
} }
sk_sp<GrGpu> GrMtlGpu::Make(GrContext* context, const GrContextOptions& options, sk_sp<GrGpu> GrMtlGpu::Make(GrDirectContext* direct, const GrContextOptions& options,
id<MTLDevice> device, id<MTLCommandQueue> queue) { id<MTLDevice> device, id<MTLCommandQueue> queue) {
if (!device || !queue) { if (!device || !queue) {
return nullptr; return nullptr;
@ -109,12 +109,12 @@ sk_sp<GrGpu> GrMtlGpu::Make(GrContext* context, const GrContextOptions& options,
if (!get_feature_set(device, &featureSet)) { if (!get_feature_set(device, &featureSet)) {
return nullptr; return nullptr;
} }
return sk_sp<GrGpu>(new GrMtlGpu(context, options, device, queue, featureSet)); return sk_sp<GrGpu>(new GrMtlGpu(direct, options, device, queue, featureSet));
} }
GrMtlGpu::GrMtlGpu(GrContext* context, const GrContextOptions& options, GrMtlGpu::GrMtlGpu(GrDirectContext* direct, const GrContextOptions& options,
id<MTLDevice> device, id<MTLCommandQueue> queue, MTLFeatureSet featureSet) id<MTLDevice> device, id<MTLCommandQueue> queue, MTLFeatureSet featureSet)
: INHERITED(context) : INHERITED(direct)
, fDevice(device) , fDevice(device)
, fQueue(queue) , fQueue(queue)
, fCmdBuffer(nullptr) , fCmdBuffer(nullptr)

View File

@ -7,7 +7,7 @@
#include "src/gpu/mtl/GrMtlPipelineStateBuilder.h" #include "src/gpu/mtl/GrMtlPipelineStateBuilder.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "src/core/SkReadBuffer.h" #include "src/core/SkReadBuffer.h"
#include "src/core/SkTraceEvent.h" #include "src/core/SkTraceEvent.h"
#include "src/gpu/GrAutoLocaleSetter.h" #include "src/gpu/GrAutoLocaleSetter.h"

View File

@ -8,6 +8,7 @@
#include "src/gpu/mtl/GrMtlResourceProvider.h" #include "src/gpu/mtl/GrMtlResourceProvider.h"
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/mtl/GrMtlCommandBuffer.h" #include "src/gpu/mtl/GrMtlCommandBuffer.h"
#include "src/gpu/mtl/GrMtlGpu.h" #include "src/gpu/mtl/GrMtlGpu.h"

View File

@ -11,7 +11,7 @@
#include "include/core/SkRefCnt.h" #include "include/core/SkRefCnt.h"
#include "include/gpu/GrTypes.h" #include "include/gpu/GrTypes.h"
class GrContext; class GrDirectContext;
class GrGpu; class GrGpu;
struct GrContextOptions; struct GrContextOptions;
@ -21,7 +21,8 @@ struct GrContextOptions;
*/ */
class GrMtlTrampoline { class GrMtlTrampoline {
public: public:
static sk_sp<GrGpu> MakeGpu(GrContext*, const GrContextOptions&, void* device, void* queue); static sk_sp<GrGpu> MakeGpu(GrDirectContext*, const GrContextOptions&,
void* device, void* queue);
}; };
#endif #endif

View File

@ -13,11 +13,11 @@
#error This file must be compiled with Arc. Use -fobjc-arc flag #error This file must be compiled with Arc. Use -fobjc-arc flag
#endif #endif
sk_sp<GrGpu> GrMtlTrampoline::MakeGpu(GrContext* context, sk_sp<GrGpu> GrMtlTrampoline::MakeGpu(GrDirectContext* direct,
const GrContextOptions& options, const GrContextOptions& options,
void* device, void* device,
void* queue) { void* queue) {
return GrMtlGpu::Make(context, return GrMtlGpu::Make(direct,
options, options,
(__bridge id<MTLDevice>)device, (__bridge id<MTLDevice>)device,
(__bridge id<MTLCommandQueue>)queue); (__bridge id<MTLCommandQueue>)queue);

View File

@ -10,6 +10,7 @@
#include "include/gpu/GrBackendSemaphore.h" #include "include/gpu/GrBackendSemaphore.h"
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "include/private/SkTo.h" #include "include/private/SkTo.h"
#include "src/core/SkCompressedDataUtils.h" #include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkConvertPixels.h" #include "src/core/SkConvertPixels.h"
@ -63,7 +64,7 @@
#define VK_CALL_RET(RET, X) GR_VK_CALL_RESULT(this, RET, X) #define VK_CALL_RET(RET, X) GR_VK_CALL_RESULT(this, RET, X)
sk_sp<GrGpu> GrVkGpu::Make(const GrVkBackendContext& backendContext, sk_sp<GrGpu> GrVkGpu::Make(const GrVkBackendContext& backendContext,
const GrContextOptions& options, GrContext* context) { const GrContextOptions& options, GrDirectContext* direct) {
if (backendContext.fInstance == VK_NULL_HANDLE || if (backendContext.fInstance == VK_NULL_HANDLE ||
backendContext.fPhysicalDevice == VK_NULL_HANDLE || backendContext.fPhysicalDevice == VK_NULL_HANDLE ||
backendContext.fDevice == VK_NULL_HANDLE || backendContext.fDevice == VK_NULL_HANDLE ||
@ -153,7 +154,7 @@ sk_sp<GrGpu> GrVkGpu::Make(const GrVkBackendContext& backendContext,
return nullptr; return nullptr;
} }
sk_sp<GrVkGpu> vkGpu(new GrVkGpu(context, options, backendContext, interface, sk_sp<GrVkGpu> vkGpu(new GrVkGpu(direct, options, backendContext, interface,
instanceVersion, physDevVersion, instanceVersion, physDevVersion,
std::move(memoryAllocator))); std::move(memoryAllocator)));
if (backendContext.fProtectedContext == GrProtected::kYes && if (backendContext.fProtectedContext == GrProtected::kYes &&
@ -165,11 +166,11 @@ sk_sp<GrGpu> GrVkGpu::Make(const GrVkBackendContext& backendContext,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options, GrVkGpu::GrVkGpu(GrDirectContext* direct, const GrContextOptions& options,
const GrVkBackendContext& backendContext, sk_sp<const GrVkInterface> interface, const GrVkBackendContext& backendContext, sk_sp<const GrVkInterface> interface,
uint32_t instanceVersion, uint32_t physicalDeviceVersion, uint32_t instanceVersion, uint32_t physicalDeviceVersion,
sk_sp<GrVkMemoryAllocator> memoryAllocator) sk_sp<GrVkMemoryAllocator> memoryAllocator)
: INHERITED(context) : INHERITED(direct)
, fInterface(std::move(interface)) , fInterface(std::move(interface))
, fMemoryAllocator(std::move(memoryAllocator)) , fMemoryAllocator(std::move(memoryAllocator))
, fPhysicalDevice(backendContext.fPhysicalDevice) , fPhysicalDevice(backendContext.fPhysicalDevice)
@ -2031,7 +2032,7 @@ void GrVkGpu::addImageMemoryBarrier(const GrManagedResource* resource,
VkPipelineStageFlags dstStageMask, VkPipelineStageFlags dstStageMask,
bool byRegion, bool byRegion,
VkImageMemoryBarrier* barrier) const { VkImageMemoryBarrier* barrier) const {
// If we are in the middle of destroying or abandoning the GrContext we may hit a release proc // If we are in the middle of destroying or abandoning the context we may hit a release proc
// that triggers the destruction of a GrVkImage. This could cause us to try and transfer the // that triggers the destruction of a GrVkImage. This could cause us to try and transfer the
// VkImage back to the original queue. In this state we don't submit anymore work and we may not // VkImage back to the original queue. In this state we don't submit anymore work and we may not
// have a current command buffer. Thus we won't do the queue transfer. // have a current command buffer. Thus we won't do the queue transfer.

View File

@ -18,6 +18,7 @@
#include "src/gpu/vk/GrVkSemaphore.h" #include "src/gpu/vk/GrVkSemaphore.h"
#include "src/gpu/vk/GrVkUtil.h" #include "src/gpu/vk/GrVkUtil.h"
class GrDirectContext;
class GrPipeline; class GrPipeline;
class GrVkBufferImpl; class GrVkBufferImpl;
@ -38,7 +39,7 @@ namespace SkSL {
class GrVkGpu : public GrGpu { class GrVkGpu : public GrGpu {
public: public:
static sk_sp<GrGpu> Make(const GrVkBackendContext&, const GrContextOptions&, GrContext*); static sk_sp<GrGpu> Make(const GrVkBackendContext&, const GrContextOptions&, GrDirectContext*);
~GrVkGpu() override; ~GrVkGpu() override;
@ -178,7 +179,7 @@ private:
kSkip_SyncQueue kSkip_SyncQueue
}; };
GrVkGpu(GrContext*, const GrContextOptions&, const GrVkBackendContext&, GrVkGpu(GrDirectContext*, const GrContextOptions&, const GrVkBackendContext&,
sk_sp<const GrVkInterface>, uint32_t instanceVersion, uint32_t physicalDeviceVersion, sk_sp<const GrVkInterface>, uint32_t instanceVersion, uint32_t physicalDeviceVersion,
sk_sp<GrVkMemoryAllocator>); sk_sp<GrVkMemoryAllocator>);

View File

@ -5,7 +5,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "src/core/SkTraceEvent.h" #include "src/core/SkTraceEvent.h"
#include "src/gpu/GrAutoLocaleSetter.h" #include "src/gpu/GrAutoLocaleSetter.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"

View File

@ -7,6 +7,7 @@
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkOpts.h" #include "src/core/SkOpts.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrProcessor.h" #include "src/gpu/GrProcessor.h"

View File

@ -7,6 +7,7 @@
#include "src/gpu/vk/GrVkResourceProvider.h" #include "src/gpu/vk/GrVkResourceProvider.h"
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkTaskGroup.h" #include "src/core/SkTaskGroup.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrSamplerState.h" #include "src/gpu/GrSamplerState.h"

View File

@ -7,6 +7,7 @@
#include "src/gpu/vk/GrVkUtil.h" #include "src/gpu/vk/GrVkUtil.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrDataUtils.h" #include "src/gpu/GrDataUtils.h"
#include "src/gpu/vk/GrVkGpu.h" #include "src/gpu/vk/GrVkGpu.h"