| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 // This is a GPU-backend specific test. It relies on static intializers to work | 8 // This is a GPU-backend specific test. It relies on static intializers to work |
| 9 | 9 |
| 10 #include "SkTypes.h" | 10 #include "SkTypes.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 GrVkImageInfo backendCopy = *backendTex; | 46 GrVkImageInfo backendCopy = *backendTex; |
| 47 backendCopy.fImage = VK_NULL_HANDLE; | 47 backendCopy.fImage = VK_NULL_HANDLE; |
| 48 desc.fTextureHandle = (GrBackendObject) &backendCopy; | 48 desc.fTextureHandle = (GrBackendObject) &backendCopy; |
| 49 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); | 49 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); |
| 50 REPORTER_ASSERT(reporter, !tex); | 50 REPORTER_ASSERT(reporter, !tex); |
| 51 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); | 51 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); |
| 52 REPORTER_ASSERT(reporter, !tex); | 52 REPORTER_ASSERT(reporter, !tex); |
| 53 | 53 |
| 54 // alloc is null | 54 // alloc is null |
| 55 backendCopy.fImage = backendTex->fImage; | 55 backendCopy.fImage = backendTex->fImage; |
| 56 backendCopy.fAlloc = VK_NULL_HANDLE; | 56 backendCopy.fAlloc = { VK_NULL_HANDLE, 0 }; |
| 57 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); | 57 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); |
| 58 REPORTER_ASSERT(reporter, !tex); | 58 REPORTER_ASSERT(reporter, !tex); |
| 59 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); | 59 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); |
| 60 REPORTER_ASSERT(reporter, !tex); | 60 REPORTER_ASSERT(reporter, !tex); |
| 61 | 61 |
| 62 // check adopt creation | 62 // check adopt creation |
| 63 backendCopy.fAlloc = backendTex->fAlloc; | 63 backendCopy.fAlloc = backendTex->fAlloc; |
| 64 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); | 64 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); |
| 65 REPORTER_ASSERT(reporter, tex); | 65 REPORTER_ASSERT(reporter, tex); |
| 66 tex->unref(); | 66 tex->unref(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 91 GrVkImageInfo backendCopy = *backendTex; | 91 GrVkImageInfo backendCopy = *backendTex; |
| 92 backendCopy.fImage = VK_NULL_HANDLE; | 92 backendCopy.fImage = VK_NULL_HANDLE; |
| 93 desc.fRenderTargetHandle = (GrBackendObject)&backendCopy; | 93 desc.fRenderTargetHandle = (GrBackendObject)&backendCopy; |
| 94 rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership); | 94 rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership); |
| 95 REPORTER_ASSERT(reporter, !rt); | 95 REPORTER_ASSERT(reporter, !rt); |
| 96 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership); | 96 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership); |
| 97 REPORTER_ASSERT(reporter, !rt); | 97 REPORTER_ASSERT(reporter, !rt); |
| 98 | 98 |
| 99 // alloc is null | 99 // alloc is null |
| 100 backendCopy.fImage = backendTex->fImage; | 100 backendCopy.fImage = backendTex->fImage; |
| 101 backendCopy.fAlloc = VK_NULL_HANDLE; | 101 backendCopy.fAlloc = { VK_NULL_HANDLE, 0 }; |
| 102 // can wrap null alloc if borrowing | 102 // can wrap null alloc if borrowing |
| 103 rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership); | 103 rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership); |
| 104 REPORTER_ASSERT(reporter, rt); | 104 REPORTER_ASSERT(reporter, rt); |
| 105 // but not if adopting | 105 // but not if adopting |
| 106 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership); | 106 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership); |
| 107 REPORTER_ASSERT(reporter, !rt); | 107 REPORTER_ASSERT(reporter, !rt); |
| 108 | 108 |
| 109 // check adopt creation | 109 // check adopt creation |
| 110 backendCopy.fAlloc = backendTex->fAlloc; | 110 backendCopy.fAlloc = backendTex->fAlloc; |
| 111 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership); | 111 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 136 GrVkImageInfo backendCopy = *backendTex; | 136 GrVkImageInfo backendCopy = *backendTex; |
| 137 backendCopy.fImage = VK_NULL_HANDLE; | 137 backendCopy.fImage = VK_NULL_HANDLE; |
| 138 desc.fTextureHandle = (GrBackendObject)&backendCopy; | 138 desc.fTextureHandle = (GrBackendObject)&backendCopy; |
| 139 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); | 139 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); |
| 140 REPORTER_ASSERT(reporter, !tex); | 140 REPORTER_ASSERT(reporter, !tex); |
| 141 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); | 141 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); |
| 142 REPORTER_ASSERT(reporter, !tex); | 142 REPORTER_ASSERT(reporter, !tex); |
| 143 | 143 |
| 144 // alloc is null | 144 // alloc is null |
| 145 backendCopy.fImage = backendTex->fImage; | 145 backendCopy.fImage = backendTex->fImage; |
| 146 backendCopy.fAlloc = VK_NULL_HANDLE; | 146 backendCopy.fAlloc = { VK_NULL_HANDLE, 0 }; |
| 147 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); | 147 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); |
| 148 REPORTER_ASSERT(reporter, !tex); | 148 REPORTER_ASSERT(reporter, !tex); |
| 149 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); | 149 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); |
| 150 REPORTER_ASSERT(reporter, !tex); | 150 REPORTER_ASSERT(reporter, !tex); |
| 151 | 151 |
| 152 // check adopt creation | 152 // check adopt creation |
| 153 backendCopy.fAlloc = backendTex->fAlloc; | 153 backendCopy.fAlloc = backendTex->fAlloc; |
| 154 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); | 154 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); |
| 155 REPORTER_ASSERT(reporter, tex); | 155 REPORTER_ASSERT(reporter, tex); |
| 156 tex->unref(); | 156 tex->unref(); |
| 157 | 157 |
| 158 gpu->deleteTestingOnlyBackendTexture(backendObj, true); | 158 gpu->deleteTestingOnlyBackendTexture(backendObj, true); |
| 159 } | 159 } |
| 160 | 160 |
| 161 DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkWrapTests, reporter, ctxInfo) { | 161 DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkWrapTests, reporter, ctxInfo) { |
| 162 wrap_tex_test(reporter, ctxInfo.grContext()); | 162 wrap_tex_test(reporter, ctxInfo.grContext()); |
| 163 wrap_rt_test(reporter, ctxInfo.grContext()); | 163 wrap_rt_test(reporter, ctxInfo.grContext()); |
| 164 wrap_trt_test(reporter, ctxInfo.grContext()); | 164 wrap_trt_test(reporter, ctxInfo.grContext()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 #endif | 167 #endif |
| OLD | NEW |