From d21b2a5d5c5dca87b7df02713782e722a2c0ae92 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 12 Dec 2017 13:01:25 -0500 Subject: Remove GrBackendObject from tests (except image_from_yuv_textures) This sets the stage for landing https://skia-review.googlesource.com/c/skia/+/82823 (Update SkImage::MakeFromYUVTexturesCopy to GrBackendTexture) Change-Id: I2c62f23dc447b9ad55c0b5f06bcd6d7ca0ec4d2b Reviewed-on: https://skia-review.googlesource.com/83920 Reviewed-by: Greg Daniel Commit-Queue: Robert Phillips --- tests/VkWrapTests.cpp | 150 ++++++++++++++++++++++++++++---------------------- 1 file changed, 84 insertions(+), 66 deletions(-) (limited to 'tests/VkWrapTests.cpp') diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp index 07b82a8a2d..cf28586196 100644 --- a/tests/VkWrapTests.cpp +++ b/tests/VkWrapTests.cpp @@ -32,110 +32,128 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) { GrVkGpu* gpu = static_cast(context->getGpu()); - GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig, - false, GrMipMapped::kNo); - const GrVkImageInfo* imageInfo = reinterpret_cast(backendObj); + GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, + kPixelConfig, false, + GrMipMapped::kNo); + const GrVkImageInfo* imageInfo = origBackendTex.getVkImageInfo(); - GrBackendTexture backendTex = GrBackendTexture(kW, kH, *imageInfo); - sk_sp tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership); + sk_sp tex = gpu->wrapBackendTexture(origBackendTex, kBorrow_GrWrapOwnership); REPORTER_ASSERT(reporter, tex); // image is null - GrVkImageInfo backendCopy = *imageInfo; - backendCopy.fImage = VK_NULL_HANDLE; - backendTex = GrBackendTexture(kW, kH, backendCopy); - tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership); - REPORTER_ASSERT(reporter, !tex); - tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership); - REPORTER_ASSERT(reporter, !tex); + { + GrVkImageInfo backendCopy = *imageInfo; + backendCopy.fImage = VK_NULL_HANDLE; + GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy); + tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership); + REPORTER_ASSERT(reporter, !tex); + tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership); + REPORTER_ASSERT(reporter, !tex); + } // alloc is null - backendCopy.fImage = imageInfo->fImage; - backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 }; - backendTex = GrBackendTexture(kW, kH, backendCopy); - tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership); - REPORTER_ASSERT(reporter, !tex); - tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership); - REPORTER_ASSERT(reporter, !tex); + { + GrVkImageInfo backendCopy = *imageInfo; + backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 }; + GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy); + tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership); + REPORTER_ASSERT(reporter, !tex); + tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership); + REPORTER_ASSERT(reporter, !tex); + } + // check adopt creation - backendCopy.fAlloc = imageInfo->fAlloc; - backendTex = GrBackendTexture(kW, kH, backendCopy); - tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership); + { + GrVkImageInfo backendCopy = *imageInfo; + GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy); + tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership); - REPORTER_ASSERT(reporter, tex); + REPORTER_ASSERT(reporter, tex); + } - gpu->deleteTestingOnlyBackendTexture(backendObj, true); + gpu->deleteTestingOnlyBackendTexture(&origBackendTex, true); } void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) { GrVkGpu* gpu = static_cast(context->getGpu()); - GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig, - true, GrMipMapped::kNo); - const GrVkImageInfo* backendTex = reinterpret_cast(backendObj); + GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, + kPixelConfig, true, + GrMipMapped::kNo); + const GrVkImageInfo* imageInfo = origBackendTex.getVkImageInfo(); - GrBackendRenderTarget backendRT(kW, kH, 0, 0, *backendTex); + GrBackendRenderTarget origBackendRT(kW, kH, 0, 0, *imageInfo); - sk_sp rt = gpu->wrapBackendRenderTarget(backendRT); + sk_sp rt = gpu->wrapBackendRenderTarget(origBackendRT); REPORTER_ASSERT(reporter, rt); // image is null - GrVkImageInfo backendCopy = *backendTex; - backendCopy.fImage = VK_NULL_HANDLE; - GrBackendRenderTarget backendRT2(kW, kH, 0, 0, backendCopy); - rt = gpu->wrapBackendRenderTarget(backendRT2); - REPORTER_ASSERT(reporter, !rt); + { + GrVkImageInfo backendCopy = *imageInfo; + backendCopy.fImage = VK_NULL_HANDLE; + GrBackendRenderTarget backendRT(kW, kH, 0, 0, backendCopy); + rt = gpu->wrapBackendRenderTarget(backendRT); + REPORTER_ASSERT(reporter, !rt); + } // alloc is null - backendCopy.fImage = backendTex->fImage; - backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 }; - // can wrap null alloc - GrBackendRenderTarget backendRT3(kW, kH, 0, 0, backendCopy); - rt = gpu->wrapBackendRenderTarget(backendRT3); - REPORTER_ASSERT(reporter, rt); + { + GrVkImageInfo backendCopy = *imageInfo; + backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 }; + // can wrap null alloc + GrBackendRenderTarget backendRT(kW, kH, 0, 0, backendCopy); + rt = gpu->wrapBackendRenderTarget(backendRT); + REPORTER_ASSERT(reporter, rt); + } // When we wrapBackendRenderTarget it is always borrowed, so we must make sure to free the // resource when we're done. - gpu->deleteTestingOnlyBackendTexture(backendObj, false); + gpu->deleteTestingOnlyBackendTexture(&origBackendTex); } void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) { GrVkGpu* gpu = static_cast(context->getGpu()); - GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig, - true, GrMipMapped::kNo); - const GrVkImageInfo* imageInfo = reinterpret_cast(backendObj); + GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, + kPixelConfig, true, + GrMipMapped::kNo); + const GrVkImageInfo* imageInfo = origBackendTex.getVkImageInfo(); - GrBackendTexture backendTex = GrBackendTexture(kW, kH, *imageInfo); - sk_sp tex = gpu->wrapRenderableBackendTexture(backendTex, 0, + sk_sp tex = gpu->wrapRenderableBackendTexture(origBackendTex, 0, kBorrow_GrWrapOwnership); REPORTER_ASSERT(reporter, tex); // image is null - GrVkImageInfo backendCopy = *imageInfo; - backendCopy.fImage = VK_NULL_HANDLE; - backendTex = GrBackendTexture(kW, kH, backendCopy); - tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kBorrow_GrWrapOwnership); - REPORTER_ASSERT(reporter, !tex); - tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership); - REPORTER_ASSERT(reporter, !tex); + { + GrVkImageInfo backendCopy = *imageInfo; + backendCopy.fImage = VK_NULL_HANDLE; + GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy); + tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kBorrow_GrWrapOwnership); + REPORTER_ASSERT(reporter, !tex); + tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership); + REPORTER_ASSERT(reporter, !tex); + } // alloc is null - backendCopy.fImage = imageInfo->fImage; - backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 }; - backendTex = GrBackendTexture(kW, kH, backendCopy); - tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kBorrow_GrWrapOwnership); - REPORTER_ASSERT(reporter, !tex); - tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership); - REPORTER_ASSERT(reporter, !tex); + { + GrVkImageInfo backendCopy = *imageInfo; + backendCopy.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 }; + GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy); + tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kBorrow_GrWrapOwnership); + REPORTER_ASSERT(reporter, !tex); + tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership); + REPORTER_ASSERT(reporter, !tex); + } // check adopt creation - backendCopy.fAlloc = imageInfo->fAlloc; - backendTex = GrBackendTexture(kW, kH, backendCopy); - tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership); - REPORTER_ASSERT(reporter, tex); - - gpu->deleteTestingOnlyBackendTexture(backendObj, true); + { + GrVkImageInfo backendCopy = *imageInfo; + GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy); + tex = gpu->wrapRenderableBackendTexture(backendTex, 0, kAdopt_GrWrapOwnership); + REPORTER_ASSERT(reporter, tex); + } + + gpu->deleteTestingOnlyBackendTexture(&origBackendTex, true); } DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkWrapTests, reporter, ctxInfo) { -- cgit v1.2.3