OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 // Include here to ensure SK_SUPPORT_GPU is set correctly before it is examined. | 8 // Include here to ensure SK_SUPPORT_GPU is set correctly before it is examined. |
9 #include "SkTypes.h" | 9 #include "SkTypes.h" |
10 | 10 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
ext) { | 177 static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
ext) { |
178 const GrGpu* gpu = context->getGpu(); | 178 const GrGpu* gpu = context->getGpu(); |
179 if (!gpu) { | 179 if (!gpu) { |
180 return; | 180 return; |
181 } | 181 } |
182 | 182 |
183 GrBackendObject texIDs[2]; | 183 GrBackendObject texIDs[2]; |
184 static const int kW = 100; | 184 static const int kW = 100; |
185 static const int kH = 100; | 185 static const int kH = 100; |
186 | 186 |
187 texIDs[0] = gpu->createBackendTexture(NULL, kW, kH, kRGBA_8888_GrPixelConfig
); | 187 texIDs[0] = gpu->createTestingOnlyBackendTexture(NULL, kW, kH, kRGBA_8888_Gr
PixelConfig); |
188 texIDs[1] = gpu->createBackendTexture(NULL, kW, kH, kRGBA_8888_GrPixelConfig
); | 188 texIDs[1] = gpu->createTestingOnlyBackendTexture(NULL, kW, kH, kRGBA_8888_Gr
PixelConfig); |
189 | 189 |
190 context->resetContext(); | 190 context->resetContext(); |
191 | 191 |
192 GrBackendTextureDesc desc; | 192 GrBackendTextureDesc desc; |
193 desc.fConfig = kBGRA_8888_GrPixelConfig; | 193 desc.fConfig = kBGRA_8888_GrPixelConfig; |
194 desc.fWidth = kW; | 194 desc.fWidth = kW; |
195 desc.fHeight = kH; | 195 desc.fHeight = kH; |
196 | 196 |
197 desc.fTextureHandle = texIDs[0]; | 197 desc.fTextureHandle = texIDs[0]; |
198 SkAutoTUnref<GrTexture> borrowed(context->textureProvider()->wrapBackendText
ure( | 198 SkAutoTUnref<GrTexture> borrowed(context->textureProvider()->wrapBackendText
ure( |
199 desc, kBorrow_GrWrapOwnership)); | 199 desc, kBorrow_GrWrapOwnership)); |
200 | 200 |
201 desc.fTextureHandle = texIDs[1]; | 201 desc.fTextureHandle = texIDs[1]; |
202 SkAutoTUnref<GrTexture> adopted(context->textureProvider()->wrapBackendTextu
re( | 202 SkAutoTUnref<GrTexture> adopted(context->textureProvider()->wrapBackendTextu
re( |
203 desc, kAdopt_GrWrapOwnership)); | 203 desc, kAdopt_GrWrapOwnership)); |
204 | 204 |
205 REPORTER_ASSERT(reporter, SkToBool(borrowed) && SkToBool(adopted)); | 205 REPORTER_ASSERT(reporter, SkToBool(borrowed) && SkToBool(adopted)); |
206 if (!SkToBool(borrowed) || !SkToBool(adopted)) { | 206 if (!SkToBool(borrowed) || !SkToBool(adopted)) { |
207 return; | 207 return; |
208 } | 208 } |
209 | 209 |
210 borrowed.reset(NULL); | 210 borrowed.reset(NULL); |
211 adopted.reset(NULL); | 211 adopted.reset(NULL); |
212 | 212 |
213 context->flush(); | 213 context->flush(); |
214 | 214 |
215 bool borrowedIsAlive = gpu->isBackendTexture(texIDs[0]); | 215 bool borrowedIsAlive = gpu->isTestingOnlyBackendTexture(texIDs[0]); |
216 bool adoptedIsAlive = gpu->isBackendTexture(texIDs[1]); | 216 bool adoptedIsAlive = gpu->isTestingOnlyBackendTexture(texIDs[1]); |
217 | 217 |
218 REPORTER_ASSERT(reporter, borrowedIsAlive); | 218 REPORTER_ASSERT(reporter, borrowedIsAlive); |
219 REPORTER_ASSERT(reporter, !adoptedIsAlive); | 219 REPORTER_ASSERT(reporter, !adoptedIsAlive); |
220 | 220 |
221 gpu->deleteBackendTexture(texIDs[0]); | 221 gpu->deleteTestingOnlyBackendTexture(texIDs[0]); |
222 | 222 |
223 context->resetContext(); | 223 context->resetContext(); |
224 } | 224 } |
225 | 225 |
226 class TestResource : public GrGpuResource { | 226 class TestResource : public GrGpuResource { |
227 static const size_t kDefaultSize = 100; | 227 static const size_t kDefaultSize = 100; |
228 enum ScratchConstructor { kScratchConstructor }; | 228 enum ScratchConstructor { kScratchConstructor }; |
229 public: | 229 public: |
230 | 230 |
231 /** Property that distinctly categorizes the resource. | 231 /** Property that distinctly categorizes the resource. |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 test_scratch_key_consistency(reporter); | 1257 test_scratch_key_consistency(reporter); |
1258 test_purge_invalidated(reporter); | 1258 test_purge_invalidated(reporter); |
1259 test_cache_chained_purge(reporter); | 1259 test_cache_chained_purge(reporter); |
1260 test_resource_size_changed(reporter); | 1260 test_resource_size_changed(reporter); |
1261 test_timestamp_wrap(reporter); | 1261 test_timestamp_wrap(reporter); |
1262 test_flush(reporter); | 1262 test_flush(reporter); |
1263 test_large_resource_count(reporter); | 1263 test_large_resource_count(reporter); |
1264 } | 1264 } |
1265 | 1265 |
1266 #endif | 1266 #endif |
OLD | NEW |