Home | History | Annotate | Download | only in images
      1 #ifndef SkImageRefPool_DEFINED
      2 #define SkImageRefPool_DEFINED
      3 
      4 #include "SkTypes.h"
      5 
      6 class SkImageRef;
      7 class SkImageRef_GlobalPool;
      8 
      9 class SkImageRefPool {
     10 public:
     11     SkImageRefPool();
     12     ~SkImageRefPool();
     13 
     14     size_t  getRAMBudget() const { return fRAMBudget; }
     15     void    setRAMBudget(size_t);
     16 
     17     size_t  getRAMUsed() const { return fRAMUsed; }
     18     void    setRAMUsed(size_t limit);
     19 
     20     void addToHead(SkImageRef*);
     21     void addToTail(SkImageRef*);
     22     void detach(SkImageRef*);
     23 
     24     void dump() const;
     25 
     26 private:
     27     size_t fRAMBudget;
     28     size_t fRAMUsed;
     29 
     30     int         fCount;
     31     SkImageRef* fHead, *fTail;
     32 
     33     int computeCount() const;
     34 
     35     friend class SkImageRef_GlobalPool;
     36 
     37     void justAddedPixels(SkImageRef*);
     38     void canLosePixels(SkImageRef*);
     39     void purgeIfNeeded();
     40 };
     41 
     42 #endif
     43 
     44