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

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

Issue 394003003: Set maximum output size for scaled-image-cache images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rename, runtime Created 6 years, 5 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
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 "SkScaledImageCache.h" 9 #include "SkScaledImageCache.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 void SkScaledImageCache::init() { 135 void SkScaledImageCache::init() {
136 fHead = NULL; 136 fHead = NULL;
137 fTail = NULL; 137 fTail = NULL;
138 #ifdef USE_HASH 138 #ifdef USE_HASH
139 fHash = new Hash; 139 fHash = new Hash;
140 #else 140 #else
141 fHash = NULL; 141 fHash = NULL;
142 #endif 142 #endif
143 fBytesUsed = 0; 143 fBytesUsed = 0;
144 fCount = 0; 144 fCount = 0;
145 fMaximumOutputSizeForHighQualityFilter = 0;
145 fAllocator = NULL; 146 fAllocator = NULL;
146 147
147 // One of these should be explicit set by the caller after we return. 148 // One of these should be explicit set by the caller after we return.
148 fByteLimit = 0; 149 fByteLimit = 0;
149 fDiscardableFactory = NULL; 150 fDiscardableFactory = NULL;
150 } 151 }
151 152
152 #include "SkDiscardableMemory.h" 153 #include "SkDiscardableMemory.h"
153 154
154 class SkOneShotDiscardablePixelRef : public SkPixelRef { 155 class SkOneShotDiscardablePixelRef : public SkPixelRef {
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 while (rec) { 632 while (rec) {
632 locked += rec->fLockCount > 0; 633 locked += rec->fLockCount > 0;
633 rec = rec->fNext; 634 rec = rec->fNext;
634 } 635 }
635 636
636 SkDebugf("SkScaledImageCache: count=%d bytes=%d locked=%d %s\n", 637 SkDebugf("SkScaledImageCache: count=%d bytes=%d locked=%d %s\n",
637 fCount, fBytesUsed, locked, 638 fCount, fBytesUsed, locked,
638 fDiscardableFactory ? "discardable" : "malloc"); 639 fDiscardableFactory ? "discardable" : "malloc");
639 } 640 }
640 641
642 void SkScaledImageCache::setMaximumOutputSizeForHighQualityFilter(size_t size) {
643 fMaximumOutputSizeForHighQualityFilter = size;
644 }
645
646 size_t SkScaledImageCache::getMaximumOutputSizeForHighQualityFilter() const {
647 return fMaximumOutputSizeForHighQualityFilter;
648 }
649
641 /////////////////////////////////////////////////////////////////////////////// 650 ///////////////////////////////////////////////////////////////////////////////
642 651
643 #include "SkThread.h" 652 #include "SkThread.h"
644 653
645 SK_DECLARE_STATIC_MUTEX(gMutex); 654 SK_DECLARE_STATIC_MUTEX(gMutex);
646 static SkScaledImageCache* gScaledImageCache = NULL; 655 static SkScaledImageCache* gScaledImageCache = NULL;
647 static void cleanup_gScaledImageCache() { 656 static void cleanup_gScaledImageCache() {
648 // We'll clean this up in our own tests, but disable for clients. 657 // We'll clean this up in our own tests, but disable for clients.
649 // Chrome seems to have funky multi-process things going on in unit tests th at 658 // Chrome seems to have funky multi-process things going on in unit tests th at
650 // makes this unsafe to delete when the main process atexit()s. 659 // makes this unsafe to delete when the main process atexit()s.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 SkBitmap::Allocator* SkScaledImageCache::GetAllocator() { 751 SkBitmap::Allocator* SkScaledImageCache::GetAllocator() {
743 SkAutoMutexAcquire am(gMutex); 752 SkAutoMutexAcquire am(gMutex);
744 return get_cache()->allocator(); 753 return get_cache()->allocator();
745 } 754 }
746 755
747 void SkScaledImageCache::Dump() { 756 void SkScaledImageCache::Dump() {
748 SkAutoMutexAcquire am(gMutex); 757 SkAutoMutexAcquire am(gMutex);
749 get_cache()->dump(); 758 get_cache()->dump();
750 } 759 }
751 760
761 void SkScaledImageCache::SetMaximumOutputSizeForHighQualityFilter(size_t size) {
762 SkAutoMutexAcquire am(gMutex);
763 get_cache()->setMaximumOutputSizeForHighQualityFilter(size);
764 }
765
766 size_t SkScaledImageCache::GetMaximumOutputSizeForHighQualityFilter() {
767 SkAutoMutexAcquire am(gMutex);
768 return get_cache()->getMaximumOutputSizeForHighQualityFilter();
769 }
770
752 /////////////////////////////////////////////////////////////////////////////// 771 ///////////////////////////////////////////////////////////////////////////////
753 772
754 #include "SkGraphics.h" 773 #include "SkGraphics.h"
755 774
756 size_t SkGraphics::GetImageCacheBytesUsed() { 775 size_t SkGraphics::GetImageCacheBytesUsed() {
757 return SkScaledImageCache::GetBytesUsed(); 776 return SkScaledImageCache::GetBytesUsed();
758 } 777 }
759 778
760 size_t SkGraphics::GetImageCacheByteLimit() { 779 size_t SkGraphics::GetImageCacheByteLimit() {
761 return SkScaledImageCache::GetByteLimit(); 780 return SkScaledImageCache::GetByteLimit();
762 } 781 }
763 782
764 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) { 783 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) {
765 return SkScaledImageCache::SetByteLimit(newLimit); 784 return SkScaledImageCache::SetByteLimit(newLimit);
766 } 785 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698