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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1248 | 1248 |
1249 for (int i = 0; i < kResourceCnt; ++i) { | 1249 for (int i = 0; i < kResourceCnt; ++i) { |
1250 GrUniqueKey key1, key2; | 1250 GrUniqueKey key1, key2; |
1251 make_unique_key<1>(&key1, i); | 1251 make_unique_key<1>(&key1, i); |
1252 make_unique_key<2>(&key2, i); | 1252 make_unique_key<2>(&key2, i); |
1253 | 1253 |
1254 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1)); | 1254 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1)); |
1255 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2)); | 1255 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2)); |
1256 } | 1256 } |
1257 } | 1257 } |
1258 | 1258 |
robertphillips
2016/08/30 16:38:37
how is this test working ?
robertphillips
2016/08/30 16:39:41
Nevermind, this is the key's custom data.
| |
1259 static void test_custom_data(skiatest::Reporter* reporter) { | 1259 static void test_custom_data(skiatest::Reporter* reporter) { |
1260 GrUniqueKey key1, key2; | 1260 GrUniqueKey key1, key2; |
1261 make_unique_key<0>(&key1, 1); | 1261 make_unique_key<0>(&key1, 1); |
1262 make_unique_key<0>(&key2, 2); | 1262 make_unique_key<0>(&key2, 2); |
1263 int foo = 4132; | 1263 int foo = 4132; |
1264 key1.setCustomData(SkData::MakeWithCopy(&foo, sizeof(foo))); | 1264 key1.setCustomData(SkData::MakeWithCopy(&foo, sizeof(foo))); |
1265 REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132); | 1265 REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132); |
1266 REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr); | 1266 REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr); |
1267 | 1267 |
1268 // Test that copying a key also takes a ref on its custom data. | 1268 // Test that copying a key also takes a ref on its custom data. |
1269 GrUniqueKey key3 = key1; | 1269 GrUniqueKey key3 = key1; |
1270 REPORTER_ASSERT(reporter, *(int*) key3.getCustomData()->data() == 4132); | 1270 REPORTER_ASSERT(reporter, *(int*) key3.getCustomData()->data() == 4132); |
1271 } | 1271 } |
1272 | 1272 |
1273 static void test_abandoned(skiatest::Reporter* reporter) { | 1273 static void test_abandoned(skiatest::Reporter* reporter) { |
1274 Mock mock(10, 300); | 1274 Mock mock(10, 300); |
1275 GrContext* context = mock.context(); | 1275 GrContext* context = mock.context(); |
1276 SkAutoTUnref<GrGpuResource> resource(new TestResource(context->getGpu())); | 1276 SkAutoTUnref<GrGpuResource> resource(new TestResource(context->getGpu())); |
1277 context->abandonContext(); | 1277 context->abandonContext(); |
1278 | 1278 |
1279 REPORTER_ASSERT(reporter, resource->wasDestroyed()); | 1279 REPORTER_ASSERT(reporter, resource->wasDestroyed()); |
1280 | 1280 |
1281 // Call all the public methods on resource in the abandoned state. They shou ldn't crash. | 1281 // Call all the public methods on resource in the abandoned state. They shou ldn't crash. |
1282 | 1282 |
robertphillips
2016/08/30 16:38:37
Can we rm foo & data too ?
| |
1283 int foo = 4132; | 1283 int foo = 4132; |
1284 sk_sp<SkData> data(SkData::MakeWithCopy(&foo, sizeof(foo))); | 1284 sk_sp<SkData> data(SkData::MakeWithCopy(&foo, sizeof(foo))); |
1285 resource->setCustomData(data.get()); | |
1286 resource->getCustomData(); | |
1287 resource->getUniqueID(); | 1285 resource->getUniqueID(); |
1288 resource->getUniqueKey(); | 1286 resource->getUniqueKey(); |
1289 resource->wasDestroyed(); | 1287 resource->wasDestroyed(); |
1290 resource->gpuMemorySize(); | 1288 resource->gpuMemorySize(); |
1291 resource->getContext(); | 1289 resource->getContext(); |
1292 | 1290 |
1293 resource->abandon(); | 1291 resource->abandon(); |
1294 resource->resourcePriv().getScratchKey(); | 1292 resource->resourcePriv().getScratchKey(); |
1295 resource->resourcePriv().isBudgeted(); | 1293 resource->resourcePriv().isBudgeted(); |
1296 resource->resourcePriv().makeBudgeted(); | 1294 resource->resourcePriv().makeBudgeted(); |
(...skipping 19 matching lines...) Expand all Loading... | |
1316 test_cache_chained_purge(reporter); | 1314 test_cache_chained_purge(reporter); |
1317 test_resource_size_changed(reporter); | 1315 test_resource_size_changed(reporter); |
1318 test_timestamp_wrap(reporter); | 1316 test_timestamp_wrap(reporter); |
1319 test_flush(reporter); | 1317 test_flush(reporter); |
1320 test_large_resource_count(reporter); | 1318 test_large_resource_count(reporter); |
1321 test_custom_data(reporter); | 1319 test_custom_data(reporter); |
1322 test_abandoned(reporter); | 1320 test_abandoned(reporter); |
1323 } | 1321 } |
1324 | 1322 |
1325 #endif | 1323 #endif |
OLD | NEW |