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

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

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/GrTestBatch.h ('k') | src/gpu/batches/GrVertexBatch.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 #ifndef GrVertexBatch_DEFINED
9 #define GrVertexBatch_DEFINED
10
11 #include "GrDrawBatch.h"
12 #include "GrBatchTarget.h"
13
14 /**
15 * Base class for vertex-based GrBatches.
16 */
17 class GrVertexBatch : public GrDrawBatch {
18 public:
19 GrVertexBatch();
20
21 virtual void generateGeometry(GrBatchTarget*) = 0;
22
23 // TODO this goes away when batches are everywhere
24 void setNumberOfDraws(int numberOfDraws) { fNumberOfDraws = numberOfDraws; }
25 int numberOfDraws() const { return fNumberOfDraws; }
26
27 protected:
28 /** Helper for rendering instances using an instanced index index buffer. Th is class creates the
29 space for the vertices and flushes the draws to the batch target. */
30 class InstancedHelper {
31 public:
32 InstancedHelper() {}
33 /** Returns the allocated storage for the vertices. The caller should po pulate the before
34 vertices before calling issueDraws(). */
35 void* init(GrBatchTarget* batchTarget, GrPrimitiveType, size_t vertexStr ide,
36 const GrIndexBuffer*, int verticesPerInstance, int indicesPer Instance,
37 int instancesToDraw);
38
39 /** Call after init() to issue draws to the batch target.*/
40 void issueDraw(GrBatchTarget* batchTarget) {
41 SkASSERT(fVertices.instanceCount());
42 batchTarget->draw(fVertices);
43 }
44 private:
45 GrVertices fVertices;
46 };
47
48 static const int kVerticesPerQuad = 4;
49 static const int kIndicesPerQuad = 6;
50
51 /** A specialization of InstanceHelper for quad rendering. */
52 class QuadHelper : private InstancedHelper {
53 public:
54 QuadHelper() : INHERITED() {}
55 /** Finds the cached quad index buffer and reserves vertex space. Return s NULL on failure
56 and on sucess a pointer to the vertex data that the caller should po pulate before
57 calling issueDraws(). */
58 void* init(GrBatchTarget* batchTarget, size_t vertexStride, int quadsToD raw);
59
60 using InstancedHelper::issueDraw;
61
62 private:
63 typedef InstancedHelper INHERITED;
64 };
65
66 private:
67 int fNumberOfDraws;
68 typedef GrDrawBatch INHERITED;
69 };
70
71 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrTestBatch.h ('k') | src/gpu/batches/GrVertexBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698