OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 #include "GrGpuResource.h" | 8 #include "GrGpuResource.h" |
10 #include "GrContext.h" | 9 #include "GrContext.h" |
11 #include "GrResourceCache.h" | 10 #include "GrResourceCache.h" |
(...skipping 18 matching lines...) Expand all Loading... |
30 | 29 |
31 void GrGpuResource::registerWithCache() { | 30 void GrGpuResource::registerWithCache() { |
32 get_resource_cache(fGpu)->resourceAccess().insertResource(this); | 31 get_resource_cache(fGpu)->resourceAccess().insertResource(this); |
33 } | 32 } |
34 | 33 |
35 GrGpuResource::~GrGpuResource() { | 34 GrGpuResource::~GrGpuResource() { |
36 // The cache should have released or destroyed this resource. | 35 // The cache should have released or destroyed this resource. |
37 SkASSERT(this->wasDestroyed()); | 36 SkASSERT(this->wasDestroyed()); |
38 } | 37 } |
39 | 38 |
40 void GrGpuResource::release() { | 39 void GrGpuResource::release() { |
41 SkASSERT(fGpu); | 40 SkASSERT(fGpu); |
42 this->onRelease(); | 41 this->onRelease(); |
43 get_resource_cache(fGpu)->resourceAccess().removeResource(this); | 42 get_resource_cache(fGpu)->resourceAccess().removeResource(this); |
44 fGpu = nullptr; | 43 fGpu = nullptr; |
45 fGpuMemorySize = 0; | 44 fGpuMemorySize = 0; |
46 } | 45 } |
47 | 46 |
48 void GrGpuResource::abandon() { | 47 void GrGpuResource::abandon() { |
49 if (this->wasDestroyed()) { | 48 if (this->wasDestroyed()) { |
50 return; | 49 return; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 197 } |
199 | 198 |
200 uint32_t GrGpuResource::CreateUniqueID() { | 199 uint32_t GrGpuResource::CreateUniqueID() { |
201 static int32_t gUniqueID = SK_InvalidUniqueID; | 200 static int32_t gUniqueID = SK_InvalidUniqueID; |
202 uint32_t id; | 201 uint32_t id; |
203 do { | 202 do { |
204 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 203 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
205 } while (id == SK_InvalidUniqueID); | 204 } while (id == SK_InvalidUniqueID); |
206 return id; | 205 return id; |
207 } | 206 } |
OLD | NEW |