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

Side by Side Diff: src/gpu/GrBatchTarget.h

Issue 1124733004: Move DrawInfo out from GrDrawTarget and rename to GrVertices. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment changes Created 5 years, 7 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/GrBatch.cpp ('k') | src/gpu/GrBatchTarget.cpp » ('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 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 #ifndef GrBatchBuffer_DEFINED 8 #ifndef GrBatchBuffer_DEFINED
9 #define GrBatchBuffer_DEFINED 9 #define GrBatchBuffer_DEFINED
10 10
11 #include "GrBatchAtlas.h" 11 #include "GrBatchAtlas.h"
12 #include "GrBufferAllocPool.h" 12 #include "GrBufferAllocPool.h"
13 #include "GrPendingProgramElement.h" 13 #include "GrPendingProgramElement.h"
14 #include "GrPipeline.h" 14 #include "GrPipeline.h"
15 #include "GrGpu.h"
16 #include "GrTRecorder.h" 15 #include "GrTRecorder.h"
16 #include "GrVertices.h"
17 17
18 /* 18 /*
19 * GrBatch instances use this object to allocate space for their geometry and to issue the draws 19 * GrBatch instances use this object to allocate space for their geometry and to issue the draws
20 * that render their batch. 20 * that render their batch.
21 */ 21 */
22 22
23 class GrIndexBufferAllocPool; 23 class GrIndexBufferAllocPool;
24 class GrVertexBufferAllocPool; 24 class GrVertexBufferAllocPool;
25 25
26 class GrBatchTarget : public SkNoncopyable { 26 class GrBatchTarget : public SkNoncopyable {
27 public: 27 public:
28 typedef GrBatchAtlas::BatchToken BatchToken; 28 typedef GrBatchAtlas::BatchToken BatchToken;
29 GrBatchTarget(GrGpu* gpu, 29 GrBatchTarget(GrGpu* gpu,
30 GrVertexBufferAllocPool* vpool, 30 GrVertexBufferAllocPool* vpool,
31 GrIndexBufferAllocPool* ipool); 31 GrIndexBufferAllocPool* ipool);
32 32
33 typedef GrDrawTarget::DrawInfo DrawInfo;
34 void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeli ne) { 33 void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeli ne) {
35 GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipelin e)); 34 GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipelin e));
36 fNumberOfDraws++; 35 fNumberOfDraws++;
37 fCurrentToken++; 36 fCurrentToken++;
38 } 37 }
39 38
40 class TextureUploader { 39 class TextureUploader {
41 public: 40 public:
42 TextureUploader(GrGpu* gpu) : fGpu(gpu) { SkASSERT(gpu); } 41 TextureUploader(GrGpu* gpu) : fGpu(gpu) { SkASSERT(gpu); }
43 42
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 }; 75 };
77 76
78 void upload(Uploader* upload) { 77 void upload(Uploader* upload) {
79 if (this->asapToken() == upload->lastUploadToken()) { 78 if (this->asapToken() == upload->lastUploadToken()) {
80 fAsapUploads.push_back().reset(SkRef(upload)); 79 fAsapUploads.push_back().reset(SkRef(upload));
81 } else { 80 } else {
82 fInlineUploads.push_back().reset(SkRef(upload)); 81 fInlineUploads.push_back().reset(SkRef(upload));
83 } 82 }
84 } 83 }
85 84
86 void draw(const GrDrawTarget::DrawInfo& draw) { 85 void draw(const GrVertices& vertices) {
87 fFlushBuffer.back().fDraws.push_back(draw); 86 fFlushBuffer.back().fVertexDraws.push_back(vertices);
88 } 87 }
89 88
90 bool isIssued(BatchToken token) const { return fLastFlushedToken >= token; } 89 bool isIssued(BatchToken token) const { return fLastFlushedToken >= token; }
91 BatchToken currentToken() const { return fCurrentToken; } 90 BatchToken currentToken() const { return fCurrentToken; }
92 BatchToken asapToken() const { return fLastFlushedToken + 1; } 91 BatchToken asapToken() const { return fLastFlushedToken + 1; }
93 92
94 // TODO much of this complexity goes away when batch is everywhere 93 // TODO much of this complexity goes away when batch is everywhere
95 void resetNumberOfDraws() { fNumberOfDraws = 0; } 94 void resetNumberOfDraws() { fNumberOfDraws = 0; }
96 int numberOfDraws() const { return fNumberOfDraws; } 95 int numberOfDraws() const { return fNumberOfDraws; }
97 void preFlush() { 96 void preFlush() {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 typedef void* TBufferAlign; // This wouldn't be enough align if a command us ed long double. 137 typedef void* TBufferAlign; // This wouldn't be enough align if a command us ed long double.
139 138
140 struct BufferedFlush { 139 struct BufferedFlush {
141 BufferedFlush(const GrPrimitiveProcessor* primProc, const GrPipeline* pi peline) 140 BufferedFlush(const GrPrimitiveProcessor* primProc, const GrPipeline* pi peline)
142 : fPrimitiveProcessor(primProc) 141 : fPrimitiveProcessor(primProc)
143 , fPipeline(pipeline) {} 142 , fPipeline(pipeline) {}
144 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi tiveProcessor; 143 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi tiveProcessor;
145 ProgramPrimitiveProcessor fPrimitiveProcessor; 144 ProgramPrimitiveProcessor fPrimitiveProcessor;
146 const GrPipeline* fPipeline; 145 const GrPipeline* fPipeline;
147 GrBatchTracker fBatchTracker; 146 GrBatchTracker fBatchTracker;
148 SkSTArray<1, DrawInfo, true> fDraws; 147 SkSTArray<1, GrVertices, true> fVertexDraws;
149 }; 148 };
150 149
151 enum { 150 enum {
152 kFlushBufferInitialSizeInBytes = 8 * sizeof(BufferedFlush), 151 kFlushBufferInitialSizeInBytes = 8 * sizeof(BufferedFlush),
153 }; 152 };
154 153
155 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer; 154 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer;
156 155
157 FlushBuffer fFlushBuffer; 156 FlushBuffer fFlushBuffer;
158 // TODO this is temporary 157 // TODO this is temporary
159 FlushBuffer::Iter fIter; 158 FlushBuffer::Iter fIter;
160 int fNumberOfDraws; 159 int fNumberOfDraws;
161 BatchToken fCurrentToken; 160 BatchToken fCurrentToken;
162 BatchToken fLastFlushedToken; // The next token to be flushed 161 BatchToken fLastFlushedToken; // The next token to be flushed
163 SkTArray<SkAutoTUnref<Uploader>, true> fAsapUploads; 162 SkTArray<SkAutoTUnref<Uploader>, true> fAsapUploads;
164 SkTArray<SkAutoTUnref<Uploader>, true> fInlineUploads; 163 SkTArray<SkAutoTUnref<Uploader>, true> fInlineUploads;
165 int fInlineUpdatesIndex; 164 int fInlineUpdatesIndex;
166 }; 165 };
167 166
168 #endif 167 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrBatch.cpp ('k') | src/gpu/GrBatchTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698