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

Side by Side Diff: tests/ResourceCacheTest.cpp

Issue 2298003003: Don't purge resources for trivial GrContext flushes (Closed)
Patch Set: Fix speeling Created 4 years, 3 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/GrDrawingManager.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 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 for (int i = 0; i < kFlushCount; ++i) { 1188 for (int i = 0; i < kFlushCount; ++i) {
1189 REPORTER_ASSERT(reporter, kFlushCount >> 1 == cache->getResourceCoun t()); 1189 REPORTER_ASSERT(reporter, kFlushCount >> 1 == cache->getResourceCoun t());
1190 cache->notifyFlushOccurred(); 1190 cache->notifyFlushOccurred();
1191 } 1191 }
1192 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount()); 1192 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
1193 1193
1194 cache->purgeAllUnlocked(); 1194 cache->purgeAllUnlocked();
1195 } 1195 }
1196 1196
1197 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount()); 1197 REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
1198
1199 // Verify that calling flush() on a GrContext with nothing to do will not tr igger resource
1200 // eviction.
1201 context->flush();
1202 for (int i = 0; i < 10; ++i) {
1203 TestResource* r = new TestResource(context->getGpu());
1204 GrUniqueKey k;
1205 make_unique_key<1>(&k, i);
1206 r->resourcePriv().setUniqueKey(k);
1207 r->unref();
1208 }
1209 REPORTER_ASSERT(reporter, 10 == cache->getResourceCount());
1210 for (int i = 0; i < 10 * kFlushCount; ++i) {
1211 context->flush();
1212 }
1213 REPORTER_ASSERT(reporter, 10 == cache->getResourceCount());
1198 } 1214 }
1199 1215
1200 static void test_large_resource_count(skiatest::Reporter* reporter) { 1216 static void test_large_resource_count(skiatest::Reporter* reporter) {
1201 // Set the cache size to double the resource count because we're going to cr eate 2x that number 1217 // Set the cache size to double the resource count because we're going to cr eate 2x that number
1202 // resources, using two different key domains. Add a little slop to the byte s because we resize 1218 // resources, using two different key domains. Add a little slop to the byte s because we resize
1203 // down to 1 byte after creating the resource. 1219 // down to 1 byte after creating the resource.
1204 static const int kResourceCnt = 2000; 1220 static const int kResourceCnt = 2000;
1205 1221
1206 Mock mock(2 * kResourceCnt, 2 * kResourceCnt + 1000); 1222 Mock mock(2 * kResourceCnt, 2 * kResourceCnt + 1000);
1207 GrContext* context = mock.context(); 1223 GrContext* context = mock.context();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 test_cache_chained_purge(reporter); 1328 test_cache_chained_purge(reporter);
1313 test_resource_size_changed(reporter); 1329 test_resource_size_changed(reporter);
1314 test_timestamp_wrap(reporter); 1330 test_timestamp_wrap(reporter);
1315 test_flush(reporter); 1331 test_flush(reporter);
1316 test_large_resource_count(reporter); 1332 test_large_resource_count(reporter);
1317 test_custom_data(reporter); 1333 test_custom_data(reporter);
1318 test_abandoned(reporter); 1334 test_abandoned(reporter);
1319 } 1335 }
1320 1336
1321 #endif 1337 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawingManager.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698