| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #ifndef SkBitmapHeap_DEFINED | 8 #ifndef SkBitmapHeap_DEFINED |
| 9 #define SkBitmapHeap_DEFINED | 9 #define SkBitmapHeap_DEFINED |
| 10 | 10 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkFlattenable.h" | 12 #include "SkFlattenable.h" |
| 13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
| 15 #include "SkThread.h" | 15 #include "SkThread.h" |
| 16 #include "SkTRefArray.h" | |
| 17 | 16 |
| 18 /** | 17 /** |
| 19 * SkBitmapHeapEntry provides users of SkBitmapHeap (using internal storage) wit
h a means to... | 18 * SkBitmapHeapEntry provides users of SkBitmapHeap (using internal storage) wit
h a means to... |
| 20 * (1) get access a bitmap in the heap | 19 * (1) get access a bitmap in the heap |
| 21 * (2) indicate they are done with bitmap by releasing their reference (if they
were an owner). | 20 * (2) indicate they are done with bitmap by releasing their reference (if they
were an owner). |
| 22 */ | 21 */ |
| 23 class SkBitmapHeapEntry : SkNoncopyable { | 22 class SkBitmapHeapEntry : SkNoncopyable { |
| 24 public: | 23 public: |
| 25 ~SkBitmapHeapEntry(); | 24 ~SkBitmapHeapEntry(); |
| 26 | 25 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 * | 106 * |
| 108 * @param externalStorage The class responsible for storing the bitmaps ins
erted into the heap | 107 * @param externalStorage The class responsible for storing the bitmaps ins
erted into the heap |
| 109 * @param heapSize The maximum size of the heap. Because of the sequential
limitation imposed | 108 * @param heapSize The maximum size of the heap. Because of the sequential
limitation imposed |
| 110 * by our LRU implementation we can guarantee that the heap will never gro
w beyond this size. | 109 * by our LRU implementation we can guarantee that the heap will never gro
w beyond this size. |
| 111 */ | 110 */ |
| 112 SkBitmapHeap(ExternalStorage* externalStorage, int32_t heapSize = UNLIMITED_
SIZE); | 111 SkBitmapHeap(ExternalStorage* externalStorage, int32_t heapSize = UNLIMITED_
SIZE); |
| 113 | 112 |
| 114 virtual ~SkBitmapHeap(); | 113 virtual ~SkBitmapHeap(); |
| 115 | 114 |
| 116 /** | 115 /** |
| 117 * Makes a shallow copy of all bitmaps currently in the heap and returns the
m as an array. The | |
| 118 * array indices match their position in the heap. | |
| 119 * | |
| 120 * @return a ptr to an array of bitmaps or NULL if external storage is bein
g used. | |
| 121 */ | |
| 122 SkTRefArray<SkBitmap>* extractBitmaps() const; | |
| 123 | |
| 124 /** | |
| 125 * Retrieves the bitmap from the specified slot in the heap | 116 * Retrieves the bitmap from the specified slot in the heap |
| 126 * | 117 * |
| 127 * @return The bitmap located at that slot or NULL if external storage is b
eing used. | 118 * @return The bitmap located at that slot or NULL if external storage is b
eing used. |
| 128 */ | 119 */ |
| 129 virtual SkBitmap* getBitmap(int32_t slot) const SK_OVERRIDE { | 120 virtual SkBitmap* getBitmap(int32_t slot) const SK_OVERRIDE { |
| 130 SkASSERT(fExternalStorage == NULL); | 121 SkASSERT(fExternalStorage == NULL); |
| 131 SkBitmapHeapEntry* entry = getEntry(slot); | 122 SkBitmapHeapEntry* entry = getEntry(slot); |
| 132 if (entry) { | 123 if (entry) { |
| 133 return &entry->fBitmap; | 124 return &entry->fBitmap; |
| 134 } | 125 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 const int32_t fOwnerCount; | 289 const int32_t fOwnerCount; |
| 299 size_t fBytesAllocated; | 290 size_t fBytesAllocated; |
| 300 | 291 |
| 301 bool fDeferAddingOwners; | 292 bool fDeferAddingOwners; |
| 302 SkTDArray<int> fDeferredEntries; | 293 SkTDArray<int> fDeferredEntries; |
| 303 | 294 |
| 304 typedef SkBitmapHeapReader INHERITED; | 295 typedef SkBitmapHeapReader INHERITED; |
| 305 }; | 296 }; |
| 306 | 297 |
| 307 #endif // SkBitmapHeap_DEFINED | 298 #endif // SkBitmapHeap_DEFINED |
| OLD | NEW |