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 GrGpuResource_DEFINED | 8 #ifndef GrGpuResource_DEFINED |
9 #define GrGpuResource_DEFINED | 9 #define GrGpuResource_DEFINED |
10 | 10 |
11 #include "GrResourceKey.h" | 11 #include "GrResourceKey.h" |
12 #include "GrTypesPriv.h" | 12 #include "GrTypesPriv.h" |
13 #include "SkInstCnt.h" | 13 #include "SkInstCnt.h" |
14 #include "SkTInternalLList.h" | 14 #include "SkTInternalLList.h" |
15 | 15 |
16 class GrContext; | 16 class GrContext; |
17 class GrGpu; | 17 class GrGpu; |
18 class GrResourceCache2; | 18 class GrResourceCache2; |
19 class GrResourceCacheEntry; | |
20 | 19 |
21 /** | 20 /** |
22 * Base class for GrGpuResource. Handles the various types of refs we need. Sepa
rated out as a base | 21 * Base class for GrGpuResource. Handles the various types of refs we need. Sepa
rated out as a base |
23 * class to isolate the ref-cnting behavior and provide friendship without expos
ing all of | 22 * class to isolate the ref-cnting behavior and provide friendship without expos
ing all of |
24 * GrGpuResource. | 23 * GrGpuResource. |
25 * | 24 * |
26 * Gpu resources can have three types of refs: | 25 * Gpu resources can have three types of refs: |
27 * 1) Normal ref (+ by ref(), - by unref()): These are used by code that is is
suing draw calls | 26 * 1) Normal ref (+ by ref(), - by unref()): These are used by code that is is
suing draw calls |
28 * that read and write the resource via GrDrawTarget and by any object that
must own a | 27 * that read and write the resource via GrDrawTarget and by any object that
must own a |
29 * GrGpuResource and is itself owned (directly or indirectly) by Skia-clien
t code. | 28 * GrGpuResource and is itself owned (directly or indirectly) by Skia-clien
t code. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 mutable int32_t fPendingWrites; | 118 mutable int32_t fPendingWrites; |
120 | 119 |
121 // This class is used to manage conversion of refs to pending reads/writes. | 120 // This class is used to manage conversion of refs to pending reads/writes. |
122 friend class GrGpuResourceRef; | 121 friend class GrGpuResourceRef; |
123 friend class GrResourceCache2; // to check IO ref counts. | 122 friend class GrResourceCache2; // to check IO ref counts. |
124 | 123 |
125 template <typename, GrIOType> friend class GrPendingIOResource; | 124 template <typename, GrIOType> friend class GrPendingIOResource; |
126 }; | 125 }; |
127 | 126 |
128 /** | 127 /** |
129 * Base class for objects that can be kept in the GrResourceCache. | 128 * Base class for objects that can be kept in the GrResourceCache2. |
130 */ | 129 */ |
131 class SK_API GrGpuResource : public GrIORef<GrGpuResource> { | 130 class SK_API GrGpuResource : public GrIORef<GrGpuResource> { |
132 public: | 131 public: |
133 SK_DECLARE_INST_COUNT(GrGpuResource) | 132 SK_DECLARE_INST_COUNT(GrGpuResource) |
134 | 133 |
135 /** | 134 /** |
136 * Frees the object in the underlying 3D API. It must be safe to call this | 135 * Frees the object in the underlying 3D API. It must be safe to call this |
137 * when the object has been previously abandoned. | 136 * when the object has been previously abandoned. |
138 */ | 137 */ |
139 void release(); | 138 void release(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 * Lifetime management is left up to the user (i.e., we will not | 249 * Lifetime management is left up to the user (i.e., we will not |
251 * free it). | 250 * free it). |
252 */ | 251 */ |
253 kWrapped_FlagBit = 0x1, | 252 kWrapped_FlagBit = 0x1, |
254 }; | 253 }; |
255 | 254 |
256 static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0); | 255 static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0); |
257 | 256 |
258 uint32_t fFlags; | 257 uint32_t fFlags; |
259 | 258 |
260 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache | |
261 mutable size_t fGpuMemorySize; | 259 mutable size_t fGpuMemorySize; |
262 const uint32_t fUniqueID; | 260 const uint32_t fUniqueID; |
263 | 261 |
264 // TODO(bsalomon): Remove GrResourceKey and use different simpler types for
content and scratch | 262 // TODO(bsalomon): Remove GrResourceKey and use different simpler types for
content and scratch |
265 // keys. | 263 // keys. |
266 GrResourceKey fScratchKey; | 264 GrResourceKey fScratchKey; |
267 GrResourceKey fContentKey; | 265 GrResourceKey fContentKey; |
268 bool fContentKeySet; | 266 bool fContentKeySet; |
269 | 267 |
270 typedef GrIORef<GrGpuResource> INHERITED; | 268 typedef GrIORef<GrGpuResource> INHERITED; |
271 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. | 269 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. |
272 }; | 270 }; |
273 | 271 |
274 #endif | 272 #endif |
OLD | NEW |