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 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1216 for (int i = 0; i < kResourceCnt; ++i) { | 1216 for (int i = 0; i < kResourceCnt; ++i) { |
1217 GrUniqueKey key1, key2; | 1217 GrUniqueKey key1, key2; |
1218 make_unique_key<1>(&key1, i); | 1218 make_unique_key<1>(&key1, i); |
1219 make_unique_key<2>(&key2, i); | 1219 make_unique_key<2>(&key2, i); |
1220 | 1220 |
1221 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1)); | 1221 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1)); |
1222 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2)); | 1222 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2)); |
1223 } | 1223 } |
1224 } | 1224 } |
1225 | 1225 |
1226 static void test_custom_data(skiatest::Reporter* reporter) { | |
1227 GrUniqueKey key1, key2; | |
1228 int foo = 4132; | |
1229 key1.setCustomData(SkData::NewWithCopy(&foo, sizeof(foo))); | |
1230 REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132); | |
1231 REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr); | |
1232 | |
1233 // Test that copying a key also takes a ref on its custom data. | |
1234 GrUniqueKey key3 = key1; | |
1235 REPORTER_ASSERT(reporter, *(int*) key3.getCustomData()->data() == 4132); | |
bsalomon
2015/08/03 19:34:54
Can you test that if you stick a resource in the c
Stephen White
2015/08/03 19:52:24
Done.
| |
1236 } | |
1237 | |
1226 //////////////////////////////////////////////////////////////////////////////// | 1238 //////////////////////////////////////////////////////////////////////////////// |
1227 DEF_GPUTEST(ResourceCache, reporter, factory) { | 1239 DEF_GPUTEST(ResourceCache, reporter, factory) { |
1228 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { | 1240 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { |
1229 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); | 1241 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); |
1230 if (!GrContextFactory::IsRenderingGLContext(glType)) { | 1242 if (!GrContextFactory::IsRenderingGLContext(glType)) { |
1231 continue; | 1243 continue; |
1232 } | 1244 } |
1233 GrContext* context = factory->get(glType); | 1245 GrContext* context = factory->get(glType); |
1234 if (NULL == context) { | 1246 if (NULL == context) { |
1235 continue; | 1247 continue; |
(...skipping 19 matching lines...) Expand all Loading... | |
1255 test_duplicate_unique_key(reporter); | 1267 test_duplicate_unique_key(reporter); |
1256 test_duplicate_scratch_key(reporter); | 1268 test_duplicate_scratch_key(reporter); |
1257 test_remove_scratch_key(reporter); | 1269 test_remove_scratch_key(reporter); |
1258 test_scratch_key_consistency(reporter); | 1270 test_scratch_key_consistency(reporter); |
1259 test_purge_invalidated(reporter); | 1271 test_purge_invalidated(reporter); |
1260 test_cache_chained_purge(reporter); | 1272 test_cache_chained_purge(reporter); |
1261 test_resource_size_changed(reporter); | 1273 test_resource_size_changed(reporter); |
1262 test_timestamp_wrap(reporter); | 1274 test_timestamp_wrap(reporter); |
1263 test_flush(reporter); | 1275 test_flush(reporter); |
1264 test_large_resource_count(reporter); | 1276 test_large_resource_count(reporter); |
1277 test_custom_data(reporter); | |
1265 } | 1278 } |
1266 | 1279 |
1267 #endif | 1280 #endif |
OLD | NEW |