| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "GrTextureProvider.h" | 8 #include "GrTextureProvider.h" |
| 9 #include "GrTexturePriv.h" | 9 #include "GrTexturePriv.h" |
| 10 #include "GrResourceCache.h" | 10 #include "GrResourceCache.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 return fGpu->wrapBackendTexture(desc, ownership); | 132 return fGpu->wrapBackendTexture(desc, ownership); |
| 133 } | 133 } |
| 134 | 134 |
| 135 GrRenderTarget* GrTextureProvider::wrapBackendRenderTarget(const GrBackendRender
TargetDesc& desc) { | 135 GrRenderTarget* GrTextureProvider::wrapBackendRenderTarget(const GrBackendRender
TargetDesc& desc) { |
| 136 ASSERT_SINGLE_OWNER | 136 ASSERT_SINGLE_OWNER |
| 137 return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(desc, | 137 return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(desc, |
| 138 kBorrow
_GrWrapOwnership); | 138 kBorrow
_GrWrapOwnership); |
| 139 } | 139 } |
| 140 | 140 |
| 141 GrRenderTarget* GrTextureProvider::wrapBackendTextureAsRenderTarget(const GrBack
endTextureDesc& desc, |
| 142 GrWrapOwners
hip ownership) { |
| 143 ASSERT_SINGLE_OWNER |
| 144 if (this->isAbandoned()) { |
| 145 return nullptr; |
| 146 } |
| 147 return fGpu->wrapBackendTextureAsRenderTarget(desc, ownership); |
| 148 } |
| 149 |
| 141 void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuR
esource* resource) { | 150 void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuR
esource* resource) { |
| 142 ASSERT_SINGLE_OWNER | 151 ASSERT_SINGLE_OWNER |
| 143 if (this->isAbandoned() || !resource) { | 152 if (this->isAbandoned() || !resource) { |
| 144 return; | 153 return; |
| 145 } | 154 } |
| 146 resource->resourcePriv().setUniqueKey(key); | 155 resource->resourcePriv().setUniqueKey(key); |
| 147 } | 156 } |
| 148 | 157 |
| 149 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons
t { | 158 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons
t { |
| 150 ASSERT_SINGLE_OWNER | 159 ASSERT_SINGLE_OWNER |
| 151 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); | 160 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); |
| 152 } | 161 } |
| 153 | 162 |
| 154 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe
y& key) { | 163 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe
y& key) { |
| 155 ASSERT_SINGLE_OWNER | 164 ASSERT_SINGLE_OWNER |
| 156 return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key)
; | 165 return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key)
; |
| 157 } | 166 } |
| 158 | 167 |
| 159 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke
y) { | 168 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke
y) { |
| 160 ASSERT_SINGLE_OWNER | 169 ASSERT_SINGLE_OWNER |
| 161 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); | 170 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); |
| 162 if (resource) { | 171 if (resource) { |
| 163 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); | 172 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); |
| 164 SkASSERT(texture); | 173 SkASSERT(texture); |
| 165 return texture; | 174 return texture; |
| 166 } | 175 } |
| 167 return NULL; | 176 return NULL; |
| 168 } | 177 } |
| OLD | NEW |