| 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 | 9 |
| 10 #include "GrGpuResource.h" | 10 #include "GrGpuResource.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 fContentKey = contentKey; | 92 fContentKey = contentKey; |
| 93 fContentKeySet = true; | 93 fContentKeySet = true; |
| 94 | 94 |
| 95 if (!get_resource_cache2(fGpu)->didSetContentKey(this)) { | 95 if (!get_resource_cache2(fGpu)->didSetContentKey(this)) { |
| 96 fContentKeySet = false; | 96 fContentKeySet = false; |
| 97 return false; | 97 return false; |
| 98 } | 98 } |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void GrGpuResource::setCacheEntry(GrResourceCacheEntry* cacheEntry) { | |
| 103 // GrResourceCache never changes the cacheEntry once one has been added. | |
| 104 SkASSERT(NULL == cacheEntry || NULL == fCacheEntry); | |
| 105 fCacheEntry = cacheEntry; | |
| 106 } | |
| 107 | |
| 108 void GrGpuResource::notifyIsPurgable() const { | 102 void GrGpuResource::notifyIsPurgable() const { |
| 109 if (fCacheEntry && !this->wasDestroyed()) { | 103 if (fCacheEntry && !this->wasDestroyed()) { |
| 110 get_resource_cache(fGpu)->notifyPurgable(this); | 104 get_resource_cache(fGpu)->notifyPurgable(this); |
| 111 } | 105 } |
| 112 } | 106 } |
| 113 | 107 |
| 114 void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) { | 108 void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) { |
| 115 SkASSERT(fScratchKey.isNullScratch()); | 109 SkASSERT(fScratchKey.isNullScratch()); |
| 116 SkASSERT(scratchKey.isScratch()); | 110 SkASSERT(scratchKey.isScratch()); |
| 117 SkASSERT(!scratchKey.isNullScratch()); | 111 SkASSERT(!scratchKey.isNullScratch()); |
| 118 fScratchKey = scratchKey; | 112 fScratchKey = scratchKey; |
| 119 } | 113 } |
| 120 | 114 |
| 121 const GrResourceKey* GrGpuResource::getContentKey() const { | |
| 122 if (fContentKeySet) { | |
| 123 return &fContentKey; | |
| 124 } | |
| 125 return NULL; | |
| 126 } | |
| 127 | |
| 128 bool GrGpuResource::isScratch() const { | |
| 129 SkASSERT(fScratchKey.isScratch()); | |
| 130 return NULL == this->getContentKey() && !fScratchKey.isNullScratch(); | |
| 131 } | |
| 132 | |
| 133 uint32_t GrGpuResource::CreateUniqueID() { | 115 uint32_t GrGpuResource::CreateUniqueID() { |
| 134 static int32_t gUniqueID = SK_InvalidUniqueID; | 116 static int32_t gUniqueID = SK_InvalidUniqueID; |
| 135 uint32_t id; | 117 uint32_t id; |
| 136 do { | 118 do { |
| 137 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 119 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 138 } while (id == SK_InvalidUniqueID); | 120 } while (id == SK_InvalidUniqueID); |
| 139 return id; | 121 return id; |
| 140 } | 122 } |
| OLD | NEW |