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

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

Issue 1534123003: More framework support for TransferBuffers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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
OLDNEW
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 "GrResourceProvider.h" 8 #include "GrResourceProvider.h"
9 9
10 #include "GrGpu.h" 10 #include "GrGpu.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; 139 scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;
140 } 140 }
141 GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags); 141 GrGpuResource* resource = this->cache()->findAndRefScratchResource(key, size, scratchFlags);
142 if (resource) { 142 if (resource) {
143 return static_cast<GrVertexBuffer*>(resource); 143 return static_cast<GrVertexBuffer*>(resource);
144 } 144 }
145 } 145 }
146 return this->gpu()->createVertexBuffer(size, dynamic); 146 return this->gpu()->createVertexBuffer(size, dynamic);
147 } 147 }
148 148
149 GrTransferBuffer* GrResourceProvider::createTransferBuffer(size_t size, Transfer Type type,
150 uint32_t flags) {
151 if (this->isAbandoned()) {
152 return nullptr;
153 }
154
155 //bool noPendingIO = SkToBool(flags & kNoPendingIO_Flag);
156 GrGpu::TransferType gpuType = kCpuToGpu_TransferType == type ? GrGpu::kCpuTo Gpu_TransferType
157 : GrGpu::kGpuTo Cpu_TransferType;
158 return this->gpu()->createTransferBuffer(size, gpuType);
159 }
160
149 GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config, 161 GrBatchAtlas* GrResourceProvider::createAtlas(GrPixelConfig config,
150 int width, int height, 162 int width, int height,
151 int numPlotsX, int numPlotsY, 163 int numPlotsX, int numPlotsY,
152 GrBatchAtlas::EvictionFunc func, v oid* data) { 164 GrBatchAtlas::EvictionFunc func, v oid* data) {
153 GrSurfaceDesc desc; 165 GrSurfaceDesc desc;
154 desc.fFlags = kNone_GrSurfaceFlags; 166 desc.fFlags = kNone_GrSurfaceFlags;
155 desc.fWidth = width; 167 desc.fWidth = width;
156 desc.fHeight = height; 168 desc.fHeight = height;
157 desc.fConfig = config; 169 desc.fConfig = config;
158 170
159 // We don't want to flush the context so we claim we're in the middle of flu shing so as to 171 // We don't want to flush the context so we claim we're in the middle of flu shing so as to
160 // guarantee we do not recieve a texture with pending IO 172 // guarantee we do not recieve a texture with pending IO
161 // TODO: Determine how to avoid having to do this. (https://bug.skia.org/415 6) 173 // TODO: Determine how to avoid having to do this. (https://bug.skia.org/415 6)
162 static const uint32_t kFlags = GrResourceProvider::kNoPendingIO_Flag; 174 static const uint32_t kFlags = GrResourceProvider::kNoPendingIO_Flag;
163 GrTexture* texture = this->createApproxTexture(desc, kFlags); 175 GrTexture* texture = this->createApproxTexture(desc, kFlags);
164 if (!texture) { 176 if (!texture) {
165 return nullptr; 177 return nullptr;
166 } 178 }
167 GrBatchAtlas* atlas = new GrBatchAtlas(texture, numPlotsX, numPlotsY); 179 GrBatchAtlas* atlas = new GrBatchAtlas(this, texture, numPlotsX, numPlotsY);
168 atlas->registerEvictionCallback(func, data); 180 atlas->registerEvictionCallback(func, data);
169 return atlas; 181 return atlas;
170 } 182 }
171 183
172 GrStencilAttachment* GrResourceProvider::attachStencilAttachment(GrRenderTarget* rt) { 184 GrStencilAttachment* GrResourceProvider::attachStencilAttachment(GrRenderTarget* rt) {
173 SkASSERT(rt); 185 SkASSERT(rt);
174 if (rt->renderTargetPriv().getStencilAttachment()) { 186 if (rt->renderTargetPriv().getStencilAttachment()) {
175 return rt->renderTargetPriv().getStencilAttachment(); 187 return rt->renderTargetPriv().getStencilAttachment();
176 } 188 }
177 189
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // FBO. But iOS doesn't allow a stencil-only FBO. It reports uns upported 222 // FBO. But iOS doesn't allow a stencil-only FBO. It reports uns upported
211 // FBO status. 223 // FBO status.
212 this->gpu()->clearStencil(rt); 224 this->gpu()->clearStencil(rt);
213 } 225 }
214 } 226 }
215 } 227 }
216 return rt->renderTargetPriv().getStencilAttachment(); 228 return rt->renderTargetPriv().getStencilAttachment();
217 } 229 }
218 230
219 231
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698