OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkCachedData_DEFINED | 8 #ifndef SkCachedData_DEFINED |
9 #define SkCachedData_DEFINED | 9 #define SkCachedData_DEFINED |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 void* writable_data() { return fData; } | 24 void* writable_data() { return fData; } |
25 | 25 |
26 void ref() const { this->internalRef(false); } | 26 void ref() const { this->internalRef(false); } |
27 void unref() const { this->internalUnref(false); } | 27 void unref() const { this->internalUnref(false); } |
28 | 28 |
29 int testing_only_getRefCnt() const { return fRefCnt; } | 29 int testing_only_getRefCnt() const { return fRefCnt; } |
30 bool testing_only_isLocked() const { return fIsLocked; } | 30 bool testing_only_isLocked() const { return fIsLocked; } |
31 bool testing_only_isInCache() const { return fInCache; } | 31 bool testing_only_isInCache() const { return fInCache; } |
32 | 32 |
| 33 SkDiscardableMemory* diagnostic_only_getDiscardable() const { |
| 34 return kDiscardableMemory_StorageType == fStorageType ? fStorage.fDM : n
ullptr; |
| 35 } |
| 36 |
33 protected: | 37 protected: |
34 // called when fData changes. could be NULL. | 38 // called when fData changes. could be NULL. |
35 virtual void onDataChange(void* oldData, void* newData) {} | 39 virtual void onDataChange(void* oldData, void* newData) {} |
36 | 40 |
37 private: | 41 private: |
38 SkMutex fMutex; // could use a pool of these... | 42 SkMutex fMutex; // could use a pool of these... |
39 | 43 |
40 enum StorageType { | 44 enum StorageType { |
41 kDiscardableMemory_StorageType, | 45 kDiscardableMemory_StorageType, |
42 kMalloc_StorageType | 46 kMalloc_StorageType |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 void attachToCacheAndRef() const { this->internalRef(true); } | 102 void attachToCacheAndRef() const { this->internalRef(true); } |
99 | 103 |
100 /* | 104 /* |
101 * Call when removing this instance from a SkResourceCache::Rec subclass | 105 * Call when removing this instance from a SkResourceCache::Rec subclass |
102 * (typically in the Rec's destructor). | 106 * (typically in the Rec's destructor). |
103 */ | 107 */ |
104 void detachFromCacheAndUnref() const { this->internalUnref(true); } | 108 void detachFromCacheAndUnref() const { this->internalUnref(true); } |
105 }; | 109 }; |
106 | 110 |
107 #endif | 111 #endif |
OLD | NEW |