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

Side by Side Diff: src/core/SkResourceCache.cpp

Issue 960563002: only notify bitmaps that have been added to the cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address reviewer comments Created 5 years, 9 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/SkPixelRef.cpp ('k') | src/gpu/SkGrPixelRef.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 "SkMessageBus.h" 9 #include "SkMessageBus.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (!forcePurge && fTotalBytesUsed < byteLimit && fCount < countLimit) { 298 if (!forcePurge && fTotalBytesUsed < byteLimit && fCount < countLimit) {
299 break; 299 break;
300 } 300 }
301 301
302 Rec* prev = rec->fPrev; 302 Rec* prev = rec->fPrev;
303 this->remove(rec); 303 this->remove(rec);
304 rec = prev; 304 rec = prev;
305 } 305 }
306 } 306 }
307 307
308 //#define SK_TRACK_PURGE_SHAREDID_HITRATE
309
310 #ifdef SK_TRACK_PURGE_SHAREDID_HITRATE
311 static int gPurgeCallCounter;
312 static int gPurgeHitCounter;
313 #endif
314
308 void SkResourceCache::purgeSharedID(uint64_t sharedID) { 315 void SkResourceCache::purgeSharedID(uint64_t sharedID) {
309 if (0 == sharedID) { 316 if (0 == sharedID) {
310 return; 317 return;
311 } 318 }
312 319
320 #ifdef SK_TRACK_PURGE_SHAREDID_HITRATE
321 gPurgeCallCounter += 1;
322 bool found = false;
323 #endif
313 // go backwards, just like purgeAsNeeded, just to make the code similar. 324 // go backwards, just like purgeAsNeeded, just to make the code similar.
314 // could iterate either direction and still be correct. 325 // could iterate either direction and still be correct.
315 Rec* rec = fTail; 326 Rec* rec = fTail;
316 while (rec) { 327 while (rec) {
317 Rec* prev = rec->fPrev; 328 Rec* prev = rec->fPrev;
318 if (rec->getKey().getSharedID() == sharedID) { 329 if (rec->getKey().getSharedID() == sharedID) {
319 // SkDebugf("purgeSharedID id=%llx rec=%p\n", sharedID, rec); 330 // SkDebugf("purgeSharedID id=%llx rec=%p\n", sharedID, rec);
320 this->remove(rec); 331 this->remove(rec);
332 #ifdef SK_TRACK_PURGE_SHAREDID_HITRATE
333 found = true;
334 #endif
321 } 335 }
322 rec = prev; 336 rec = prev;
323 } 337 }
338
339 #ifdef SK_TRACK_PURGE_SHAREDID_HITRATE
340 if (found) {
341 gPurgeHitCounter += 1;
342 }
343
344 SkDebugf("PurgeShared calls=%d hits=%d rate=%g\n", gPurgeCallCounter, gPurge HitCounter,
345 gPurgeHitCounter * 100.0 / gPurgeCallCounter);
346 #endif
324 } 347 }
325 348
326 size_t SkResourceCache::setTotalByteLimit(size_t newLimit) { 349 size_t SkResourceCache::setTotalByteLimit(size_t newLimit) {
327 size_t prevLimit = fTotalByteLimit; 350 size_t prevLimit = fTotalByteLimit;
328 fTotalByteLimit = newLimit; 351 fTotalByteLimit = newLimit;
329 if (newLimit < prevLimit) { 352 if (newLimit < prevLimit) {
330 this->purgeAsNeeded(); 353 this->purgeAsNeeded();
331 } 354 }
332 return prevLimit; 355 return prevLimit;
333 } 356 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 } 636 }
614 637
615 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) { 638 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) {
616 return SkResourceCache::SetSingleAllocationByteLimit(newLimit); 639 return SkResourceCache::SetSingleAllocationByteLimit(newLimit);
617 } 640 }
618 641
619 void SkGraphics::PurgeResourceCache() { 642 void SkGraphics::PurgeResourceCache() {
620 return SkResourceCache::PurgeAll(); 643 return SkResourceCache::PurgeAll();
621 } 644 }
622 645
OLDNEW
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698