Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: src/core/SkCachedData.h

Issue 1214603003: Revert of Remove SkThread.h, include SkMutex.h or SkAtomics.h as appropriate. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkBitmapHeap.h ('k') | src/core/SkClipStack.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "SkMutex.h" 11 #include "SkThread.h"
12 12
13 class SkDiscardableMemory; 13 class SkDiscardableMemory;
14 14
15 class SkCachedData : ::SkNoncopyable { 15 class SkCachedData : ::SkNoncopyable {
16 public: 16 public:
17 SkCachedData(void* mallocData, size_t size); 17 SkCachedData(void* mallocData, size_t size);
18 SkCachedData(size_t size, SkDiscardableMemory*); 18 SkCachedData(size_t size, SkDiscardableMemory*);
19 virtual ~SkCachedData(); 19 virtual ~SkCachedData();
20 20
21 size_t size() const { return fSize; } 21 size_t size() const { return fSize; }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 class AutoMutexWritable; 73 class AutoMutexWritable;
74 74
75 public: 75 public:
76 #ifdef SK_DEBUG 76 #ifdef SK_DEBUG
77 void validate() const; 77 void validate() const;
78 #else 78 #else
79 void validate() const {} 79 void validate() const {}
80 #endif 80 #endif
81 81
82 /* 82 /*
83 * Attaching a data to to a SkResourceCache (only one at a time) enables th e data to be 83 * Attaching a data to to a SkResourceCache (only one at a time) enables th e data to be
84 * unlocked when the cache is the only owner, thus freeing it to be purged (assuming the 84 * unlocked when the cache is the only owner, thus freeing it to be purged (assuming the
85 * data is backed by a SkDiscardableMemory). 85 * data is backed by a SkDiscardableMemory).
86 * 86 *
87 * When attached, it also automatically attempts to "lock" the data when th e first client 87 * When attached, it also automatically attempts to "lock" the data when th e first client
88 * ref's the data (typically from a find(key, visitor) call). 88 * ref's the data (typically from a find(key, visitor) call).
89 * 89 *
90 * Thus the data will always be "locked" when a non-cache has a ref on it ( whether or not 90 * Thus the data will always be "locked" when a non-cache has a ref on it ( whether or not
91 * the lock succeeded to recover the memory -- check data() to see if it is NULL). 91 * the lock succeeded to recover the memory -- check data() to see if it is NULL).
92 */ 92 */
93 93
94 /* 94 /*
95 * Call when adding this instance to a SkResourceCache::Rec subclass 95 * Call when adding this instance to a SkResourceCache::Rec subclass
96 * (typically in the Rec's constructor). 96 * (typically in the Rec's constructor).
97 */ 97 */
98 void attachToCacheAndRef() const { this->internalRef(true); } 98 void attachToCacheAndRef() const { this->internalRef(true); }
99 99
100 /* 100 /*
101 * Call when removing this instance from a SkResourceCache::Rec subclass 101 * Call when removing this instance from a SkResourceCache::Rec subclass
102 * (typically in the Rec's destructor). 102 * (typically in the Rec's destructor).
103 */ 103 */
104 void detachFromCacheAndUnref() const { this->internalUnref(true); } 104 void detachFromCacheAndUnref() const { this->internalUnref(true); }
105 }; 105 };
106 106
107 #endif 107 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapHeap.h ('k') | src/core/SkClipStack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698