From 3d0359a318abd02e32d0d8744ea8222eacfac312 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Thu, 9 Jul 2020 15:35:55 -0400 Subject: [PATCH] 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 Reviewed-by: Brian Salomon Reviewed-by: Robert Phillips --- samplecode/SampleCCPRGeometry.cpp | 2 +- src/gpu/GrBufferAllocPool.cpp | 2 +- src/gpu/GrDirectContext.cpp | 31 +++++++++++++--------- src/gpu/GrGpu.cpp | 4 +-- src/gpu/GrGpu.h | 23 ++++++++-------- src/gpu/GrGpuResource.cpp | 2 +- src/gpu/GrOpFlushState.cpp | 1 + src/gpu/d3d/GrD3DGpu.cpp | 8 +++--- src/gpu/d3d/GrD3DGpu.h | 4 +-- src/gpu/d3d/GrD3DPipelineStateBuilder.cpp | 2 +- src/gpu/d3d/GrD3DResourceProvider.cpp | 1 + src/gpu/dawn/GrDawnGpu.cpp | 9 ++++--- src/gpu/dawn/GrDawnGpu.h | 6 +++-- src/gpu/gl/GrGLGpu.cpp | 9 ++++--- src/gpu/gl/GrGLGpu.h | 4 +-- src/gpu/gl/GrGLGpuProgramCache.cpp | 1 + src/gpu/gl/GrGLRenderTarget.cpp | 2 +- src/gpu/gl/GrGLTextureRenderTarget.cpp | 2 +- src/gpu/gl/builders/GrGLProgramBuilder.cpp | 2 +- src/gpu/mock/GrMockGpu.cpp | 8 +++--- src/gpu/mock/GrMockGpu.h | 4 +-- src/gpu/mtl/GrMtlGpu.h | 8 +++--- src/gpu/mtl/GrMtlGpu.mm | 8 +++--- src/gpu/mtl/GrMtlPipelineStateBuilder.mm | 2 +- src/gpu/mtl/GrMtlResourceProvider.mm | 1 + src/gpu/mtl/GrMtlTrampoline.h | 5 ++-- src/gpu/mtl/GrMtlTrampoline.mm | 4 +-- src/gpu/vk/GrVkGpu.cpp | 11 ++++---- src/gpu/vk/GrVkGpu.h | 5 ++-- src/gpu/vk/GrVkPipelineStateBuilder.cpp | 2 +- src/gpu/vk/GrVkPipelineStateCache.cpp | 1 + src/gpu/vk/GrVkResourceProvider.cpp | 1 + src/gpu/vk/GrVkUtil.cpp | 1 + 33 files changed, 98 insertions(+), 78 deletions(-) diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp index 9df119e7e0..0bd2c09489 100644 --- a/samplecode/SampleCCPRGeometry.cpp +++ b/samplecode/SampleCCPRGeometry.cpp @@ -334,7 +334,7 @@ void CCPRGeometryView::updateGpuData() { void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) { GrResourceProvider* rp = state->resourceProvider(); - auto direct = GrAsDirectContext(state->gpu()->getContext()); + auto direct = state->gpu()->getContext(); #ifdef SK_GL GrGLGpu* glGpu = GrBackendApi::kOpenGL == direct->backend() ? static_cast(state->gpu()) diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp index e906caf329..fa1c8a26c5 100644 --- a/src/gpu/GrBufferAllocPool.cpp +++ b/src/gpu/GrBufferAllocPool.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ -#include "include/gpu/GrContext.h" +#include "include/gpu/GrDirectContext.h" #include "include/gpu/GrTypes.h" #include "include/private/SkMacros.h" #include "src/core/SkSafeMath.h" diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp index b6cc8afa1f..8bfb239f59 100644 --- a/src/gpu/GrDirectContext.cpp +++ b/src/gpu/GrDirectContext.cpp @@ -160,9 +160,10 @@ GrGLFunction make_get_error_with_random_oom(GrGLFunction sk_sp GrContext::MakeGL(sk_sp glInterface, const GrContextOptions& options) { - sk_sp context(new GrDirectContext(GrBackendApi::kOpenGL, options)); + auto direct = new GrDirectContext(GrBackendApi::kOpenGL, options); #if GR_TEST_UTILS if (options.fRandomGLOOM) { auto copy = sk_make_sp(*glInterface); @@ -175,7 +176,8 @@ sk_sp GrContext::MakeGL(sk_sp glInterface, glInterface = std::move(copy); } #endif - context->fGpu = GrGLGpu::Make(std::move(glInterface), options, context.get()); + direct->fGpu = GrGLGpu::Make(std::move(glInterface), options, direct); + sk_sp context(direct); if (!context->init()) { return nullptr; } @@ -190,9 +192,10 @@ sk_sp GrContext::MakeMock(const GrMockOptions* mockOptions) { sk_sp GrContext::MakeMock(const GrMockOptions* mockOptions, const GrContextOptions& options) { - sk_sp 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 context(direct); if (!context->init()) { return nullptr; } @@ -212,9 +215,10 @@ sk_sp GrContext::MakeVulkan(const GrVkBackendContext& backendContext) sk_sp GrContext::MakeVulkan(const GrVkBackendContext& backendContext, const GrContextOptions& options) { #ifdef SK_VULKAN - sk_sp 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 context(direct); if (!context->init()) { return nullptr; } @@ -232,9 +236,10 @@ sk_sp GrContext::MakeMetal(void* device, void* queue) { } sk_sp GrContext::MakeMetal(void* device, void* queue, const GrContextOptions& options) { - sk_sp 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 context(direct); if (!context->init()) { return nullptr; } @@ -251,9 +256,10 @@ sk_sp GrContext::MakeDirect3D(const GrD3DBackendContext& backendConte sk_sp GrContext::MakeDirect3D(const GrD3DBackendContext& backendContext, const GrContextOptions& options) { - sk_sp 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 context(direct); if (!context->init()) { return nullptr; } @@ -269,9 +275,10 @@ sk_sp GrContext::MakeDawn(const wgpu::Device& device) { } sk_sp GrContext::MakeDawn(const wgpu::Device& device, const GrContextOptions& options) { - sk_sp 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 context(direct); if (!context->init()) { return nullptr; } diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 89939980ab..a38a51a346 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -10,7 +10,7 @@ #include "include/gpu/GrBackendSemaphore.h" #include "include/gpu/GrBackendSurface.h" -#include "include/gpu/GrContext.h" +#include "include/gpu/GrDirectContext.h" #include "src/core/SkCompressedDataUtils.h" #include "src/core/SkMathPriv.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() { this->callSubmittedProcs(false); diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index d5cae7da71..f793a93c62 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -20,12 +20,11 @@ #include "src/gpu/GrSwizzle.h" #include "src/gpu/GrTextureProducer.h" #include "src/gpu/GrXferProcessor.h" -#include class GrBackendRenderTarget; class GrBackendSemaphore; +class GrDirectContext; class GrGpuBuffer; -class GrContext; struct GrContextOptions; class GrGLContext; class GrPath; @@ -44,11 +43,11 @@ class SkJSONWriter; class GrGpu : public SkRefCnt { public: - GrGpu(GrContext* context); + GrGpu(GrDirectContext* direct); ~GrGpu() override; - GrContext* getContext() { return fContext; } - const GrContext* getContext() const { return fContext; } + GrDirectContext* getContext() { return fContext; } + const GrDirectContext* getContext() const { return fContext; } /** * Gets the capabilities of the draw target. @@ -66,12 +65,12 @@ public: kCleanup, }; - // Called by GrContext when the underlying backend context is already or will be destroyed - // before GrContext. + // Called by context when the underlying backend context is already or will be destroyed + // before GrDirectContext. virtual void disconnect(DisconnectType); - // Called by GrContext::isContextLost. Returns true if the backend Gpu object has gotten into an - // unrecoverable, lost state. + // Called by GrDirectContext::isContextLost. Returns true if the backend Gpu object has gotten + // into an unrecoverable, lost state. virtual bool isDeviceLost() const { return false; } /** @@ -390,7 +389,7 @@ public: 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 * semaphore before using this texture. */ @@ -636,7 +635,7 @@ public: /** * 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; @@ -868,7 +867,7 @@ private: uint32_t fResetBits; // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. - GrContext* fContext; + GrDirectContext* fContext; GrSamplePatternDictionary fSamplePatternDictionary; std::vector> fStagingBuffers; diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp index e8a9af2406..42fd8580ad 100644 --- a/src/gpu/GrGpuResource.cpp +++ b/src/gpu/GrGpuResource.cpp @@ -6,7 +6,7 @@ */ #include "include/core/SkTraceMemoryDump.h" -#include "include/gpu/GrContext.h" +#include "include/gpu/GrDirectContext.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrGpu.h" #include "src/gpu/GrGpuResource.h" diff --git a/src/gpu/GrOpFlushState.cpp b/src/gpu/GrOpFlushState.cpp index 8bc88f0d09..5e4a602689 100644 --- a/src/gpu/GrOpFlushState.cpp +++ b/src/gpu/GrOpFlushState.cpp @@ -7,6 +7,7 @@ #include "src/gpu/GrOpFlushState.h" +#include "include/gpu/GrDirectContext.h" #include "src/core/SkConvertPixels.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrDataUtils.h" diff --git a/src/gpu/d3d/GrD3DGpu.cpp b/src/gpu/d3d/GrD3DGpu.cpp index a2112c2f0b..809ff1169d 100644 --- a/src/gpu/d3d/GrD3DGpu.cpp +++ b/src/gpu/d3d/GrD3DGpu.cpp @@ -29,8 +29,8 @@ #endif sk_sp GrD3DGpu::Make(const GrD3DBackendContext& backendContext, - const GrContextOptions& contextOptions, GrContext* context) { - return sk_sp(new GrD3DGpu(context, contextOptions, backendContext)); + const GrContextOptions& contextOptions, GrDirectContext* direct) { + return sk_sp(new GrD3DGpu(direct, contextOptions, backendContext)); } // This constant determines how many OutstandingCommandLists are allocated together as a block in @@ -39,9 +39,9 @@ sk_sp GrD3DGpu::Make(const GrD3DBackendContext& backendContext, // command lists we expect to see. static const int kDefaultOutstandingAllocCnt = 8; -GrD3DGpu::GrD3DGpu(GrContext* context, const GrContextOptions& contextOptions, +GrD3DGpu::GrD3DGpu(GrDirectContext* direct, const GrContextOptions& contextOptions, const GrD3DBackendContext& backendContext) - : INHERITED(context) + : INHERITED(direct) , fDevice(backendContext.fDevice) , fQueue(backendContext.fQueue) diff --git a/src/gpu/d3d/GrD3DGpu.h b/src/gpu/d3d/GrD3DGpu.h index eb1f73fa7e..ab60be0264 100644 --- a/src/gpu/d3d/GrD3DGpu.h +++ b/src/gpu/d3d/GrD3DGpu.h @@ -31,7 +31,7 @@ namespace SkSL { class GrD3DGpu : public GrGpu { public: static sk_sp Make(const GrD3DBackendContext& backendContext, const GrContextOptions&, - GrContext*); + GrDirectContext*); ~GrD3DGpu() override; @@ -113,7 +113,7 @@ private: kSkip }; - GrD3DGpu(GrContext* context, const GrContextOptions&, const GrD3DBackendContext&); + GrD3DGpu(GrDirectContext*, const GrContextOptions&, const GrD3DBackendContext&); void destroyResources(); diff --git a/src/gpu/d3d/GrD3DPipelineStateBuilder.cpp b/src/gpu/d3d/GrD3DPipelineStateBuilder.cpp index 3a987b188c..f1bbb60d09 100644 --- a/src/gpu/d3d/GrD3DPipelineStateBuilder.cpp +++ b/src/gpu/d3d/GrD3DPipelineStateBuilder.cpp @@ -9,7 +9,7 @@ #include "src/gpu/d3d/GrD3DPipelineStateBuilder.h" -#include "include/gpu/GrContext.h" +#include "include/gpu/GrDirectContext.h" #include "include/gpu/d3d/GrD3DTypes.h" #include "src/core/SkTraceEvent.h" #include "src/gpu/GrAutoLocaleSetter.h" diff --git a/src/gpu/d3d/GrD3DResourceProvider.cpp b/src/gpu/d3d/GrD3DResourceProvider.cpp index c933743e35..37ea657bfc 100644 --- a/src/gpu/d3d/GrD3DResourceProvider.cpp +++ b/src/gpu/d3d/GrD3DResourceProvider.cpp @@ -8,6 +8,7 @@ #include "src/gpu/d3d/GrD3DResourceProvider.h" #include "include/gpu/GrContextOptions.h" +#include "include/gpu/GrDirectContext.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/d3d/GrD3DBuffer.h" #include "src/gpu/d3d/GrD3DCommandList.h" diff --git a/src/gpu/dawn/GrDawnGpu.cpp b/src/gpu/dawn/GrDawnGpu.cpp index f35a2e7e63..59c09511ef 100644 --- a/src/gpu/dawn/GrDawnGpu.cpp +++ b/src/gpu/dawn/GrDawnGpu.cpp @@ -10,6 +10,7 @@ #include "include/gpu/GrBackendSemaphore.h" #include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrContextOptions.h" +#include "include/gpu/GrDirectContext.h" #include "src/gpu/GrDataUtils.h" #include "src/gpu/GrGeometryProcessor.h" #include "src/gpu/GrGpuResourceCacheAccess.h" @@ -96,19 +97,19 @@ static wgpu::AddressMode to_dawn_address_mode(GrSamplerState::WrapMode wrapMode) } sk_sp GrDawnGpu::Make(const wgpu::Device& device, - const GrContextOptions& options, GrContext* context) { + const GrContextOptions& options, GrDirectContext* direct) { if (!device) { return nullptr; } - return sk_sp(new GrDawnGpu(context, options, device)); + return sk_sp(new GrDawnGpu(direct, options, device)); } //////////////////////////////////////////////////////////////////////////////// -GrDawnGpu::GrDawnGpu(GrContext* context, const GrContextOptions& options, +GrDawnGpu::GrDawnGpu(GrDirectContext* direct, const GrContextOptions& options, const wgpu::Device& device) - : INHERITED(context) + : INHERITED(direct) , fDevice(device) , fQueue(device.GetDefaultQueue()) , fCompiler(new SkSL::Compiler()) diff --git a/src/gpu/dawn/GrDawnGpu.h b/src/gpu/dawn/GrDawnGpu.h index 29e64b29bb..282ddc44f9 100644 --- a/src/gpu/dawn/GrDawnGpu.h +++ b/src/gpu/dawn/GrDawnGpu.h @@ -20,6 +20,7 @@ class GrDawnOpsRenderPass; class GrDawnStagingBuffer; +class GrDirectContext; class GrPipeline; struct GrDawnProgram; @@ -29,8 +30,7 @@ namespace SkSL { class GrDawnGpu : public GrGpu { public: - static sk_sp Make(const wgpu::Device& device, const GrContextOptions&, GrContext*); - GrDawnGpu(GrContext* context, const GrContextOptions& options, const wgpu::Device& device); + static sk_sp Make(const wgpu::Device&, const GrContextOptions&, GrDirectContext*); ~GrDawnGpu() override; @@ -98,6 +98,8 @@ public: void appendCommandBuffer(wgpu::CommandBuffer commandBuffer); private: + GrDawnGpu(GrDirectContext*, const GrContextOptions&, const wgpu::Device&); + void onResetContext(uint32_t resetBits) override {} virtual void querySampleLocations(GrRenderTarget*, SkTArray*) override {} diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 1a88ad027d..6820f76576 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -10,6 +10,7 @@ #include "include/core/SkTypes.h" #include "include/gpu/GrBackendSemaphore.h" #include "include/gpu/GrBackendSurface.h" +#include "include/gpu/GrDirectContext.h" #include "include/gpu/GrTypes.h" #include "include/private/SkHalf.h" #include "include/private/SkTemplates.h" @@ -301,7 +302,7 @@ private: /////////////////////////////////////////////////////////////////////////////// sk_sp GrGLGpu::Make(sk_sp interface, const GrContextOptions& options, - GrContext* context) { + GrDirectContext* direct) { if (!interface) { interface = GrGLMakeNativeInterface(); // For clients that have written their own GrGLCreateNativeInterface and haven't yet updated @@ -320,11 +321,11 @@ sk_sp GrGLGpu::Make(sk_sp interface, const GrContext if (!glContext) { return nullptr; } - return sk_sp(new GrGLGpu(std::move(glContext), context)); + return sk_sp(new GrGLGpu(std::move(glContext), direct)); } -GrGLGpu::GrGLGpu(std::unique_ptr ctx, GrContext* context) - : GrGpu(context) +GrGLGpu::GrGLGpu(std::unique_ptr ctx, GrDirectContext* direct) + : GrGpu(direct) , fGLContext(std::move(ctx)) , fProgramCache(new ProgramCache(this)) , fHWProgramID(0) diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 6172b1bef8..1305780028 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -32,7 +32,7 @@ class GrSwizzle; class GrGLGpu final : public GrGpu { public: - static sk_sp Make(sk_sp, const GrContextOptions&, GrContext*); + static sk_sp Make(sk_sp, const GrContextOptions&, GrDirectContext*); ~GrGLGpu() override; void disconnect(DisconnectType) override; @@ -189,7 +189,7 @@ public: void flushProgram(GrGLuint); private: - GrGLGpu(std::unique_ptr, GrContext*); + GrGLGpu(std::unique_ptr, GrDirectContext*); // GrGpu overrides GrBackendTexture onCreateBackendTexture(SkISize dimensions, diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp index bf54a88398..dab80f04a4 100644 --- a/src/gpu/gl/GrGLGpuProgramCache.cpp +++ b/src/gpu/gl/GrGLGpuProgramCache.cpp @@ -8,6 +8,7 @@ #include "src/gpu/gl/GrGLGpu.h" #include "include/gpu/GrContextOptions.h" +#include "include/gpu/GrDirectContext.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrProcessor.h" #include "src/gpu/GrProgramDesc.h" diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index 95508ef6c0..5a82c9eeea 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -6,7 +6,7 @@ */ #include "include/core/SkTraceMemoryDump.h" -#include "include/gpu/GrContext.h" +#include "include/gpu/GrDirectContext.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrGpuResourcePriv.h" #include "src/gpu/GrRenderTargetPriv.h" diff --git a/src/gpu/gl/GrGLTextureRenderTarget.cpp b/src/gpu/gl/GrGLTextureRenderTarget.cpp index 434c0389bc..2747f298f7 100644 --- a/src/gpu/gl/GrGLTextureRenderTarget.cpp +++ b/src/gpu/gl/GrGLTextureRenderTarget.cpp @@ -6,7 +6,7 @@ */ #include "include/core/SkTraceMemoryDump.h" -#include "include/gpu/GrContext.h" +#include "include/gpu/GrDirectContext.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrTexturePriv.h" #include "src/gpu/gl/GrGLGpu.h" diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index b50fc304f9..7a152caf03 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -7,7 +7,7 @@ #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/SkAutoMalloc.h" #include "src/core/SkReadBuffer.h" diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp index ccd1157cf8..3890ce4708 100644 --- a/src/gpu/mock/GrMockGpu.cpp +++ b/src/gpu/mock/GrMockGpu.cpp @@ -44,12 +44,12 @@ int GrMockGpu::NextExternalRenderTargetID() { } sk_sp GrMockGpu::Make(const GrMockOptions* mockOptions, - const GrContextOptions& contextOptions, GrContext* context) { + const GrContextOptions& contextOptions, GrDirectContext* direct) { static const GrMockOptions kDefaultOptions = GrMockOptions(); if (!mockOptions) { mockOptions = &kDefaultOptions; } - return sk_sp(new GrMockGpu(context, *mockOptions, contextOptions)); + return sk_sp(new GrMockGpu(direct, *mockOptions, contextOptions)); } GrOpsRenderPass* GrMockGpu::getOpsRenderPass( @@ -68,9 +68,9 @@ void GrMockGpu::submit(GrOpsRenderPass* renderPass) { delete renderPass; } -GrMockGpu::GrMockGpu(GrContext* context, const GrMockOptions& options, +GrMockGpu::GrMockGpu(GrDirectContext* direct, const GrMockOptions& options, const GrContextOptions& contextOptions) - : INHERITED(context) + : INHERITED(direct) , fMockOptions(options) { fCaps.reset(new GrMockCaps(contextOptions, options)); } diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h index f663e3e4a4..0abebfca56 100644 --- a/src/gpu/mock/GrMockGpu.h +++ b/src/gpu/mock/GrMockGpu.h @@ -20,7 +20,7 @@ class GrPipeline; class GrMockGpu : public GrGpu { public: - static sk_sp Make(const GrMockOptions*, const GrContextOptions&, GrContext*); + static sk_sp Make(const GrMockOptions*, const GrContextOptions&, GrDirectContext*); ~GrMockGpu() override {} @@ -57,7 +57,7 @@ public: void checkFinishProcs() override {} private: - GrMockGpu(GrContext* context, const GrMockOptions&, const GrContextOptions&); + GrMockGpu(GrDirectContext*, const GrMockOptions&, const GrContextOptions&); void onResetContext(uint32_t resetBits) override {} diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h index b31d5d0640..4bfd6d33c8 100644 --- a/src/gpu/mtl/GrMtlGpu.h +++ b/src/gpu/mtl/GrMtlGpu.h @@ -33,8 +33,8 @@ namespace SkSL { class GrMtlGpu : public GrGpu { public: - static sk_sp Make(GrContext* context, const GrContextOptions& options, - id device, id queue); + static sk_sp Make(GrDirectContext*, const GrContextOptions&, + id, id); ~GrMtlGpu() override; void disconnect(DisconnectType) override; @@ -117,8 +117,8 @@ public: } private: - GrMtlGpu(GrContext* context, const GrContextOptions& options, - id device, id queue, MTLFeatureSet featureSet); + GrMtlGpu(GrDirectContext*, const GrContextOptions&, id, + id, MTLFeatureSet); void destroyResources(); diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm index b4ac162e46..7c188bf834 100644 --- a/src/gpu/mtl/GrMtlGpu.mm +++ b/src/gpu/mtl/GrMtlGpu.mm @@ -100,7 +100,7 @@ static bool get_feature_set(id device, MTLFeatureSet* featureSet) { return false; } -sk_sp GrMtlGpu::Make(GrContext* context, const GrContextOptions& options, +sk_sp GrMtlGpu::Make(GrDirectContext* direct, const GrContextOptions& options, id device, id queue) { if (!device || !queue) { return nullptr; @@ -109,12 +109,12 @@ sk_sp GrMtlGpu::Make(GrContext* context, const GrContextOptions& options, if (!get_feature_set(device, &featureSet)) { return nullptr; } - return sk_sp(new GrMtlGpu(context, options, device, queue, featureSet)); + return sk_sp(new GrMtlGpu(direct, options, device, queue, featureSet)); } -GrMtlGpu::GrMtlGpu(GrContext* context, const GrContextOptions& options, +GrMtlGpu::GrMtlGpu(GrDirectContext* direct, const GrContextOptions& options, id device, id queue, MTLFeatureSet featureSet) - : INHERITED(context) + : INHERITED(direct) , fDevice(device) , fQueue(queue) , fCmdBuffer(nullptr) diff --git a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm index 0f93d15b20..90109909e5 100644 --- a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm +++ b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm @@ -7,7 +7,7 @@ #include "src/gpu/mtl/GrMtlPipelineStateBuilder.h" -#include "include/gpu/GrContext.h" +#include "include/gpu/GrDirectContext.h" #include "src/core/SkReadBuffer.h" #include "src/core/SkTraceEvent.h" #include "src/gpu/GrAutoLocaleSetter.h" diff --git a/src/gpu/mtl/GrMtlResourceProvider.mm b/src/gpu/mtl/GrMtlResourceProvider.mm index f8040b3646..2ea438e95e 100644 --- a/src/gpu/mtl/GrMtlResourceProvider.mm +++ b/src/gpu/mtl/GrMtlResourceProvider.mm @@ -8,6 +8,7 @@ #include "src/gpu/mtl/GrMtlResourceProvider.h" #include "include/gpu/GrContextOptions.h" +#include "include/gpu/GrDirectContext.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/mtl/GrMtlCommandBuffer.h" #include "src/gpu/mtl/GrMtlGpu.h" diff --git a/src/gpu/mtl/GrMtlTrampoline.h b/src/gpu/mtl/GrMtlTrampoline.h index ac0cd61e9e..7ddb105c1b 100644 --- a/src/gpu/mtl/GrMtlTrampoline.h +++ b/src/gpu/mtl/GrMtlTrampoline.h @@ -11,7 +11,7 @@ #include "include/core/SkRefCnt.h" #include "include/gpu/GrTypes.h" -class GrContext; +class GrDirectContext; class GrGpu; struct GrContextOptions; @@ -21,7 +21,8 @@ struct GrContextOptions; */ class GrMtlTrampoline { public: - static sk_sp MakeGpu(GrContext*, const GrContextOptions&, void* device, void* queue); + static sk_sp MakeGpu(GrDirectContext*, const GrContextOptions&, + void* device, void* queue); }; #endif diff --git a/src/gpu/mtl/GrMtlTrampoline.mm b/src/gpu/mtl/GrMtlTrampoline.mm index 85f67b061c..46f64aee1b 100644 --- a/src/gpu/mtl/GrMtlTrampoline.mm +++ b/src/gpu/mtl/GrMtlTrampoline.mm @@ -13,11 +13,11 @@ #error This file must be compiled with Arc. Use -fobjc-arc flag #endif -sk_sp GrMtlTrampoline::MakeGpu(GrContext* context, +sk_sp GrMtlTrampoline::MakeGpu(GrDirectContext* direct, const GrContextOptions& options, void* device, void* queue) { - return GrMtlGpu::Make(context, + return GrMtlGpu::Make(direct, options, (__bridge id)device, (__bridge id)queue); diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 0d81a5aafd..d66490ed67 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -10,6 +10,7 @@ #include "include/gpu/GrBackendSemaphore.h" #include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrContextOptions.h" +#include "include/gpu/GrDirectContext.h" #include "include/private/SkTo.h" #include "src/core/SkCompressedDataUtils.h" #include "src/core/SkConvertPixels.h" @@ -63,7 +64,7 @@ #define VK_CALL_RET(RET, X) GR_VK_CALL_RESULT(this, RET, X) sk_sp GrVkGpu::Make(const GrVkBackendContext& backendContext, - const GrContextOptions& options, GrContext* context) { + const GrContextOptions& options, GrDirectContext* direct) { if (backendContext.fInstance == VK_NULL_HANDLE || backendContext.fPhysicalDevice == VK_NULL_HANDLE || backendContext.fDevice == VK_NULL_HANDLE || @@ -153,7 +154,7 @@ sk_sp GrVkGpu::Make(const GrVkBackendContext& backendContext, return nullptr; } - sk_sp vkGpu(new GrVkGpu(context, options, backendContext, interface, + sk_sp vkGpu(new GrVkGpu(direct, options, backendContext, interface, instanceVersion, physDevVersion, std::move(memoryAllocator))); if (backendContext.fProtectedContext == GrProtected::kYes && @@ -165,11 +166,11 @@ sk_sp GrVkGpu::Make(const GrVkBackendContext& backendContext, //////////////////////////////////////////////////////////////////////////////// -GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options, +GrVkGpu::GrVkGpu(GrDirectContext* direct, const GrContextOptions& options, const GrVkBackendContext& backendContext, sk_sp interface, uint32_t instanceVersion, uint32_t physicalDeviceVersion, sk_sp memoryAllocator) - : INHERITED(context) + : INHERITED(direct) , fInterface(std::move(interface)) , fMemoryAllocator(std::move(memoryAllocator)) , fPhysicalDevice(backendContext.fPhysicalDevice) @@ -2031,7 +2032,7 @@ void GrVkGpu::addImageMemoryBarrier(const GrManagedResource* resource, VkPipelineStageFlags dstStageMask, bool byRegion, 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 // 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. diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h index ec9134b5b5..d88746f2b8 100644 --- a/src/gpu/vk/GrVkGpu.h +++ b/src/gpu/vk/GrVkGpu.h @@ -18,6 +18,7 @@ #include "src/gpu/vk/GrVkSemaphore.h" #include "src/gpu/vk/GrVkUtil.h" +class GrDirectContext; class GrPipeline; class GrVkBufferImpl; @@ -38,7 +39,7 @@ namespace SkSL { class GrVkGpu : public GrGpu { public: - static sk_sp Make(const GrVkBackendContext&, const GrContextOptions&, GrContext*); + static sk_sp Make(const GrVkBackendContext&, const GrContextOptions&, GrDirectContext*); ~GrVkGpu() override; @@ -178,7 +179,7 @@ private: kSkip_SyncQueue }; - GrVkGpu(GrContext*, const GrContextOptions&, const GrVkBackendContext&, + GrVkGpu(GrDirectContext*, const GrContextOptions&, const GrVkBackendContext&, sk_sp, uint32_t instanceVersion, uint32_t physicalDeviceVersion, sk_sp); diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.cpp b/src/gpu/vk/GrVkPipelineStateBuilder.cpp index 7ccecc2ba6..1023b2dcee 100644 --- a/src/gpu/vk/GrVkPipelineStateBuilder.cpp +++ b/src/gpu/vk/GrVkPipelineStateBuilder.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ -#include "include/gpu/GrContext.h" +#include "include/gpu/GrDirectContext.h" #include "src/core/SkTraceEvent.h" #include "src/gpu/GrAutoLocaleSetter.h" #include "src/gpu/GrContextPriv.h" diff --git a/src/gpu/vk/GrVkPipelineStateCache.cpp b/src/gpu/vk/GrVkPipelineStateCache.cpp index 6297ffc0e1..ea7fc3474d 100644 --- a/src/gpu/vk/GrVkPipelineStateCache.cpp +++ b/src/gpu/vk/GrVkPipelineStateCache.cpp @@ -7,6 +7,7 @@ #include "include/gpu/GrContextOptions.h" +#include "include/gpu/GrDirectContext.h" #include "src/core/SkOpts.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrProcessor.h" diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp index e5c2785335..290a3e5dda 100644 --- a/src/gpu/vk/GrVkResourceProvider.cpp +++ b/src/gpu/vk/GrVkResourceProvider.cpp @@ -7,6 +7,7 @@ #include "src/gpu/vk/GrVkResourceProvider.h" +#include "include/gpu/GrDirectContext.h" #include "src/core/SkTaskGroup.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrSamplerState.h" diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp index 892d605583..5d1e05342b 100644 --- a/src/gpu/vk/GrVkUtil.cpp +++ b/src/gpu/vk/GrVkUtil.cpp @@ -7,6 +7,7 @@ #include "src/gpu/vk/GrVkUtil.h" +#include "include/gpu/GrDirectContext.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrDataUtils.h" #include "src/gpu/vk/GrVkGpu.h"