| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 void* writable_data() { return fData; } | 25 void* writable_data() { return fData; } |
| 26 | 26 |
| 27 void ref() const { this->internalRef(false); } | 27 void ref() const { this->internalRef(false); } |
| 28 void unref() const { this->internalUnref(false); } | 28 void unref() const { this->internalUnref(false); } |
| 29 | 29 |
| 30 int testing_only_getRefCnt() const { return fRefCnt; } | 30 int testing_only_getRefCnt() const { return fRefCnt; } |
| 31 bool testing_only_isLocked() const { return fIsLocked; } | 31 bool testing_only_isLocked() const { return fIsLocked; } |
| 32 bool testing_only_isInCache() const { return fInCache; } | 32 bool testing_only_isInCache() const { return fInCache; } |
| 33 | 33 |
| 34 SkDiscardableMemory* diagnostic_only_getDiscardable() const { |
| 35 return kDiscardableMemory_StorageType == fStorageType ? fStorage.fDM : n
ullptr; |
| 36 } |
| 37 |
| 34 protected: | 38 protected: |
| 35 // called when fData changes. could be NULL. | 39 // called when fData changes. could be NULL. |
| 36 virtual void onDataChange(void* oldData, void* newData) {} | 40 virtual void onDataChange(void* oldData, void* newData) {} |
| 37 | 41 |
| 38 private: | 42 private: |
| 39 SkMutex fMutex; // could use a pool of these... | 43 SkMutex fMutex; // could use a pool of these... |
| 40 | 44 |
| 41 enum StorageType { | 45 enum StorageType { |
| 42 kDiscardableMemory_StorageType, | 46 kDiscardableMemory_StorageType, |
| 43 kMalloc_StorageType | 47 kMalloc_StorageType |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void attachToCacheAndRef() const { this->internalRef(true); } | 103 void attachToCacheAndRef() const { this->internalRef(true); } |
| 100 | 104 |
| 101 /* | 105 /* |
| 102 * Call when removing this instance from a SkResourceCache::Rec subclass | 106 * Call when removing this instance from a SkResourceCache::Rec subclass |
| 103 * (typically in the Rec's destructor). | 107 * (typically in the Rec's destructor). |
| 104 */ | 108 */ |
| 105 void detachFromCacheAndUnref() const { this->internalUnref(true); } | 109 void detachFromCacheAndUnref() const { this->internalUnref(true); } |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 #endif | 112 #endif |
| OLD | NEW |