Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: tests/ResourceCacheTest.cpp

Issue 1260363007: Revert "Implement caching of filled paths in the tessellated path renderer." (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/PathTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 REPORTER_ASSERT(reporter, c->gpuMemorySize() == cache->getResourceBytes()); 838 REPORTER_ASSERT(reporter, c->gpuMemorySize() == cache->getResourceBytes());
839 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive()); 839 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
840 840
841 // Verify that we can find c, then remove its unique key. It should get purg ed immediately. 841 // Verify that we can find c, then remove its unique key. It should get purg ed immediately.
842 REPORTER_ASSERT(reporter, c == cache->findAndRefUniqueResource(key)); 842 REPORTER_ASSERT(reporter, c == cache->findAndRefUniqueResource(key));
843 c->resourcePriv().removeUniqueKey(); 843 c->resourcePriv().removeUniqueKey();
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
849 {
850 GrUniqueKey key2;
851 make_unique_key<0>(&key2, 0);
852 SkAutoTUnref<TestResource> d(SkNEW_ARGS(TestResource, (context->getGpu() )));
853 int foo = 4132;
854 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo)));
855 key2.setCustomData(data.get());
856 d->resourcePriv().setUniqueKey(key2);
857 }
858
859 GrUniqueKey key3;
860 make_unique_key<0>(&key3, 0);
861 SkAutoTUnref<GrGpuResource> d2(cache->findAndRefUniqueResource(key3));
862 REPORTER_ASSERT(reporter, *(int*) d2->getUniqueKey().getCustomData()->data() == 4132);
863 } 848 }
864 849
865 static void test_purge_invalidated(skiatest::Reporter* reporter) { 850 static void test_purge_invalidated(skiatest::Reporter* reporter) {
866 Mock mock(5, 30000); 851 Mock mock(5, 30000);
867 GrContext* context = mock.context(); 852 GrContext* context = mock.context();
868 GrResourceCache* cache = mock.cache(); 853 GrResourceCache* cache = mock.cache();
869 854
870 GrUniqueKey key1, key2, key3; 855 GrUniqueKey key1, key2, key3;
871 make_unique_key<0>(&key1, 1); 856 make_unique_key<0>(&key1, 1);
872 make_unique_key<0>(&key2, 2); 857 make_unique_key<0>(&key2, 2);
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 for (int i = 0; i < kResourceCnt; ++i) { 1216 for (int i = 0; i < kResourceCnt; ++i) {
1232 GrUniqueKey key1, key2; 1217 GrUniqueKey key1, key2;
1233 make_unique_key<1>(&key1, i); 1218 make_unique_key<1>(&key1, i);
1234 make_unique_key<2>(&key2, i); 1219 make_unique_key<2>(&key2, i);
1235 1220
1236 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1)); 1221 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1));
1237 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2)); 1222 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2));
1238 } 1223 }
1239 } 1224 }
1240 1225
1241 static void test_custom_data(skiatest::Reporter* reporter) {
1242 GrUniqueKey key1, key2;
1243 make_unique_key<0>(&key1, 1);
1244 make_unique_key<0>(&key2, 2);
1245 int foo = 4132;
1246 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo)));
1247 key1.setCustomData(data.get());
1248 REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132);
1249 REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr);
1250
1251 // Test that copying a key also takes a ref on its custom data.
1252 GrUniqueKey key3 = key1;
1253 REPORTER_ASSERT(reporter, *(int*) key3.getCustomData()->data() == 4132);
1254 }
1255
1256 //////////////////////////////////////////////////////////////////////////////// 1226 ////////////////////////////////////////////////////////////////////////////////
1257 DEF_GPUTEST(ResourceCache, reporter, factory) { 1227 DEF_GPUTEST(ResourceCache, reporter, factory) {
1258 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 1228 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
1259 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 1229 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
1260 if (!GrContextFactory::IsRenderingGLContext(glType)) { 1230 if (!GrContextFactory::IsRenderingGLContext(glType)) {
1261 continue; 1231 continue;
1262 } 1232 }
1263 GrContext* context = factory->get(glType); 1233 GrContext* context = factory->get(glType);
1264 if (NULL == context) { 1234 if (NULL == context) {
1265 continue; 1235 continue;
(...skipping 19 matching lines...) Expand all
1285 test_duplicate_unique_key(reporter); 1255 test_duplicate_unique_key(reporter);
1286 test_duplicate_scratch_key(reporter); 1256 test_duplicate_scratch_key(reporter);
1287 test_remove_scratch_key(reporter); 1257 test_remove_scratch_key(reporter);
1288 test_scratch_key_consistency(reporter); 1258 test_scratch_key_consistency(reporter);
1289 test_purge_invalidated(reporter); 1259 test_purge_invalidated(reporter);
1290 test_cache_chained_purge(reporter); 1260 test_cache_chained_purge(reporter);
1291 test_resource_size_changed(reporter); 1261 test_resource_size_changed(reporter);
1292 test_timestamp_wrap(reporter); 1262 test_timestamp_wrap(reporter);
1293 test_flush(reporter); 1263 test_flush(reporter);
1294 test_large_resource_count(reporter); 1264 test_large_resource_count(reporter);
1295 test_custom_data(reporter);
1296 } 1265 }
1297 1266
1298 #endif 1267 #endif
OLDNEW
« no previous file with comments | « tests/PathTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698