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

Side by Side Diff: tests/ResourceCacheTest.cpp

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 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 | « tests/RecordTestUtils.h ('k') | tests/SListTest.cpp » ('j') | 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 #if SK_SUPPORT_GPU 8 #if SK_SUPPORT_GPU
9 9
10 #include "GrContextFactory.h" 10 #include "GrContextFactory.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 : INHERITED(gpu, false) 67 : INHERITED(gpu, false)
68 , fCache(NULL) 68 , fCache(NULL)
69 , fToDelete(NULL) 69 , fToDelete(NULL)
70 , fSize(size) { 70 , fSize(size) {
71 ++fAlive; 71 ++fAlive;
72 this->registerWithCache(); 72 this->registerWithCache();
73 } 73 }
74 74
75 ~TestResource() { 75 ~TestResource() {
76 --fAlive; 76 --fAlive;
77 if (NULL != fToDelete) { 77 if (fToDelete) {
78 // Breaks our little 2-element cycle below. 78 // Breaks our little 2-element cycle below.
79 fToDelete->setDeleteWhenDestroyed(NULL, NULL); 79 fToDelete->setDeleteWhenDestroyed(NULL, NULL);
80 fCache->deleteResource(fToDelete->getCacheEntry()); 80 fCache->deleteResource(fToDelete->getCacheEntry());
81 } 81 }
82 this->release(); 82 this->release();
83 } 83 }
84 84
85 void setSize(size_t size) { 85 void setSize(size_t size) {
86 fSize = size; 86 fSize = size;
87 this->didChangeGpuMemorySize(); 87 this->didChangeGpuMemorySize();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 REPORTER_ASSERT(reporter, 300 == cache.getCachedResourceBytes()); 268 REPORTER_ASSERT(reporter, 300 == cache.getCachedResourceBytes());
269 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount()); 269 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
270 // Internal resource cache validation will test the detached size (debug mode only). 270 // Internal resource cache validation will test the detached size (debug mode only).
271 271
272 cache.makeNonExclusive(a->getCacheEntry()); 272 cache.makeNonExclusive(a->getCacheEntry());
273 a->unref(); 273 a->unref();
274 274
275 REPORTER_ASSERT(reporter, 300 == cache.getCachedResourceBytes()); 275 REPORTER_ASSERT(reporter, 300 == cache.getCachedResourceBytes());
276 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount()); 276 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
277 REPORTER_ASSERT(reporter, NULL != cache.find(key1)); 277 REPORTER_ASSERT(reporter, cache.find(key1));
278 // Internal resource cache validation will test the detached size (debug mode only). 278 // Internal resource cache validation will test the detached size (debug mode only).
279 } 279 }
280 } 280 }
281 281
282 //////////////////////////////////////////////////////////////////////////////// 282 ////////////////////////////////////////////////////////////////////////////////
283 DEF_GPUTEST(ResourceCache, reporter, factory) { 283 DEF_GPUTEST(ResourceCache, reporter, factory) {
284 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 284 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
285 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 285 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
286 if (!GrContextFactory::IsRenderingGLContext(glType)) { 286 if (!GrContextFactory::IsRenderingGLContext(glType)) {
287 continue; 287 continue;
(...skipping 14 matching lines...) Expand all
302 SkCanvas canvas(device.get()); 302 SkCanvas canvas(device.get());
303 303
304 test_cache(reporter, context, &canvas); 304 test_cache(reporter, context, &canvas);
305 test_purge_invalidated(reporter, context); 305 test_purge_invalidated(reporter, context);
306 test_cache_delete_on_destruction(reporter, context); 306 test_cache_delete_on_destruction(reporter, context);
307 test_resource_size_changed(reporter, context); 307 test_resource_size_changed(reporter, context);
308 } 308 }
309 } 309 }
310 310
311 #endif 311 #endif
OLDNEW
« no previous file with comments | « tests/RecordTestUtils.h ('k') | tests/SListTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698