michael@0: michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #ifndef SkImageRefPool_DEFINED michael@0: #define SkImageRefPool_DEFINED michael@0: michael@0: #include "SkTypes.h" michael@0: michael@0: class SkImageRef; michael@0: class SkImageRef_GlobalPool; michael@0: michael@0: class SkImageRefPool { michael@0: public: michael@0: SkImageRefPool(); michael@0: ~SkImageRefPool(); michael@0: michael@0: size_t getRAMBudget() const { return fRAMBudget; } michael@0: void setRAMBudget(size_t); michael@0: michael@0: size_t getRAMUsed() const { return fRAMUsed; } michael@0: void setRAMUsed(size_t limit); michael@0: michael@0: void addToHead(SkImageRef*); michael@0: void addToTail(SkImageRef*); michael@0: void detach(SkImageRef*); michael@0: michael@0: void dump() const; michael@0: michael@0: private: michael@0: size_t fRAMBudget; michael@0: size_t fRAMUsed; michael@0: michael@0: int fCount; michael@0: SkImageRef* fHead, *fTail; michael@0: michael@0: int computeCount() const; michael@0: michael@0: friend class SkImageRef_GlobalPool; michael@0: michael@0: void justAddedPixels(SkImageRef*); michael@0: void canLosePixels(SkImageRef*); michael@0: void purgeIfNeeded(); michael@0: }; michael@0: michael@0: #endif