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

Side by Side Diff: tests/ResourceCacheTest.cpp

Issue 1262623008: Revert of Fix SkData leaks at GrResourceKey::setCustomData() call sites. (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 | « src/gpu/GrTessellatingPathRenderer.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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo))); 854 key2.setCustomData(SkData::NewWithCopy(&foo, sizeof(foo)));
855 key2.setCustomData(data.get());
856 d->resourcePriv().setUniqueKey(key2); 855 d->resourcePriv().setUniqueKey(key2);
857 } 856 }
858 857
859 GrUniqueKey key3; 858 GrUniqueKey key3;
860 make_unique_key<0>(&key3, 0); 859 make_unique_key<0>(&key3, 0);
861 SkAutoTUnref<GrGpuResource> d2(cache->findAndRefUniqueResource(key3)); 860 SkAutoTUnref<GrGpuResource> d2(cache->findAndRefUniqueResource(key3));
862 REPORTER_ASSERT(reporter, *(int*) d2->getUniqueKey().getCustomData()->data() == 4132); 861 REPORTER_ASSERT(reporter, *(int*) d2->getUniqueKey().getCustomData()->data() == 4132);
863 } 862 }
864 863
865 static void test_purge_invalidated(skiatest::Reporter* reporter) { 864 static void test_purge_invalidated(skiatest::Reporter* reporter) {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 make_unique_key<2>(&key2, i); 1233 make_unique_key<2>(&key2, i);
1235 1234
1236 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1)); 1235 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1));
1237 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2)); 1236 REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key2));
1238 } 1237 }
1239 } 1238 }
1240 1239
1241 static void test_custom_data(skiatest::Reporter* reporter) { 1240 static void test_custom_data(skiatest::Reporter* reporter) {
1242 GrUniqueKey key1, key2; 1241 GrUniqueKey key1, key2;
1243 int foo = 4132; 1242 int foo = 4132;
1244 SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo))); 1243 key1.setCustomData(SkData::NewWithCopy(&foo, sizeof(foo)));
1245 key1.setCustomData(data.get());
1246 REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132); 1244 REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132);
1247 REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr); 1245 REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr);
1248 1246
1249 // Test that copying a key also takes a ref on its custom data. 1247 // Test that copying a key also takes a ref on its custom data.
1250 GrUniqueKey key3 = key1; 1248 GrUniqueKey key3 = key1;
1251 REPORTER_ASSERT(reporter, *(int*) key3.getCustomData()->data() == 4132); 1249 REPORTER_ASSERT(reporter, *(int*) key3.getCustomData()->data() == 4132);
1252 } 1250 }
1253 1251
1254 //////////////////////////////////////////////////////////////////////////////// 1252 ////////////////////////////////////////////////////////////////////////////////
1255 DEF_GPUTEST(ResourceCache, reporter, factory) { 1253 DEF_GPUTEST(ResourceCache, reporter, factory) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 test_purge_invalidated(reporter); 1285 test_purge_invalidated(reporter);
1288 test_cache_chained_purge(reporter); 1286 test_cache_chained_purge(reporter);
1289 test_resource_size_changed(reporter); 1287 test_resource_size_changed(reporter);
1290 test_timestamp_wrap(reporter); 1288 test_timestamp_wrap(reporter);
1291 test_flush(reporter); 1289 test_flush(reporter);
1292 test_large_resource_count(reporter); 1290 test_large_resource_count(reporter);
1293 test_custom_data(reporter); 1291 test_custom_data(reporter);
1294 } 1292 }
1295 1293
1296 #endif 1294 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698