| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 GrTexture* GrTextureProvider::internalRefScratchTexture(const GrSurfaceDesc& inD
esc, | 66 GrTexture* GrTextureProvider::internalRefScratchTexture(const GrSurfaceDesc& inD
esc, |
| 67 uint32_t flags) { | 67 uint32_t flags) { |
| 68 SkASSERT(!this->isAbandoned()); | 68 SkASSERT(!this->isAbandoned()); |
| 69 SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig)); | 69 SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig)); |
| 70 | 70 |
| 71 SkTCopyOnFirstWrite<GrSurfaceDesc> desc(inDesc); | 71 SkTCopyOnFirstWrite<GrSurfaceDesc> desc(inDesc); |
| 72 | 72 |
| 73 if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_Gr
SurfaceFlag)) { | 73 if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_Gr
SurfaceFlag)) { |
| 74 if (!(kExact_ScratchTextureFlag & flags)) { | 74 if (!(kExact_ScratchTextureFlag & flags)) { |
| 75 // bin by pow2 with a reasonable min | 75 // bin by pow2 with a reasonable min |
| 76 static const int MIN_SIZE = 16; | 76 const int minSize = SkTMin(16, fGpu->caps()->minTextureSize()); |
| 77 GrSurfaceDesc* wdesc = desc.writable(); | 77 GrSurfaceDesc* wdesc = desc.writable(); |
| 78 wdesc->fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth)); | 78 wdesc->fWidth = SkTMax(minSize, GrNextPow2(desc->fWidth)); |
| 79 wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight)); | 79 wdesc->fHeight = SkTMax(minSize, GrNextPow2(desc->fHeight)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 GrScratchKey key; | 82 GrScratchKey key; |
| 83 GrTexturePriv::ComputeScratchKey(*desc, &key); | 83 GrTexturePriv::ComputeScratchKey(*desc, &key); |
| 84 uint32_t scratchFlags = 0; | 84 uint32_t scratchFlags = 0; |
| 85 if (kNoPendingIO_ScratchTextureFlag & flags) { | 85 if (kNoPendingIO_ScratchTextureFlag & flags) { |
| 86 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; | 86 scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; |
| 87 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { | 87 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { |
| 88 // If it is not a render target then it will most likely be populate
d by | 88 // If it is not a render target then it will most likely be populate
d by |
| 89 // writePixels() which will trigger a flush if the texture has pendi
ng IO. | 89 // writePixels() which will trigger a flush if the texture has pendi
ng IO. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 resource->resourcePriv().setUniqueKey(key); | 127 resource->resourcePriv().setUniqueKey(key); |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons
t { | 130 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons
t { |
| 131 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); | 131 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); |
| 132 } | 132 } |
| 133 | 133 |
| 134 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe
y& key) { | 134 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe
y& key) { |
| 135 return this->isAbandoned() ? NULL : fCache->findAndRefUniqueResource(key); | 135 return this->isAbandoned() ? NULL : fCache->findAndRefUniqueResource(key); |
| 136 } | 136 } |
| OLD | NEW |