1 2 /* 3 * Copyright 2011 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 #ifndef SkImageRefPool_DEFINED 9 #define SkImageRefPool_DEFINED 10 11 #include "SkTypes.h" 12 13 class SkImageRef; 14 class SkImageRef_GlobalPool; 15 16 class SkImageRefPool { 17 public: 18 SkImageRefPool(); 19 ~SkImageRefPool(); 20 21 size_t getRAMBudget() const { return fRAMBudget; } 22 void setRAMBudget(size_t); 23 24 size_t getRAMUsed() const { return fRAMUsed; } 25 void setRAMUsed(size_t limit); 26 27 void addToHead(SkImageRef*); 28 void addToTail(SkImageRef*); 29 void detach(SkImageRef*); 30 31 void dump() const; 32 33 private: 34 size_t fRAMBudget; 35 size_t fRAMUsed; 36 37 int fCount; 38 SkImageRef* fHead, *fTail; 39 40 int computeCount() const; 41 42 friend class SkImageRef_GlobalPool; 43 44 void justAddedPixels(SkImageRef*); 45 void canLosePixels(SkImageRef*); 46 void purgeIfNeeded(); 47 }; 48 49 #endif 50