diff options
-rw-r--r-- | src/gpu/GrGpu.h | 10 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 9 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 2 | ||||
-rw-r--r-- | src/gpu/mock/GrMockGpu.cpp | 2 | ||||
-rw-r--r-- | src/gpu/mock/GrMockGpu.h | 2 | ||||
-rw-r--r-- | src/gpu/mtl/GrMtlGpu.h | 2 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 6 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.h | 2 | ||||
-rw-r--r-- | tests/ResourceCacheTest.cpp | 8 | ||||
-rw-r--r-- | tests/VkWrapTests.cpp | 4 |
10 files changed, 21 insertions, 26 deletions
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index dc518cd72d..e7e4ac087f 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -464,11 +464,11 @@ public: GrMipMapped mipMapped) = 0; /** Check a handle represents an actual texture in the backend API that has not been freed. */ virtual bool isTestingOnlyBackendTexture(const GrBackendTexture&) const = 0; - /** If ownership of the backend texture has been transferred pass true for abandonTexture. This - will do any necessary cleanup of the handle without freeing the texture in the backend - API. */ - virtual void deleteTestingOnlyBackendTexture(GrBackendTexture*, - bool abandonTexture = false) = 0; + /** + * Frees a texture created by createTestingOnlyBackendTexture(). If ownership of the backend + * texture has been transferred to a GrContext using adopt semantics this should not be called. + */ + virtual void deleteTestingOnlyBackendTexture(GrBackendTexture*) = 0; // width and height may be larger than rt (if underlying API allows it). // Returns nullptr if compatible sb could not be created, otherwise the caller owns the ref on diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 97aa4ac03a..ea7be0ef93 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4428,14 +4428,11 @@ bool GrGLGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const { return (GR_GL_TRUE == result); } -void GrGLGpu::deleteTestingOnlyBackendTexture(GrBackendTexture* tex, bool abandonTexture) { +void GrGLGpu::deleteTestingOnlyBackendTexture(GrBackendTexture* tex) { SkASSERT(kOpenGL_GrBackend == tex->backend()); - const GrGLTextureInfo* info = tex->getGLTextureInfo(); - if (info && !abandonTexture) { - GrGLuint texID = info->fID; - - GL_CALL(DeleteTextures(1, &texID)); + if (const auto* info = tex->getGLTextureInfo()) { + GL_CALL(DeleteTextures(1, &info->fID)); } } diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index a62c7153fe..6b193993bc 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -154,7 +154,7 @@ public: bool isRenderTarget, GrMipMapped mipMapped) override; bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override; - void deleteTestingOnlyBackendTexture(GrBackendTexture*, bool abandonTexture = false) override; + void deleteTestingOnlyBackendTexture(GrBackendTexture*) override; void resetShaderCacheForTesting() const override; diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp index 3a6b661ece..05371b42e6 100644 --- a/src/gpu/mock/GrMockGpu.cpp +++ b/src/gpu/mock/GrMockGpu.cpp @@ -113,7 +113,7 @@ bool GrMockGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const { return fOutstandingTestingOnlyTextureIDs.contains(info->fID); } -void GrMockGpu::deleteTestingOnlyBackendTexture(GrBackendTexture* tex, bool abandonTexture) { +void GrMockGpu::deleteTestingOnlyBackendTexture(GrBackendTexture* tex) { SkASSERT(kMock_GrBackend == tex->backend()); const GrMockTextureInfo* info = tex->getMockTextureInfo(); diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h index b5398e54b3..14cbd7979f 100644 --- a/src/gpu/mock/GrMockGpu.h +++ b/src/gpu/mock/GrMockGpu.h @@ -124,7 +124,7 @@ private: GrBackendTexture createTestingOnlyBackendTexture(void* pixels, int w, int h, GrPixelConfig, bool isRT, GrMipMapped) override; bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override; - void deleteTestingOnlyBackendTexture(GrBackendTexture*, bool abandonTexture = false) override; + void deleteTestingOnlyBackendTexture(GrBackendTexture*) override; static int NextInternalTextureID(); static int NextExternalTextureID(); diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h index a48618b868..fd190e28fa 100644 --- a/src/gpu/mtl/GrMtlGpu.h +++ b/src/gpu/mtl/GrMtlGpu.h @@ -144,7 +144,7 @@ private: return GrBackendTexture(); } bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override { return false; } - void deleteTestingOnlyBackendTexture(GrBackendTexture*, bool abandon = false) override {} + void deleteTestingOnlyBackendTexture(GrBackendTexture*) override {} sk_sp<GrMtlCaps> fMtlCaps; diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index a53432c25f..3a81eed350 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -1536,12 +1536,10 @@ bool GrVkGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const { return false; } -void GrVkGpu::deleteTestingOnlyBackendTexture(GrBackendTexture* tex, bool abandon) { +void GrVkGpu::deleteTestingOnlyBackendTexture(GrBackendTexture* tex) { SkASSERT(kVulkan_GrBackend == tex->fBackend); - const GrVkImageInfo* info = tex->getVkImageInfo(); - - if (info && !abandon) { + if (const auto* info = tex->getVkImageInfo()) { // something in the command buffer may still be using this, so force submit this->submitCommandBuffer(kForce_SyncQueue); GrVkImage::DestroyImageInfo(this, const_cast<GrVkImageInfo*>(info)); diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h index 36555272a0..7616fccefe 100644 --- a/src/gpu/vk/GrVkGpu.h +++ b/src/gpu/vk/GrVkGpu.h @@ -74,7 +74,7 @@ public: bool isRenderTarget, GrMipMapped) override; bool isTestingOnlyBackendTexture(const GrBackendTexture&) const override; - void deleteTestingOnlyBackendTexture(GrBackendTexture*, bool abandonTexture = false) override; + void deleteTestingOnlyBackendTexture(GrBackendTexture*) override; GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*, int width, diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index 2ceb567688..a88c06270d 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -245,8 +245,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI REPORTER_ASSERT(reporter, borrowedIsAlive); REPORTER_ASSERT(reporter, !adoptedIsAlive); - gpu->deleteTestingOnlyBackendTexture(&(backendTextures[0]), !borrowedIsAlive); - gpu->deleteTestingOnlyBackendTexture(&(backendTextures[1]), !adoptedIsAlive); + if (borrowedIsAlive) { + gpu->deleteTestingOnlyBackendTexture(&(backendTextures[0])); + } + if (adoptedIsAlive) { + gpu->deleteTestingOnlyBackendTexture(&(backendTextures[1])); + } context->resetContext(); } diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp index bcf59d222e..2f52972903 100644 --- a/tests/VkWrapTests.cpp +++ b/tests/VkWrapTests.cpp @@ -71,8 +71,6 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) { REPORTER_ASSERT(reporter, tex); } - - gpu->deleteTestingOnlyBackendTexture(&origBackendTex, true); } void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) { @@ -153,8 +151,6 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) { tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership); REPORTER_ASSERT(reporter, tex); } - - gpu->deleteTestingOnlyBackendTexture(&origBackendTex, true); } DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkWrapTests, reporter, ctxInfo) { |