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

Side by Side Diff: src/gpu/batches/GrVertexBatch.cpp

Issue 1296483002: Split GrDrawBatch and GrVertexBatch into their own files (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add new files to git 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 | « src/gpu/batches/GrVertexBatch.h ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrVertexBatch.h"
9 #include "GrBatchTarget.h"
10 #include "GrResourceProvider.h"
11
12 GrVertexBatch::GrVertexBatch() : fNumberOfDraws(0) {}
13
14 void* GrVertexBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimiti veType primType,
15 size_t vertexStride, const GrIndexBuffer* i ndexBuffer,
16 int verticesPerInstance, int indicesPerInst ance,
17 int instancesToDraw) {
18 SkASSERT(batchTarget);
19 if (!indexBuffer) {
20 return NULL;
21 }
22 const GrVertexBuffer* vertexBuffer;
23 int firstVertex;
24 int vertexCount = verticesPerInstance * instancesToDraw;
25 void* vertices = batchTarget->makeVertSpace(vertexStride, vertexCount,
26 &vertexBuffer, &firstVertex);
27 if (!vertices) {
28 SkDebugf("Vertices could not be allocated for instanced rendering.");
29 return NULL;
30 }
31 SkASSERT(vertexBuffer);
32 size_t ibSize = indexBuffer->gpuMemorySize();
33 int maxInstancesPerDraw = static_cast<int>(ibSize / (sizeof(uint16_t) * indi cesPerInstance));
34
35 fVertices.initInstanced(primType, vertexBuffer, indexBuffer,
36 firstVertex, verticesPerInstance, indicesPerInstance, instancesToDraw,
37 maxInstancesPerDraw);
38 return vertices;
39 }
40
41 void* GrVertexBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexS tride,
42 int quadsToDraw) {
43 SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer(
44 batchTarget->resourceProvider()->refQuadIndexBuffer());
45 if (!quadIndexBuffer) {
46 SkDebugf("Could not get quad index buffer.");
47 return NULL;
48 }
49 return this->INHERITED::init(batchTarget, kTriangles_GrPrimitiveType, vertex Stride,
50 quadIndexBuffer, kVerticesPerQuad, kIndicesPerQ uad, quadsToDraw);
51 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrVertexBatch.h ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698