Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: src/gpu/GrTextureProvider.cpp

Issue 1271353003: Fix variable shadowing and unreachable code that it caused (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 // Currently we don't recycle compressed textures as scratch. 55 // Currently we don't recycle compressed textures as scratch.
56 if (GrPixelConfigIsCompressed(desc.fConfig)) { 56 if (GrPixelConfigIsCompressed(desc.fConfig)) {
57 return NULL; 57 return NULL;
58 } else { 58 } else {
59 return this->refScratchTexture(desc, scratchFlags); 59 return this->refScratchTexture(desc, scratchFlags);
60 } 60 }
61 } 61 }
62 62
63 GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, 63 GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc,
64 uint32_t scratchFlags) { 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 & scratchFlags)) { 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 minSize = SkTMin(16, fGpu->caps()->minTextureSize());
74 GrSurfaceDesc* wdesc = desc.writable(); 74 GrSurfaceDesc* wdesc = desc.writable();
75 wdesc->fWidth = SkTMax(minSize, GrNextPow2(desc->fWidth)); 75 wdesc->fWidth = SkTMax(minSize, GrNextPow2(desc->fWidth));
76 wdesc->fHeight = SkTMax(minSize, GrNextPow2(desc->fHeight)); 76 wdesc->fHeight = SkTMax(minSize, 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 & scratchFlags) { 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, scratch Flags);
90 if (resource) { 90 if (resource) {
91 GrSurface* surface = static_cast<GrSurface*>(resource); 91 GrSurface* surface = static_cast<GrSurface*>(resource);
92 GrRenderTarget* rt = surface->asRenderTarget(); 92 GrRenderTarget* rt = surface->asRenderTarget();
93 if (rt && fGpu->caps()->discardRenderTargetSupport()) { 93 if (rt && fGpu->caps()->discardRenderTargetSupport()) {
94 rt->discard(); 94 rt->discard();
95 } 95 }
96 return surface->asTexture(); 96 return surface->asTexture();
97 } 97 }
98 } 98 }
99 99
100 if (!(kNoCreate_ScratchTextureFlag & scratchFlags)) { 100 if (!(kNoCreate_ScratchTextureFlag & flags)) {
101 return fGpu->createTexture(*desc, true, NULL, 0); 101 return fGpu->createTexture(*desc, true, NULL, 0);
102 } 102 }
103 103
104 return NULL; 104 return NULL;
105 } 105 }
106 106
107 GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& des c, 107 GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& des c,
108 GrWrapOwnership ownership) { 108 GrWrapOwnership ownership) {
109 if (this->isAbandoned()) { 109 if (this->isAbandoned()) {
110 return NULL; 110 return NULL;
(...skipping 13 matching lines...) Expand all
124 resource->resourcePriv().setUniqueKey(key); 124 resource->resourcePriv().setUniqueKey(key);
125 } 125 }
126 126
127 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons t { 127 bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) cons t {
128 return this->isAbandoned() ? false : fCache->hasUniqueKey(key); 128 return this->isAbandoned() ? false : fCache->hasUniqueKey(key);
129 } 129 }
130 130
131 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe y& key) { 131 GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKe y& key) {
132 return this->isAbandoned() ? NULL : fCache->findAndRefUniqueResource(key); 132 return this->isAbandoned() ? NULL : fCache->findAndRefUniqueResource(key);
133 } 133 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698