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

Side by Side Diff: src/core/SkResourceCache.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 | « src/core/SkRecordDraw.cpp ('k') | src/core/SkScan_Path.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 #include "SkChecksum.h" 8 #include "SkChecksum.h"
9 #include "SkResourceCache.h" 9 #include "SkResourceCache.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 this->moveToHead(rec); // for our LRU 215 this->moveToHead(rec); // for our LRU
216 rec->fLockCount += 1; 216 rec->fLockCount += 1;
217 } 217 }
218 return rec; 218 return rec;
219 } 219 }
220 220
221 const SkResourceCache::Rec* SkResourceCache::addAndLock(Rec* rec) { 221 const SkResourceCache::Rec* SkResourceCache::addAndLock(Rec* rec) {
222 SkASSERT(rec); 222 SkASSERT(rec);
223 // See if we already have this key (racy inserts, etc.) 223 // See if we already have this key (racy inserts, etc.)
224 const Rec* existing = this->findAndLock(rec->getKey()); 224 const Rec* existing = this->findAndLock(rec->getKey());
225 if (NULL != existing) { 225 if (existing) {
226 SkDELETE(rec); 226 SkDELETE(rec);
227 return existing; 227 return existing;
228 } 228 }
229 229
230 this->addToHead(rec); 230 this->addToHead(rec);
231 SkASSERT(1 == rec->fLockCount); 231 SkASSERT(1 == rec->fLockCount);
232 #ifdef USE_HASH 232 #ifdef USE_HASH
233 SkASSERT(fHash); 233 SkASSERT(fHash);
234 fHash->add(rec); 234 fHash->add(rec);
235 #endif 235 #endif
236 // We may (now) be overbudget, so see if we need to purge something. 236 // We may (now) be overbudget, so see if we need to purge something.
237 this->purgeAsNeeded(); 237 this->purgeAsNeeded();
238 return rec; 238 return rec;
239 } 239 }
240 240
241 void SkResourceCache::add(Rec* rec) { 241 void SkResourceCache::add(Rec* rec) {
242 SkASSERT(rec); 242 SkASSERT(rec);
243 // See if we already have this key (racy inserts, etc.) 243 // See if we already have this key (racy inserts, etc.)
244 const Rec* existing = this->findAndLock(rec->getKey()); 244 const Rec* existing = this->findAndLock(rec->getKey());
245 if (NULL != existing) { 245 if (existing) {
246 SkDELETE(rec); 246 SkDELETE(rec);
247 this->unlock(existing); 247 this->unlock(existing);
248 return; 248 return;
249 } 249 }
250 250
251 this->addToHead(rec); 251 this->addToHead(rec);
252 SkASSERT(1 == rec->fLockCount); 252 SkASSERT(1 == rec->fLockCount);
253 #ifdef USE_HASH 253 #ifdef USE_HASH
254 SkASSERT(fHash); 254 SkASSERT(fHash);
255 fHash->add(rec); 255 fHash->add(rec);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 407 }
408 408
409 if (fHead == fTail) { 409 if (fHead == fTail) {
410 SkASSERT(NULL == fHead->fPrev); 410 SkASSERT(NULL == fHead->fPrev);
411 SkASSERT(NULL == fHead->fNext); 411 SkASSERT(NULL == fHead->fNext);
412 SkASSERT(fHead->bytesUsed() == fTotalBytesUsed); 412 SkASSERT(fHead->bytesUsed() == fTotalBytesUsed);
413 return; 413 return;
414 } 414 }
415 415
416 SkASSERT(NULL == fHead->fPrev); 416 SkASSERT(NULL == fHead->fPrev);
417 SkASSERT(NULL != fHead->fNext); 417 SkASSERT(fHead->fNext);
418 SkASSERT(NULL == fTail->fNext); 418 SkASSERT(NULL == fTail->fNext);
419 SkASSERT(NULL != fTail->fPrev); 419 SkASSERT(fTail->fPrev);
420 420
421 size_t used = 0; 421 size_t used = 0;
422 int count = 0; 422 int count = 0;
423 const Rec* rec = fHead; 423 const Rec* rec = fHead;
424 while (rec) { 424 while (rec) {
425 count += 1; 425 count += 1;
426 used += rec->bytesUsed(); 426 used += rec->bytesUsed();
427 SkASSERT(used <= fTotalBytesUsed); 427 SkASSERT(used <= fTotalBytesUsed);
428 rec = rec->fNext; 428 rec = rec->fNext;
429 } 429 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 } 573 }
574 574
575 size_t SkGraphics::GetResourceCacheSingleAllocationByteLimit() { 575 size_t SkGraphics::GetResourceCacheSingleAllocationByteLimit() {
576 return SkResourceCache::GetSingleAllocationByteLimit(); 576 return SkResourceCache::GetSingleAllocationByteLimit();
577 } 577 }
578 578
579 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) { 579 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) {
580 return SkResourceCache::SetSingleAllocationByteLimit(newLimit); 580 return SkResourceCache::SetSingleAllocationByteLimit(newLimit);
581 } 581 }
582 582
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | src/core/SkScan_Path.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698