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 11 matching lines...) Expand all Loading... |
22 using sk_gpu_test::GrContextFactory; | 22 using sk_gpu_test::GrContextFactory; |
23 | 23 |
24 const int kW = 1024; | 24 const int kW = 1024; |
25 const int kH = 1024; | 25 const int kH = 1024; |
26 const GrPixelConfig kPixelConfig = kRGBA_8888_GrPixelConfig; | 26 const GrPixelConfig kPixelConfig = kRGBA_8888_GrPixelConfig; |
27 | 27 |
28 void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) { | 28 void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) { |
29 | 29 |
30 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); | 30 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); |
31 | 31 |
32 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k
W, kH, kPixelConfig); | 32 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k
W, kH, kPixelConfig, |
| 33 false); |
33 const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(bac
kendObj); | 34 const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(bac
kendObj); |
34 | 35 |
35 // check basic borrowed creation | 36 // check basic borrowed creation |
36 GrBackendTextureDesc desc; | 37 GrBackendTextureDesc desc; |
37 desc.fConfig = kPixelConfig; | 38 desc.fConfig = kPixelConfig; |
38 desc.fWidth = kW; | 39 desc.fWidth = kW; |
39 desc.fHeight = kH; | 40 desc.fHeight = kH; |
40 desc.fTextureHandle = backendObj; | 41 desc.fTextureHandle = backendObj; |
41 GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); | 42 GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); |
42 REPORTER_ASSERT(reporter, tex); | 43 REPORTER_ASSERT(reporter, tex); |
(...skipping 21 matching lines...) Expand all Loading... |
64 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); | 65 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); |
65 REPORTER_ASSERT(reporter, tex); | 66 REPORTER_ASSERT(reporter, tex); |
66 tex->unref(); | 67 tex->unref(); |
67 | 68 |
68 gpu->deleteTestingOnlyBackendTexture(backendObj, true); | 69 gpu->deleteTestingOnlyBackendTexture(backendObj, true); |
69 } | 70 } |
70 | 71 |
71 void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) { | 72 void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) { |
72 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); | 73 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); |
73 | 74 |
74 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k
W, kH, kPixelConfig); | 75 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k
W, kH, kPixelConfig, |
| 76 true); |
75 const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(bac
kendObj); | 77 const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(bac
kendObj); |
76 | 78 |
77 // check basic borrowed creation | 79 // check basic borrowed creation |
78 GrBackendRenderTargetDesc desc; | 80 GrBackendRenderTargetDesc desc; |
79 desc.fWidth = kW; | 81 desc.fWidth = kW; |
80 desc.fHeight = kH; | 82 desc.fHeight = kH; |
81 desc.fConfig = kPixelConfig; | 83 desc.fConfig = kPixelConfig; |
82 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 84 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
83 desc.fSampleCnt = 0; | 85 desc.fSampleCnt = 0; |
84 desc.fStencilBits = 0; | 86 desc.fStencilBits = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
111 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership); | 113 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership); |
112 REPORTER_ASSERT(reporter, rt); | 114 REPORTER_ASSERT(reporter, rt); |
113 rt->unref(); | 115 rt->unref(); |
114 | 116 |
115 gpu->deleteTestingOnlyBackendTexture(backendObj, true); | 117 gpu->deleteTestingOnlyBackendTexture(backendObj, true); |
116 } | 118 } |
117 | 119 |
118 void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) { | 120 void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) { |
119 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); | 121 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); |
120 | 122 |
121 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k
W, kH, kPixelConfig); | 123 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k
W, kH, kPixelConfig, |
| 124 true); |
122 const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(bac
kendObj); | 125 const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(bac
kendObj); |
123 | 126 |
124 // check basic borrowed creation | 127 // check basic borrowed creation |
125 GrBackendTextureDesc desc; | 128 GrBackendTextureDesc desc; |
126 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 129 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
127 desc.fConfig = kPixelConfig; | 130 desc.fConfig = kPixelConfig; |
128 desc.fWidth = kW; | 131 desc.fWidth = kW; |
129 desc.fHeight = kH; | 132 desc.fHeight = kH; |
130 desc.fTextureHandle = backendObj; | 133 desc.fTextureHandle = backendObj; |
131 GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); | 134 GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); |
(...skipping 26 matching lines...) Expand all Loading... |
158 gpu->deleteTestingOnlyBackendTexture(backendObj, true); | 161 gpu->deleteTestingOnlyBackendTexture(backendObj, true); |
159 } | 162 } |
160 | 163 |
161 DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkWrapTests, reporter, ctxInfo) { | 164 DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkWrapTests, reporter, ctxInfo) { |
162 wrap_tex_test(reporter, ctxInfo.grContext()); | 165 wrap_tex_test(reporter, ctxInfo.grContext()); |
163 wrap_rt_test(reporter, ctxInfo.grContext()); | 166 wrap_rt_test(reporter, ctxInfo.grContext()); |
164 wrap_trt_test(reporter, ctxInfo.grContext()); | 167 wrap_trt_test(reporter, ctxInfo.grContext()); |
165 } | 168 } |
166 | 169 |
167 #endif | 170 #endif |
OLD | NEW |