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

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

Issue 1831133004: Revert of Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « src/gpu/GrGpu.h ('k') | src/gpu/GrIndexBuffer.h » ('j') | 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 * Copyright 2010 Google Inc. 2 * Copyright 2010 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 8
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 10
11 #include "GrBuffer.h"
12 #include "GrCaps.h" 11 #include "GrCaps.h"
13 #include "GrContext.h" 12 #include "GrContext.h"
14 #include "GrGpuResourcePriv.h" 13 #include "GrGpuResourcePriv.h"
14 #include "GrIndexBuffer.h"
15 #include "GrMesh.h" 15 #include "GrMesh.h"
16 #include "GrPathRendering.h" 16 #include "GrPathRendering.h"
17 #include "GrPipeline.h" 17 #include "GrPipeline.h"
18 #include "GrResourceCache.h" 18 #include "GrResourceCache.h"
19 #include "GrResourceProvider.h" 19 #include "GrResourceProvider.h"
20 #include "GrRenderTargetPriv.h" 20 #include "GrRenderTargetPriv.h"
21 #include "GrStencilAttachment.h" 21 #include "GrStencilAttachment.h"
22 #include "GrSurfacePriv.h" 22 #include "GrSurfacePriv.h"
23 #include "GrTransferBuffer.h"
24 #include "GrVertexBuffer.h"
23 #include "SkTypes.h" 25 #include "SkTypes.h"
24 26
25 GrMesh& GrMesh::operator =(const GrMesh& di) { 27 GrMesh& GrMesh::operator =(const GrMesh& di) {
26 fPrimitiveType = di.fPrimitiveType; 28 fPrimitiveType = di.fPrimitiveType;
27 fStartVertex = di.fStartVertex; 29 fStartVertex = di.fStartVertex;
28 fStartIndex = di.fStartIndex; 30 fStartIndex = di.fStartIndex;
29 fVertexCount = di.fVertexCount; 31 fVertexCount = di.fVertexCount;
30 fIndexCount = di.fIndexCount; 32 fIndexCount = di.fIndexCount;
31 33
32 fInstanceCount = di.fInstanceCount; 34 fInstanceCount = di.fInstanceCount;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { 231 if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
230 return nullptr; 232 return nullptr;
231 } 233 }
232 int maxSize = this->caps()->maxTextureSize(); 234 int maxSize = this->caps()->maxTextureSize();
233 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { 235 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
234 return nullptr; 236 return nullptr;
235 } 237 }
236 return this->onWrapBackendTextureAsRenderTarget(desc, ownership); 238 return this->onWrapBackendTextureAsRenderTarget(desc, ownership);
237 } 239 }
238 240
239 GrBuffer* GrGpu::createBuffer(GrBufferType type, size_t size, GrAccessPattern ac cessPattern) { 241 GrVertexBuffer* GrGpu::createVertexBuffer(size_t size, bool dynamic) {
240 this->handleDirtyContext(); 242 this->handleDirtyContext();
241 GrBuffer* buffer = this->onCreateBuffer(type, size, accessPattern); 243 GrVertexBuffer* vb = this->onCreateVertexBuffer(size, dynamic);
242 if (!this->caps()->reuseScratchBuffers()) { 244 if (!this->caps()->reuseScratchBuffers()) {
243 buffer->resourcePriv().removeScratchKey(); 245 vb->resourcePriv().removeScratchKey();
244 } 246 }
245 return buffer; 247 return vb;
248 }
249
250 GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) {
251 this->handleDirtyContext();
252 GrIndexBuffer* ib = this->onCreateIndexBuffer(size, dynamic);
253 if (!this->caps()->reuseScratchBuffers()) {
254 ib->resourcePriv().removeScratchKey();
255 }
256 return ib;
257 }
258
259 GrTransferBuffer* GrGpu::createTransferBuffer(size_t size, TransferType type) {
260 this->handleDirtyContext();
261 GrTransferBuffer* tb = this->onCreateTransferBuffer(size, type);
262 return tb;
246 } 263 }
247 264
248 void GrGpu::clear(const SkIRect& rect, 265 void GrGpu::clear(const SkIRect& rect,
249 GrColor color, 266 GrColor color,
250 GrRenderTarget* renderTarget) { 267 GrRenderTarget* renderTarget) {
251 SkASSERT(renderTarget); 268 SkASSERT(renderTarget);
252 SkASSERT(SkIRect::MakeWH(renderTarget->width(), renderTarget->height()).cont ains(rect)); 269 SkASSERT(SkIRect::MakeWH(renderTarget->width(), renderTarget->height()).cont ains(rect));
253 this->handleDirtyContext(); 270 this->handleDirtyContext();
254 this->onClear(renderTarget, rect, color); 271 this->onClear(renderTarget, rect, color);
255 } 272 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 mipLevel.fPixels = buffer; 409 mipLevel.fPixels = buffer;
393 mipLevel.fRowBytes = rowBytes; 410 mipLevel.fRowBytes = rowBytes;
394 SkSTArray<1, GrMipLevel> texels; 411 SkSTArray<1, GrMipLevel> texels;
395 texels.push_back(mipLevel); 412 texels.push_back(mipLevel);
396 413
397 return this->writePixels(surface, left, top, width, height, config, texels); 414 return this->writePixels(surface, left, top, width, height, config, texels);
398 } 415 }
399 416
400 bool GrGpu::transferPixels(GrSurface* surface, 417 bool GrGpu::transferPixels(GrSurface* surface,
401 int left, int top, int width, int height, 418 int left, int top, int width, int height,
402 GrPixelConfig config, GrBuffer* transferBuffer, 419 GrPixelConfig config, GrTransferBuffer* buffer,
403 size_t offset, size_t rowBytes) { 420 size_t offset, size_t rowBytes) {
404 SkASSERT(transferBuffer); 421 SkASSERT(buffer);
405 422
406 this->handleDirtyContext(); 423 this->handleDirtyContext();
407 if (this->onTransferPixels(surface, left, top, width, height, config, 424 if (this->onTransferPixels(surface, left, top, width, height, config,
408 transferBuffer, offset, rowBytes)) { 425 buffer, offset, rowBytes)) {
409 fStats.incTransfersToTexture(); 426 fStats.incTransfersToTexture();
410 return true; 427 return true;
411 } 428 }
412 return false; 429 return false;
413 } 430 }
414 431
415 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { 432 void GrGpu::resolveRenderTarget(GrRenderTarget* target) {
416 SkASSERT(target); 433 SkASSERT(target);
417 this->handleDirtyContext(); 434 this->handleDirtyContext();
418 this->onResolveRenderTarget(target); 435 this->onResolveRenderTarget(target);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 if (primProc.numAttribs() > this->caps()->maxVertexAttributes()) { 499 if (primProc.numAttribs() > this->caps()->maxVertexAttributes()) {
483 fStats.incNumFailedDraws(); 500 fStats.incNumFailedDraws();
484 return false; 501 return false;
485 } 502 }
486 this->handleDirtyContext(); 503 this->handleDirtyContext();
487 504
488 this->onDraw(pipeline, primProc, meshes, meshCount); 505 this->onDraw(pipeline, primProc, meshes, meshCount);
489 return true; 506 return true;
490 } 507 }
491 508
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrIndexBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698