OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 | 8 |
9 #include "GrGpuResource.h" | 9 #include "GrGpuResource.h" |
10 #include "GrResourceCache.h" | 10 #include "GrResourceCache.h" |
11 #include "GrGpu.h" | 11 #include "GrGpu.h" |
12 #include "GrGpuResourcePriv.h" | 12 #include "GrGpuResourcePriv.h" |
13 | 13 |
14 static inline GrResourceCache* get_resource_cache(GrGpu* gpu) { | 14 static inline GrResourceCache* get_resource_cache(GrGpu* gpu) { |
15 SkASSERT(gpu); | 15 SkASSERT(gpu); |
16 SkASSERT(gpu->getContext()); | 16 SkASSERT(gpu->getContext()); |
17 SkASSERT(gpu->getContext()->getResourceCache()); | 17 SkASSERT(gpu->getContext()->getResourceCache()); |
18 return gpu->getContext()->getResourceCache(); | 18 return gpu->getContext()->getResourceCache(); |
19 } | 19 } |
20 | 20 |
21 GrGpuResource::GrGpuResource(GrGpu* gpu, LifeCycle lifeCycle) | 21 GrGpuResource::GrGpuResource(GrGpu* gpu, LifeCycle lifeCycle) |
22 : fGpu(gpu) | 22 : fGpu(gpu) |
23 , fGpuMemorySize(kInvalidGpuMemorySize) | 23 , fGpuMemorySize(kInvalidGpuMemorySize) |
24 , fLifeCycle(lifeCycle) | 24 , fLifeCycle(lifeCycle) |
25 , fUniqueID(CreateUniqueID()) { | 25 , fUniqueID(CreateUniqueID()) { |
| 26 SkDEBUGCODE(fCacheArrayIndex = -1); |
26 } | 27 } |
27 | 28 |
28 void GrGpuResource::registerWithCache() { | 29 void GrGpuResource::registerWithCache() { |
29 get_resource_cache(fGpu)->resourceAccess().insertResource(this); | 30 get_resource_cache(fGpu)->resourceAccess().insertResource(this); |
30 } | 31 } |
31 | 32 |
32 GrGpuResource::~GrGpuResource() { | 33 GrGpuResource::~GrGpuResource() { |
33 // The cache should have released or destroyed this resource. | 34 // The cache should have released or destroyed this resource. |
34 SkASSERT(this->wasDestroyed()); | 35 SkASSERT(this->wasDestroyed()); |
35 } | 36 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 155 } |
155 | 156 |
156 uint32_t GrGpuResource::CreateUniqueID() { | 157 uint32_t GrGpuResource::CreateUniqueID() { |
157 static int32_t gUniqueID = SK_InvalidUniqueID; | 158 static int32_t gUniqueID = SK_InvalidUniqueID; |
158 uint32_t id; | 159 uint32_t id; |
159 do { | 160 do { |
160 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 161 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
161 } while (id == SK_InvalidUniqueID); | 162 } while (id == SK_InvalidUniqueID); |
162 return id; | 163 return id; |
163 } | 164 } |
OLD | NEW |