| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 "GrTextureProvider.h" | 9 #include "GrTextureProvider.h" |
| 10 #include "GrTexturePriv.h" | 10 #include "GrTexturePriv.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 GrScratchKey key; | 79 GrScratchKey key; |
| 80 GrTexturePriv::ComputeScratchKey(*desc, &key); | 80 GrTexturePriv::ComputeScratchKey(*desc, &key); |
| 81 uint32_t scratchFlags = 0; | 81 uint32_t scratchFlags = 0; |
| 82 if (kNoPendingIO_ScratchTextureFlag & flags) { | 82 if (kNoPendingIO_ScratchTextureFlag & flags) { |
| 83 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; | 83 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; |
| 84 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { | 84 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { |
| 85 // If it is not a render target then it will most likely be populate
d by | 85 // If it is not a render target then it will most likely be populate
d by |
| 86 // writePixels() which will trigger a flush if the texture has pendi
ng IO. | 86 // writePixels() which will trigger a flush if the texture has pendi
ng IO. |
| 87 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; | 87 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; |
| 88 } | 88 } |
| 89 GrGpuResource* resource = fCache->findAndRefScratchResource(key, scratch
Flags); | 89 GrGpuResource* resource = fCache->findAndRefScratchResource(key, |
| 90 GrSurface::Wo
rseCaseSize(*desc), |
| 91 scratchFlags)
; |
| 90 if (resource) { | 92 if (resource) { |
| 91 GrSurface* surface = static_cast<GrSurface*>(resource); | 93 GrSurface* surface = static_cast<GrSurface*>(resource); |
| 92 GrRenderTarget* rt = surface->asRenderTarget(); | 94 GrRenderTarget* rt = surface->asRenderTarget(); |
| 93 if (rt && fGpu->caps()->discardRenderTargetSupport()) { | 95 if (rt && fGpu->caps()->discardRenderTargetSupport()) { |
| 94 rt->discard(); | 96 rt->discard(); |
| 95 } | 97 } |
| 96 return surface->asTexture(); | 98 return surface->asTexture(); |
| 97 } | 99 } |
| 98 } | 100 } |
| 99 | 101 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 124 resource->resourcePriv().setUniqueKey(key); | 126 resource->resourcePriv().setUniqueKey(key); |
| 125 } | 127 } |
| 126 | 128 |
| 127 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons
t { | 129 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons
t { |
| 128 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); | 130 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); |
| 129 } | 131 } |
| 130 | 132 |
| 131 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe
y& key) { | 133 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe
y& key) { |
| 132 return this->isAbandoned() ? NULL : fCache->findAndRefUniqueResource(key); | 134 return this->isAbandoned() ? NULL : fCache->findAndRefUniqueResource(key); |
| 133 } | 135 } |
| OLD | NEW |