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 "SkAtomics.h" | 15 #include "SkThread.h" |
16 | 16 |
17 /** | 17 /** |
18 * 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... |
19 * (1) get access a bitmap in the heap | 19 * (1) get access a bitmap in the heap |
20 * (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). |
21 */ | 21 */ |
22 class SkBitmapHeapEntry : SkNoncopyable { | 22 class SkBitmapHeapEntry : SkNoncopyable { |
23 public: | 23 public: |
24 ~SkBitmapHeapEntry(); | 24 ~SkBitmapHeapEntry(); |
25 | 25 |
(...skipping 19 matching lines...) Expand all Loading... |
45 // reclaimed. | 45 // reclaimed. |
46 size_t fBytesAllocated; | 46 size_t fBytesAllocated; |
47 | 47 |
48 friend class SkBitmapHeap; | 48 friend class SkBitmapHeap; |
49 friend class SkBitmapHeapTester; | 49 friend class SkBitmapHeapTester; |
50 }; | 50 }; |
51 | 51 |
52 | 52 |
53 class SkBitmapHeapReader : public SkRefCnt { | 53 class SkBitmapHeapReader : public SkRefCnt { |
54 public: | 54 public: |
55 | 55 |
56 | 56 |
57 SkBitmapHeapReader() : INHERITED() {} | 57 SkBitmapHeapReader() : INHERITED() {} |
58 virtual SkBitmap* getBitmap(int32_t slot) const = 0; | 58 virtual SkBitmap* getBitmap(int32_t slot) const = 0; |
59 virtual void releaseRef(int32_t slot) = 0; | 59 virtual void releaseRef(int32_t slot) = 0; |
60 private: | 60 private: |
61 typedef SkRefCnt INHERITED; | 61 typedef SkRefCnt INHERITED; |
62 }; | 62 }; |
63 | 63 |
64 | 64 |
65 /** | 65 /** |
66 * TODO: stores immutable bitmaps into a heap | 66 * TODO: stores immutable bitmaps into a heap |
67 */ | 67 */ |
68 class SkBitmapHeap : public SkBitmapHeapReader { | 68 class SkBitmapHeap : public SkBitmapHeapReader { |
69 public: | 69 public: |
70 class ExternalStorage : public SkRefCnt { | 70 class ExternalStorage : public SkRefCnt { |
71 public: | 71 public: |
72 | 72 |
73 | 73 |
74 virtual bool insert(const SkBitmap& bitmap, int32_t slot) = 0; | 74 virtual bool insert(const SkBitmap& bitmap, int32_t slot) = 0; |
75 | 75 |
76 private: | 76 private: |
77 typedef SkRefCnt INHERITED; | 77 typedef SkRefCnt INHERITED; |
78 }; | 78 }; |
79 | 79 |
80 static const int32_t UNLIMITED_SIZE = -1; | 80 static const int32_t UNLIMITED_SIZE = -1; |
81 static const int32_t IGNORE_OWNERS = -1; | 81 static const int32_t IGNORE_OWNERS = -1; |
82 static const int32_t INVALID_SLOT = -1; | 82 static const int32_t INVALID_SLOT = -1; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 const int32_t fOwnerCount; | 289 const int32_t fOwnerCount; |
290 size_t fBytesAllocated; | 290 size_t fBytesAllocated; |
291 | 291 |
292 bool fDeferAddingOwners; | 292 bool fDeferAddingOwners; |
293 SkTDArray<int> fDeferredEntries; | 293 SkTDArray<int> fDeferredEntries; |
294 | 294 |
295 typedef SkBitmapHeapReader INHERITED; | 295 typedef SkBitmapHeapReader INHERITED; |
296 }; | 296 }; |
297 | 297 |
298 #endif // SkBitmapHeap_DEFINED | 298 #endif // SkBitmapHeap_DEFINED |
OLD | NEW |