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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 c->unref(); | 844 c->unref(); |
845 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount()); | 845 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount()); |
846 REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes()); | 846 REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes()); |
847 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive()); | 847 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive()); |
848 | 848 |
849 { | 849 { |
850 GrUniqueKey key2; | 850 GrUniqueKey key2; |
851 make_unique_key<0>(&key2, 0); | 851 make_unique_key<0>(&key2, 0); |
852 SkAutoTUnref<TestResource> d(SkNEW_ARGS(TestResource, (context->getGpu()
))); | 852 SkAutoTUnref<TestResource> d(SkNEW_ARGS(TestResource, (context->getGpu()
))); |
853 int foo = 4132; | 853 int foo = 4132; |
854 key2.setCustomData(SkData::NewWithCopy(&foo, sizeof(foo))); | 854 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo))); |
| 855 key2.setCustomData(data.get()); |
855 d->resourcePriv().setUniqueKey(key2); | 856 d->resourcePriv().setUniqueKey(key2); |
856 } | 857 } |
857 | 858 |
858 GrUniqueKey key3; | 859 GrUniqueKey key3; |
859 make_unique_key<0>(&key3, 0); | 860 make_unique_key<0>(&key3, 0); |
860 SkAutoTUnref<GrGpuResource> d2(cache->findAndRefUniqueResource(key3)); | 861 SkAutoTUnref<GrGpuResource> d2(cache->findAndRefUniqueResource(key3)); |
861 REPORTER_ASSERT(reporter, *(int*) d2->getUniqueKey().getCustomData()->data()
== 4132); | 862 REPORTER_ASSERT(reporter, *(int*) d2->getUniqueKey().getCustomData()->data()
== 4132); |
862 } | 863 } |
863 | 864 |
864 static void test_purge_invalidated(skiatest::Reporter* reporter) { | 865 static void test_purge_invalidated(skiatest::Reporter* reporter) { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 make_unique_key<2>(&key2, i); | 1234 make_unique_key<2>(&key2, i); |
1234 | 1235 |
1235 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1)); | 1236 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1)); |
1236 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2)); | 1237 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2)); |
1237 } | 1238 } |
1238 } | 1239 } |
1239 | 1240 |
1240 static void test_custom_data(skiatest::Reporter* reporter) { | 1241 static void test_custom_data(skiatest::Reporter* reporter) { |
1241 GrUniqueKey key1, key2; | 1242 GrUniqueKey key1, key2; |
1242 int foo = 4132; | 1243 int foo = 4132; |
1243 key1.setCustomData(SkData::NewWithCopy(&foo, sizeof(foo))); | 1244 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo))); |
| 1245 key1.setCustomData(data.get()); |
1244 REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132); | 1246 REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132); |
1245 REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr); | 1247 REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr); |
1246 | 1248 |
1247 // Test that copying a key also takes a ref on its custom data. | 1249 // Test that copying a key also takes a ref on its custom data. |
1248 GrUniqueKey key3 = key1; | 1250 GrUniqueKey key3 = key1; |
1249 REPORTER_ASSERT(reporter, *(int*) key3.getCustomData()->data() == 4132); | 1251 REPORTER_ASSERT(reporter, *(int*) key3.getCustomData()->data() == 4132); |
1250 } | 1252 } |
1251 | 1253 |
1252 //////////////////////////////////////////////////////////////////////////////// | 1254 //////////////////////////////////////////////////////////////////////////////// |
1253 DEF_GPUTEST(ResourceCache, reporter, factory) { | 1255 DEF_GPUTEST(ResourceCache, reporter, factory) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 test_purge_invalidated(reporter); | 1287 test_purge_invalidated(reporter); |
1286 test_cache_chained_purge(reporter); | 1288 test_cache_chained_purge(reporter); |
1287 test_resource_size_changed(reporter); | 1289 test_resource_size_changed(reporter); |
1288 test_timestamp_wrap(reporter); | 1290 test_timestamp_wrap(reporter); |
1289 test_flush(reporter); | 1291 test_flush(reporter); |
1290 test_large_resource_count(reporter); | 1292 test_large_resource_count(reporter); |
1291 test_custom_data(reporter); | 1293 test_custom_data(reporter); |
1292 } | 1294 } |
1293 | 1295 |
1294 #endif | 1296 #endif |
OLD | NEW |