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

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

Issue 1116923003: simple cleanup in GrTargetCommands (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc 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/GrTargetCommands.h ('k') | src/gpu/GrTextContext.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 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 "GrTargetCommands.h" 8 #include "GrTargetCommands.h"
9 9
10 #include "GrColor.h" 10 #include "GrColor.h"
(...skipping 17 matching lines...) Expand all
28 28
29 GrTargetCommands::Cmd* GrTargetCommands::recordDrawBatch( 29 GrTargetCommands::Cmd* GrTargetCommands::recordDrawBatch(
30 GrInOrderDrawBuffer* iodb, 30 GrInOrderDrawBuffer* iodb,
31 GrBatch* batch, 31 GrBatch* batch,
32 const GrDrawTarget::PipelineIn fo& pipelineInfo) { 32 const GrDrawTarget::PipelineIn fo& pipelineInfo) {
33 if (!this->setupPipelineAndShouldDraw(iodb, batch, pipelineInfo)) { 33 if (!this->setupPipelineAndShouldDraw(iodb, batch, pipelineInfo)) {
34 return NULL; 34 return NULL;
35 } 35 }
36 36
37 // Check if there is a Batch Draw we can batch with 37 // Check if there is a Batch Draw we can batch with
38 if (Cmd::kDrawBatch_CmdType != fCmdBuffer.back().type() || !fDrawBatch) { 38 if (Cmd::kDrawBatch_CmdType == fCmdBuffer.back().type()) {
39 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget)); 39 DrawBatch* previous = static_cast<DrawBatch*>(&fCmdBuffer.back());
40 return fDrawBatch; 40 if (previous->fBatch->combineIfPossible(batch)) {
41 return NULL;
42 }
41 } 43 }
42 44
43 SkASSERT(&fCmdBuffer.back() == fDrawBatch); 45 return GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fBatchTarget ));
44 if (!fDrawBatch->fBatch->combineIfPossible(batch)) {
45 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget));
46 }
47
48 return fDrawBatch;
49 } 46 }
50 47
51 GrTargetCommands::Cmd* GrTargetCommands::recordStencilPath( 48 GrTargetCommands::Cmd* GrTargetCommands::recordStencilPath(
52 GrInOrderDrawBuffer* iod b, 49 GrInOrderDrawBuffer* iod b,
53 const GrPipelineBuilder& pipelineBuilder, 50 const GrPipelineBuilder& pipelineBuilder,
54 const GrPathProcessor* p athProc, 51 const GrPathProcessor* p athProc,
55 const GrPath* path, 52 const GrPath* path,
56 const GrScissorState& sc issorState, 53 const GrScissorState& sc issorState,
57 const GrStencilSettings& stencilSettings) { 54 const GrStencilSettings& stencilSettings) {
58 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, 55 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 SkASSERT(renderTarget); 180 SkASSERT(renderTarget);
184 181
185 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); 182 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget));
186 clr->fColor = GrColor_ILLEGAL; 183 clr->fColor = GrColor_ILLEGAL;
187 return clr; 184 return clr;
188 } 185 }
189 186
190 void GrTargetCommands::reset() { 187 void GrTargetCommands::reset() {
191 fCmdBuffer.reset(); 188 fCmdBuffer.reset();
192 fPrevState = NULL; 189 fPrevState = NULL;
193 fDrawBatch = NULL;
194 } 190 }
195 191
196 void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { 192 void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) {
197 if (fCmdBuffer.empty()) { 193 if (fCmdBuffer.empty()) {
198 return; 194 return;
199 } 195 }
200 196
201 // Updated every time we find a set state cmd to reflect the current state i n the playback 197 // Updated every time we find a set state cmd to reflect the current state i n the playback
202 // stream. 198 // stream.
203 SetState* currentState = NULL; 199 SetState* currentState = NULL;
204 200
205 GrGpu* gpu = iodb->getGpu(); 201 GrGpu* gpu = iodb->getGpu();
206 202
207 #ifdef USE_BITMAP_TEXTBLOBS
208 // Loop over all batches and generate geometry 203 // Loop over all batches and generate geometry
209 CmdBuffer::Iter genIter(fCmdBuffer); 204 CmdBuffer::Iter genIter(fCmdBuffer);
210 while (genIter.next()) { 205 while (genIter.next()) {
211 if (Cmd::kDrawBatch_CmdType == genIter->type()) { 206 if (Cmd::kDrawBatch_CmdType == genIter->type()) {
212 DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get()); 207 DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get());
213 fBatchTarget.resetNumberOfDraws(); 208 fBatchTarget.resetNumberOfDraws();
214 db->execute(NULL, currentState); 209 db->execute(NULL, currentState);
215 db->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); 210 db->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws());
216 } else if (Cmd::kSetState_CmdType == genIter->type()) { 211 } else if (Cmd::kSetState_CmdType == genIter->type()) {
217 SetState* ss = reinterpret_cast<SetState*>(genIter.get()); 212 SetState* ss = reinterpret_cast<SetState*>(genIter.get());
218 213
219 ss->execute(gpu, currentState); 214 ss->execute(gpu, currentState);
220 currentState = ss; 215 currentState = ss;
221 } 216 }
222 } 217 }
223 #endif
224 218
225 iodb->getVertexAllocPool()->unmap(); 219 iodb->getVertexAllocPool()->unmap();
226 iodb->getIndexAllocPool()->unmap(); 220 iodb->getIndexAllocPool()->unmap();
227 fBatchTarget.preFlush(); 221 fBatchTarget.preFlush();
228 222
229 CmdBuffer::Iter iter(fCmdBuffer); 223 CmdBuffer::Iter iter(fCmdBuffer);
230 224
231 while (iter.next()) { 225 while (iter.next()) {
232 GrGpuTraceMarker newMarker("", -1); 226 GrGpuTraceMarker newMarker("", -1);
233 SkString traceString; 227 SkString traceString;
234 if (iter->isTraced()) { 228 if (iter->isTraced()) {
235 traceString = iodb->getCmdString(iter->markerID()); 229 traceString = iodb->getCmdString(iter->markerID());
236 newMarker.fMarker = traceString.c_str(); 230 newMarker.fMarker = traceString.c_str();
237 gpu->addGpuTraceMarker(&newMarker); 231 gpu->addGpuTraceMarker(&newMarker);
238 } 232 }
239 233
240 // TODO temporary hack
241 if (Cmd::kDrawBatch_CmdType == iter->type()) { 234 if (Cmd::kDrawBatch_CmdType == iter->type()) {
242 DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get()); 235 DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get());
243 fBatchTarget.flushNext(db->fBatch->numberOfDraws()); 236 fBatchTarget.flushNext(db->fBatch->numberOfDraws());
244 237
245 if (iter->isTraced()) { 238 if (iter->isTraced()) {
246 gpu->removeGpuTraceMarker(&newMarker); 239 gpu->removeGpuTraceMarker(&newMarker);
247 } 240 }
248 continue; 241 continue;
249 } 242 }
250 243
251 if (Cmd::kSetState_CmdType == iter->type()) { 244 if (Cmd::kSetState_CmdType == iter->type()) {
252 #ifndef USE_BITMAP_TEXTBLOBS
253 SetState* ss = reinterpret_cast<SetState*>(iter.get());
254
255 ss->execute(gpu, currentState);
256 currentState = ss;
257 #else
258 // TODO this is just until NVPR is in batch 245 // TODO this is just until NVPR is in batch
259 SetState* ss = reinterpret_cast<SetState*>(iter.get()); 246 SetState* ss = reinterpret_cast<SetState*>(iter.get());
260 247
261 if (ss->fPrimitiveProcessor) { 248 if (ss->fPrimitiveProcessor) {
262 ss->execute(gpu, currentState); 249 ss->execute(gpu, currentState);
263 } 250 }
264 currentState = ss; 251 currentState = ss;
265 #endif
266 252
267 } else { 253 } else {
268 iter->execute(gpu, currentState); 254 iter->execute(gpu, currentState);
269 } 255 }
270 256
271 if (iter->isTraced()) { 257 if (iter->isTraced()) {
272 gpu->removeGpuTraceMarker(&newMarker); 258 gpu->removeGpuTraceMarker(&newMarker);
273 } 259 }
274 } 260 }
275 261
276 // TODO see copious notes about hack
277 fBatchTarget.postFlush(); 262 fBatchTarget.postFlush();
278 } 263 }
279 264
280 void GrTargetCommands::Draw::execute(GrGpu* gpu, const SetState* state) {
281 SkASSERT(state);
282 DrawArgs args(state->fPrimitiveProcessor.get(), state->getPipeline(), &state ->fDesc,
283 &state->fBatchTracker);
284 gpu->draw(args, fInfo);
285 }
286
287 void GrTargetCommands::StencilPath::execute(GrGpu* gpu, const SetState*) { 265 void GrTargetCommands::StencilPath::execute(GrGpu* gpu, const SetState*) {
288 GrGpu::StencilPathState state; 266 GrGpu::StencilPathState state;
289 state.fRenderTarget = fRenderTarget.get(); 267 state.fRenderTarget = fRenderTarget.get();
290 state.fScissor = &fScissor; 268 state.fScissor = &fScissor;
291 state.fStencil = &fStencil; 269 state.fStencil = &fStencil;
292 state.fUseHWAA = fUseHWAA; 270 state.fUseHWAA = fUseHWAA;
293 state.fViewMatrix = &fViewMatrix; 271 state.fViewMatrix = &fViewMatrix;
294 272
295 gpu->stencilPath(this->path(), state); 273 gpu->stencilPath(this->path(), state);
296 } 274 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 if (!xp.willNeedXferBarrier(rt, *iodb->caps(), &barrierType)) { 397 if (!xp.willNeedXferBarrier(rt, *iodb->caps(), &barrierType)) {
420 return; 398 return;
421 } 399 }
422 400
423 XferBarrier* xb = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, XferBarrier, ()); 401 XferBarrier* xb = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, XferBarrier, ());
424 xb->fBarrierType = barrierType; 402 xb->fBarrierType = barrierType;
425 403
426 iodb->recordTraceMarkersIfNecessary(xb); 404 iodb->recordTraceMarkersIfNecessary(xb);
427 } 405 }
428 406
OLDNEW
« no previous file with comments | « src/gpu/GrTargetCommands.h ('k') | src/gpu/GrTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698