| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
ext) { | 179 static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
ext) { |
| 180 const GrGpu* gpu = context->getGpu(); | 180 const GrGpu* gpu = context->getGpu(); |
| 181 // this test is only valid for GL | 181 // this test is only valid for GL |
| 182 if (!gpu || !gpu->glContextForTesting()) { | 182 if (!gpu || !gpu->glContextForTesting()) { |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 | 185 |
| 186 GrBackendObject texIDs[2]; | 186 GrBackendObject texHandles[2]; |
| 187 static const int kW = 100; | 187 static const int kW = 100; |
| 188 static const int kH = 100; | 188 static const int kH = 100; |
| 189 | 189 |
| 190 texIDs[0] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_8888
_GrPixelConfig); | 190 texHandles[0] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_
8888_GrPixelConfig); |
| 191 texIDs[1] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_8888
_GrPixelConfig); | 191 texHandles[1] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_
8888_GrPixelConfig); |
| 192 | 192 |
| 193 context->resetContext(); | 193 context->resetContext(); |
| 194 | 194 |
| 195 GrBackendTextureDesc desc; | 195 GrBackendTextureDesc desc; |
| 196 desc.fConfig = kBGRA_8888_GrPixelConfig; | 196 desc.fConfig = kBGRA_8888_GrPixelConfig; |
| 197 desc.fWidth = kW; | 197 desc.fWidth = kW; |
| 198 desc.fHeight = kH; | 198 desc.fHeight = kH; |
| 199 | 199 |
| 200 desc.fTextureHandle = texIDs[0]; | 200 desc.fTextureHandle = texHandles[0]; |
| 201 SkAutoTUnref<GrTexture> borrowed(context->textureProvider()->wrapBackendText
ure( | 201 SkAutoTUnref<GrTexture> borrowed(context->textureProvider()->wrapBackendText
ure( |
| 202 desc, kBorrow_GrWrapOwnership)); | 202 desc, kBorrow_GrWrapOwnership)); |
| 203 | 203 |
| 204 desc.fTextureHandle = texIDs[1]; | 204 desc.fTextureHandle = texHandles[1]; |
| 205 SkAutoTUnref<GrTexture> adopted(context->textureProvider()->wrapBackendTextu
re( | 205 SkAutoTUnref<GrTexture> adopted(context->textureProvider()->wrapBackendTextu
re( |
| 206 desc, kAdopt_GrWrapOwnership)); | 206 desc, kAdopt_GrWrapOwnership)); |
| 207 | 207 |
| 208 REPORTER_ASSERT(reporter, SkToBool(borrowed) && SkToBool(adopted)); | 208 REPORTER_ASSERT(reporter, SkToBool(borrowed) && SkToBool(adopted)); |
| 209 if (!SkToBool(borrowed) || !SkToBool(adopted)) { | 209 if (!SkToBool(borrowed) || !SkToBool(adopted)) { |
| 210 return; | 210 return; |
| 211 } | 211 } |
| 212 | 212 |
| 213 borrowed.reset(nullptr); | 213 borrowed.reset(nullptr); |
| 214 adopted.reset(nullptr); | 214 adopted.reset(nullptr); |
| 215 | 215 |
| 216 context->flush(); | 216 context->flush(); |
| 217 | 217 |
| 218 bool borrowedIsAlive = gpu->isTestingOnlyBackendTexture(texIDs[0]); | 218 bool borrowedIsAlive = gpu->isTestingOnlyBackendTexture(texHandles[0]); |
| 219 bool adoptedIsAlive = gpu->isTestingOnlyBackendTexture(texIDs[1]); | 219 bool adoptedIsAlive = gpu->isTestingOnlyBackendTexture(texHandles[1]); |
| 220 | 220 |
| 221 REPORTER_ASSERT(reporter, borrowedIsAlive); | 221 REPORTER_ASSERT(reporter, borrowedIsAlive); |
| 222 REPORTER_ASSERT(reporter, !adoptedIsAlive); | 222 REPORTER_ASSERT(reporter, !adoptedIsAlive); |
| 223 | 223 |
| 224 gpu->deleteTestingOnlyBackendTexture(texIDs[0]); | 224 gpu->deleteTestingOnlyBackendTexture(texHandles[0]); |
| 225 | 225 |
| 226 context->resetContext(); | 226 context->resetContext(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 class TestResource : public GrGpuResource { | 229 class TestResource : public GrGpuResource { |
| 230 enum ScratchConstructor { kScratchConstructor }; | 230 enum ScratchConstructor { kScratchConstructor }; |
| 231 public: | 231 public: |
| 232 static const size_t kDefaultSize = 100; | 232 static const size_t kDefaultSize = 100; |
| 233 | 233 |
| 234 /** Property that distinctly categorizes the resource. | 234 /** Property that distinctly categorizes the resource. |
| (...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 test_cache_chained_purge(reporter); | 1320 test_cache_chained_purge(reporter); |
| 1321 test_resource_size_changed(reporter); | 1321 test_resource_size_changed(reporter); |
| 1322 test_timestamp_wrap(reporter); | 1322 test_timestamp_wrap(reporter); |
| 1323 test_flush(reporter); | 1323 test_flush(reporter); |
| 1324 test_large_resource_count(reporter); | 1324 test_large_resource_count(reporter); |
| 1325 test_custom_data(reporter); | 1325 test_custom_data(reporter); |
| 1326 test_abandoned(reporter); | 1326 test_abandoned(reporter); |
| 1327 } | 1327 } |
| 1328 | 1328 |
| 1329 #endif | 1329 #endif |
| OLD | NEW |