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 "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 GrGpuResource::~GrGpuResource() { | 34 GrGpuResource::~GrGpuResource() { |
35 // The cache should have released or destroyed this resource. | 35 // The cache should have released or destroyed this resource. |
36 SkASSERT(this->wasDestroyed()); | 36 SkASSERT(this->wasDestroyed()); |
37 } | 37 } |
38 | 38 |
39 void GrGpuResource::release() { | 39 void GrGpuResource::release() { |
40 SkASSERT(fGpu); | 40 SkASSERT(fGpu); |
41 this->onRelease(); | 41 this->onRelease(); |
42 get_resource_cache(fGpu)->resourceAccess().removeResource(this); | 42 get_resource_cache(fGpu)->resourceAccess().removeResource(this); |
43 fGpu = NULL; | 43 fGpu = nullptr; |
44 fGpuMemorySize = 0; | 44 fGpuMemorySize = 0; |
45 } | 45 } |
46 | 46 |
47 void GrGpuResource::abandon() { | 47 void GrGpuResource::abandon() { |
48 SkASSERT(fGpu); | 48 SkASSERT(fGpu); |
49 this->onAbandon(); | 49 this->onAbandon(); |
50 get_resource_cache(fGpu)->resourceAccess().removeResource(this); | 50 get_resource_cache(fGpu)->resourceAccess().removeResource(this); |
51 fGpu = NULL; | 51 fGpu = nullptr; |
52 fGpuMemorySize = 0; | 52 fGpuMemorySize = 0; |
53 } | 53 } |
54 | 54 |
55 const SkData* GrGpuResource::setCustomData(const SkData* data) { | 55 const SkData* GrGpuResource::setCustomData(const SkData* data) { |
56 SkSafeRef(data); | 56 SkSafeRef(data); |
57 fData.reset(data); | 57 fData.reset(data); |
58 return data; | 58 return data; |
59 } | 59 } |
60 | 60 |
61 const GrContext* GrGpuResource::getContext() const { | 61 const GrContext* GrGpuResource::getContext() const { |
62 if (fGpu) { | 62 if (fGpu) { |
63 return fGpu->getContext(); | 63 return fGpu->getContext(); |
64 } else { | 64 } else { |
65 return NULL; | 65 return nullptr; |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 GrContext* GrGpuResource::getContext() { | 69 GrContext* GrGpuResource::getContext() { |
70 if (fGpu) { | 70 if (fGpu) { |
71 return fGpu->getContext(); | 71 return fGpu->getContext(); |
72 } else { | 72 } else { |
73 return NULL; | 73 return nullptr; |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 void GrGpuResource::didChangeGpuMemorySize() const { | 77 void GrGpuResource::didChangeGpuMemorySize() const { |
78 if (this->wasDestroyed()) { | 78 if (this->wasDestroyed()) { |
79 return; | 79 return; |
80 } | 80 } |
81 | 81 |
82 size_t oldSize = fGpuMemorySize; | 82 size_t oldSize = fGpuMemorySize; |
83 SkASSERT(kInvalidGpuMemorySize != oldSize); | 83 SkASSERT(kInvalidGpuMemorySize != oldSize); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 173 } |
174 | 174 |
175 uint32_t GrGpuResource::CreateUniqueID() { | 175 uint32_t GrGpuResource::CreateUniqueID() { |
176 static int32_t gUniqueID = SK_InvalidUniqueID; | 176 static int32_t gUniqueID = SK_InvalidUniqueID; |
177 uint32_t id; | 177 uint32_t id; |
178 do { | 178 do { |
179 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 179 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
180 } while (id == SK_InvalidUniqueID); | 180 } while (id == SK_InvalidUniqueID); |
181 return id; | 181 return id; |
182 } | 182 } |
OLD | NEW |