| 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 | 9 |
| 10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 GrTexturePriv::ComputeScratchKey(*desc, &key); | 132 GrTexturePriv::ComputeScratchKey(*desc, &key); |
| 133 uint32_t scratchFlags = 0; | 133 uint32_t scratchFlags = 0; |
| 134 if (kNoPendingIO_ScratchTextureFlag & flags) { | 134 if (kNoPendingIO_ScratchTextureFlag & flags) { |
| 135 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; | 135 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; |
| 136 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { | 136 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { |
| 137 // If it is not a render target then it will most likely be populate
d by | 137 // If it is not a render target then it will most likely be populate
d by |
| 138 // writePixels() which will trigger a flush if the texture has pendi
ng IO. | 138 // writePixels() which will trigger a flush if the texture has pendi
ng IO. |
| 139 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; | 139 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; |
| 140 } | 140 } |
| 141 GrGpuResource* resource = fCache->findAndRefScratchResource(key, | 141 GrGpuResource* resource = fCache->findAndRefScratchResource(key, |
| 142 GrSurface::Wo
rseCaseSize(*desc), | 142 GrSurface::Wo
rstCaseSize(*desc), |
| 143 scratchFlags)
; | 143 scratchFlags)
; |
| 144 if (resource) { | 144 if (resource) { |
| 145 GrSurface* surface = static_cast<GrSurface*>(resource); | 145 GrSurface* surface = static_cast<GrSurface*>(resource); |
| 146 GrRenderTarget* rt = surface->asRenderTarget(); | 146 GrRenderTarget* rt = surface->asRenderTarget(); |
| 147 if (rt && fGpu->caps()->discardRenderTargetSupport()) { | 147 if (rt && fGpu->caps()->discardRenderTargetSupport()) { |
| 148 rt->discard(); | 148 rt->discard(); |
| 149 } | 149 } |
| 150 return surface->asTexture(); | 150 return surface->asTexture(); |
| 151 } | 151 } |
| 152 } | 152 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke
y) { | 194 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke
y) { |
| 195 ASSERT_SINGLE_OWNER | 195 ASSERT_SINGLE_OWNER |
| 196 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); | 196 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); |
| 197 if (resource) { | 197 if (resource) { |
| 198 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); | 198 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); |
| 199 SkASSERT(texture); | 199 SkASSERT(texture); |
| 200 return texture; | 200 return texture; |
| 201 } | 201 } |
| 202 return NULL; | 202 return NULL; |
| 203 } | 203 } |
| OLD | NEW |