epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 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(); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 20 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | size_t getRAMBudget() const { return fRAMBudget; } |
| 22 | void setRAMBudget(size_t); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 23 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 24 | size_t getRAMUsed() const { return fRAMUsed; } |
| 25 | void setRAMUsed(size_t limit); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 26 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 27 | void addToHead(SkImageRef*); |
| 28 | void addToTail(SkImageRef*); |
| 29 | void detach(SkImageRef*); |
| 30 | |
| 31 | void dump() const; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 32 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 33 | private: |
| 34 | size_t fRAMBudget; |
| 35 | size_t fRAMUsed; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 36 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | int fCount; |
| 38 | SkImageRef* fHead, *fTail; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 39 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | int computeCount() const; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 41 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 42 | friend class SkImageRef_GlobalPool; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 43 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 44 | void justAddedPixels(SkImageRef*); |
| 45 | void canLosePixels(SkImageRef*); |
| 46 | void purgeIfNeeded(); |
| 47 | }; |
| 48 | |
| 49 | #endif |