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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, | 63 GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, |
64 uint32_t flags) { | 64 uint32_t flags) { |
65 SkASSERT(!this->isAbandoned()); | 65 SkASSERT(!this->isAbandoned()); |
66 SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig)); | 66 SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig)); |
67 | 67 |
68 SkTCopyOnFirstWrite<GrSurfaceDesc> desc(inDesc); | 68 SkTCopyOnFirstWrite<GrSurfaceDesc> desc(inDesc); |
69 | 69 |
70 if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_Gr
SurfaceFlag)) { | 70 if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_Gr
SurfaceFlag)) { |
71 if (!(kExact_ScratchTextureFlag & flags)) { | 71 if (!(kExact_ScratchTextureFlag & flags)) { |
72 // bin by pow2 with a reasonable min | 72 // bin by pow2 with a reasonable min |
73 const int minSize = SkTMin(16, fGpu->caps()->minTextureSize()); | 73 const int kMinSize = 16; |
74 GrSurfaceDesc* wdesc = desc.writable(); | 74 GrSurfaceDesc* wdesc = desc.writable(); |
75 wdesc->fWidth = SkTMax(minSize, GrNextPow2(desc->fWidth)); | 75 wdesc->fWidth = SkTMax(kMinSize, GrNextPow2(desc->fWidth)); |
76 wdesc->fHeight = SkTMax(minSize, GrNextPow2(desc->fHeight)); | 76 wdesc->fHeight = SkTMax(kMinSize, GrNextPow2(desc->fHeight)); |
77 } | 77 } |
78 | 78 |
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. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 resource->resourcePriv().setUniqueKey(key); | 126 resource->resourcePriv().setUniqueKey(key); |
127 } | 127 } |
128 | 128 |
129 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons
t { | 129 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons
t { |
130 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); | 130 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); |
131 } | 131 } |
132 | 132 |
133 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe
y& key) { | 133 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe
y& key) { |
134 return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key)
; | 134 return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key)
; |
135 } | 135 } |
OLD | NEW |