OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrInOrderDrawBuffer.h" | 8 #include "GrInOrderDrawBuffer.h" |
9 | 9 |
10 #include "GrBufferAllocPool.h" | 10 #include "GrBufferAllocPool.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 , fDrawBatch(NULL) { | 28 , fDrawBatch(NULL) { |
29 | 29 |
30 SkASSERT(vertexPool); | 30 SkASSERT(vertexPool); |
31 SkASSERT(indexPool); | 31 SkASSERT(indexPool); |
32 } | 32 } |
33 | 33 |
34 GrInOrderDrawBuffer::~GrInOrderDrawBuffer() { | 34 GrInOrderDrawBuffer::~GrInOrderDrawBuffer() { |
35 this->reset(); | 35 this->reset(); |
36 } | 36 } |
37 | 37 |
| 38 void GrInOrderDrawBuffer::closeBatch() { |
| 39 if (fDrawBatch) { |
| 40 fBatchTarget.resetNumberOfDraws(); |
| 41 fDrawBatch->execute(this->getGpu(), fPrevState); |
| 42 fDrawBatch->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); |
| 43 fDrawBatch = NULL; |
| 44 } |
| 45 } |
| 46 |
38 //////////////////////////////////////////////////////////////////////////////// | 47 //////////////////////////////////////////////////////////////////////////////// |
39 | 48 |
40 /** We always use per-vertex colors so that rects can be batched across color ch
anges. Sometimes we | 49 /** We always use per-vertex colors so that rects can be batched across color ch
anges. Sometimes we |
41 have explicit local coords and sometimes not. We *could* always provide expl
icit local coords | 50 have explicit local coords and sometimes not. We *could* always provide expl
icit local coords |
42 and just duplicate the positions when the caller hasn't provided a local coo
rd rect, but we | 51 and just duplicate the positions when the caller hasn't provided a local coo
rd rect, but we |
43 haven't seen a use case which frequently switches between local rect and no
local rect draws. | 52 haven't seen a use case which frequently switches between local rect and no
local rect draws. |
44 | 53 |
45 The color param is used to determine whether the opaque hint can be set on t
he draw state. | 54 The color param is used to determine whether the opaque hint can be set on t
he draw state. |
46 The caller must populate the vertex colors itself. | 55 The caller must populate the vertex colors itself. |
47 | 56 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 356 } |
348 | 357 |
349 // how many instances can be concat'ed onto draw given the size of the index
buffer | 358 // how many instances can be concat'ed onto draw given the size of the index
buffer |
350 int instancesToConcat = this->indexCountInCurrentSource() / info.indicesPerI
nstance(); | 359 int instancesToConcat = this->indexCountInCurrentSource() / info.indicesPerI
nstance(); |
351 instancesToConcat -= draw->fInfo.instanceCount(); | 360 instancesToConcat -= draw->fInfo.instanceCount(); |
352 instancesToConcat = SkTMin(instancesToConcat, info.instanceCount()); | 361 instancesToConcat = SkTMin(instancesToConcat, info.instanceCount()); |
353 | 362 |
354 draw->fInfo.adjustInstanceCount(instancesToConcat); | 363 draw->fInfo.adjustInstanceCount(instancesToConcat); |
355 | 364 |
356 // update last fGpuCmdMarkers to include any additional trace markers that h
ave been added | 365 // update last fGpuCmdMarkers to include any additional trace markers that h
ave been added |
357 if (this->getActiveTraceMarkers().count() > 0) { | 366 this->recordTraceMarkersIfNecessary(draw); |
358 if (draw->isTraced()) { | |
359 fGpuCmdMarkers.back().addSet(this->getActiveTraceMarkers()); | |
360 } else { | |
361 fGpuCmdMarkers.push_back(this->getActiveTraceMarkers()); | |
362 draw->makeTraced(); | |
363 } | |
364 } | |
365 | |
366 return instancesToConcat; | 367 return instancesToConcat; |
367 } | 368 } |
368 | 369 |
369 void GrInOrderDrawBuffer::onDraw(const GrGeometryProcessor* gp, | 370 void GrInOrderDrawBuffer::onDraw(const GrGeometryProcessor* gp, |
370 const DrawInfo& info, | 371 const DrawInfo& info, |
371 const PipelineInfo& pipelineInfo) { | 372 const PipelineInfo& pipelineInfo) { |
372 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); | 373 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); |
373 this->closeBatch(); | 374 this->closeBatch(); |
374 | 375 |
375 if (!this->setupPipelineAndShouldDraw(gp, pipelineInfo)) { | 376 if (!this->setupPipelineAndShouldDraw(gp, pipelineInfo)) { |
376 return; | 377 return; |
377 } | 378 } |
378 | 379 |
379 Draw* draw; | 380 Draw* draw; |
380 if (info.isInstanced()) { | 381 if (info.isInstanced()) { |
381 int instancesConcated = this->concatInstancedDraw(info); | 382 int instancesConcated = this->concatInstancedDraw(info); |
382 if (info.instanceCount() > instancesConcated) { | 383 if (info.instanceCount() > instancesConcated) { |
383 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); | 384 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); |
384 draw->fInfo.adjustInstanceCount(-instancesConcated); | 385 draw->fInfo.adjustInstanceCount(-instancesConcated); |
385 } else { | 386 } else { |
386 return; | 387 return; |
387 } | 388 } |
388 } else { | 389 } else { |
389 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); | 390 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); |
390 } | 391 } |
391 this->recordTraceMarkersIfNecessary(); | 392 this->recordTraceMarkersIfNecessary(draw); |
392 } | 393 } |
393 | 394 |
394 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch, | 395 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch, |
395 const PipelineInfo& pipelineInfo) { | 396 const PipelineInfo& pipelineInfo) { |
396 if (!this->setupPipelineAndShouldDraw(batch, pipelineInfo)) { | 397 if (!this->setupPipelineAndShouldDraw(batch, pipelineInfo)) { |
397 return; | 398 return; |
398 } | 399 } |
399 | 400 |
400 // Check if there is a Batch Draw we can batch with | 401 // Check if there is a Batch Draw we can batch with |
401 if (Cmd::kDrawBatch_Cmd != fCmdBuffer.back().type()) { | 402 if (Cmd::kDrawBatch_Cmd != fCmdBuffer.back().type()) { |
402 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB
atchTarget)); | 403 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB
atchTarget)); |
| 404 this->recordTraceMarkersIfNecessary(fDrawBatch); |
403 return; | 405 return; |
404 } | 406 } |
405 | 407 |
406 DrawBatch* draw = static_cast<DrawBatch*>(&fCmdBuffer.back()); | 408 SkASSERT(&fCmdBuffer.back() == fDrawBatch); |
407 if (draw->fBatch->combineIfPossible(batch)) { | 409 if (!fDrawBatch->fBatch->combineIfPossible(batch)) { |
408 return; | |
409 } else { | |
410 this->closeBatch(); | 410 this->closeBatch(); |
411 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB
atchTarget)); | 411 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB
atchTarget)); |
412 } | 412 } |
413 this->recordTraceMarkersIfNecessary(); | 413 this->recordTraceMarkersIfNecessary(fDrawBatch); |
414 } | 414 } |
415 | 415 |
416 void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder
, | 416 void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder
, |
417 const GrPathProcessor* pathProc, | 417 const GrPathProcessor* pathProc, |
418 const GrPath* path, | 418 const GrPath* path, |
419 const GrScissorState& scissorState, | 419 const GrScissorState& scissorState, |
420 const GrStencilSettings& stencilSettings
) { | 420 const GrStencilSettings& stencilSettings
) { |
421 this->closeBatch(); | 421 this->closeBatch(); |
422 | 422 |
423 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, | 423 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, |
424 (path, pipelineBuilder.getRenderT
arget())); | 424 (path, pipelineBuilder.getRenderT
arget())); |
425 | 425 |
426 sp->fScissor = scissorState; | 426 sp->fScissor = scissorState; |
427 sp->fUseHWAA = pipelineBuilder.isHWAntialias(); | 427 sp->fUseHWAA = pipelineBuilder.isHWAntialias(); |
428 sp->fViewMatrix = pathProc->viewMatrix(); | 428 sp->fViewMatrix = pathProc->viewMatrix(); |
429 sp->fStencil = stencilSettings; | 429 sp->fStencil = stencilSettings; |
430 this->recordTraceMarkersIfNecessary(); | 430 this->recordTraceMarkersIfNecessary(sp); |
431 } | 431 } |
432 | 432 |
433 void GrInOrderDrawBuffer::onDrawPath(const GrPathProcessor* pathProc, | 433 void GrInOrderDrawBuffer::onDrawPath(const GrPathProcessor* pathProc, |
434 const GrPath* path, | 434 const GrPath* path, |
435 const GrStencilSettings& stencilSettings, | 435 const GrStencilSettings& stencilSettings, |
436 const PipelineInfo& pipelineInfo) { | 436 const PipelineInfo& pipelineInfo) { |
437 this->closeBatch(); | 437 this->closeBatch(); |
438 | 438 |
439 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover
ing? | 439 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover
ing? |
440 if (!this->setupPipelineAndShouldDraw(pathProc, pipelineInfo)) { | 440 if (!this->setupPipelineAndShouldDraw(pathProc, pipelineInfo)) { |
441 return; | 441 return; |
442 } | 442 } |
443 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); | 443 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); |
444 dp->fStencilSettings = stencilSettings; | 444 dp->fStencilSettings = stencilSettings; |
445 this->recordTraceMarkersIfNecessary(); | 445 this->recordTraceMarkersIfNecessary(dp); |
446 } | 446 } |
447 | 447 |
448 void GrInOrderDrawBuffer::onDrawPaths(const GrPathProcessor* pathProc, | 448 void GrInOrderDrawBuffer::onDrawPaths(const GrPathProcessor* pathProc, |
449 const GrPathRange* pathRange, | 449 const GrPathRange* pathRange, |
450 const void* indices, | 450 const void* indices, |
451 PathIndexType indexType, | 451 PathIndexType indexType, |
452 const float transformValues[], | 452 const float transformValues[], |
453 PathTransformType transformType, | 453 PathTransformType transformType, |
454 int count, | 454 int count, |
455 const GrStencilSettings& stencilSettings, | 455 const GrStencilSettings& stencilSettings, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 505 } |
506 | 506 |
507 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange))
; | 507 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange))
; |
508 dp->fIndices = savedIndices; | 508 dp->fIndices = savedIndices; |
509 dp->fIndexType = indexType; | 509 dp->fIndexType = indexType; |
510 dp->fTransforms = savedTransforms; | 510 dp->fTransforms = savedTransforms; |
511 dp->fTransformType = transformType; | 511 dp->fTransformType = transformType; |
512 dp->fCount = count; | 512 dp->fCount = count; |
513 dp->fStencilSettings = stencilSettings; | 513 dp->fStencilSettings = stencilSettings; |
514 | 514 |
515 this->recordTraceMarkersIfNecessary(); | 515 this->recordTraceMarkersIfNecessary(dp); |
516 } | 516 } |
517 | 517 |
518 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color, | 518 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color, |
519 bool canIgnoreRect, GrRenderTarget* renderTarg
et) { | 519 bool canIgnoreRect, GrRenderTarget* renderTarg
et) { |
520 SkASSERT(renderTarget); | 520 SkASSERT(renderTarget); |
521 this->closeBatch(); | 521 this->closeBatch(); |
522 | 522 |
523 SkIRect r; | 523 SkIRect r; |
524 if (NULL == rect) { | 524 if (NULL == rect) { |
525 // We could do something smart and remove previous draws and clears to | 525 // We could do something smart and remove previous draws and clears to |
526 // the current render target. If we get that smart we have to make sure | 526 // the current render target. If we get that smart we have to make sure |
527 // those draws aren't read before this clear (render-to-texture). | 527 // those draws aren't read before this clear (render-to-texture). |
528 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height()); | 528 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height()); |
529 rect = &r; | 529 rect = &r; |
530 } | 530 } |
531 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); | 531 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); |
532 GrColorIsPMAssert(color); | 532 GrColorIsPMAssert(color); |
533 clr->fColor = color; | 533 clr->fColor = color; |
534 clr->fRect = *rect; | 534 clr->fRect = *rect; |
535 clr->fCanIgnoreRect = canIgnoreRect; | 535 clr->fCanIgnoreRect = canIgnoreRect; |
536 this->recordTraceMarkersIfNecessary(); | 536 this->recordTraceMarkersIfNecessary(clr); |
537 } | 537 } |
538 | 538 |
539 void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect, | 539 void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect, |
540 bool insideClip, | 540 bool insideClip, |
541 GrRenderTarget* renderTarget) { | 541 GrRenderTarget* renderTarget) { |
542 SkASSERT(renderTarget); | 542 SkASSERT(renderTarget); |
543 this->closeBatch(); | 543 this->closeBatch(); |
544 | 544 |
545 ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilCli
p, (renderTarget)); | 545 ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilCli
p, (renderTarget)); |
546 clr->fRect = rect; | 546 clr->fRect = rect; |
547 clr->fInsideClip = insideClip; | 547 clr->fInsideClip = insideClip; |
548 this->recordTraceMarkersIfNecessary(); | 548 this->recordTraceMarkersIfNecessary(clr); |
549 } | 549 } |
550 | 550 |
551 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { | 551 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { |
552 SkASSERT(renderTarget); | 552 SkASSERT(renderTarget); |
553 this->closeBatch(); | 553 this->closeBatch(); |
554 | 554 |
555 if (!this->caps()->discardRenderTargetSupport()) { | 555 if (!this->caps()->discardRenderTargetSupport()) { |
556 return; | 556 return; |
557 } | 557 } |
558 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); | 558 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); |
559 clr->fColor = GrColor_ILLEGAL; | 559 clr->fColor = GrColor_ILLEGAL; |
560 this->recordTraceMarkersIfNecessary(); | 560 this->recordTraceMarkersIfNecessary(clr); |
561 } | 561 } |
562 | 562 |
563 void GrInOrderDrawBuffer::onReset() { | 563 void GrInOrderDrawBuffer::onReset() { |
564 fCmdBuffer.reset(); | 564 fCmdBuffer.reset(); |
565 fPrevState = NULL; | 565 fPrevState = NULL; |
566 fPathIndexBuffer.rewind(); | 566 fPathIndexBuffer.rewind(); |
567 fPathTransformBuffer.rewind(); | 567 fPathTransformBuffer.rewind(); |
568 fGpuCmdMarkers.reset(); | 568 fGpuCmdMarkers.reset(); |
569 fDrawBatch = NULL; | 569 fDrawBatch = NULL; |
570 } | 570 } |
(...skipping 17 matching lines...) Expand all Loading... |
588 CmdBuffer::Iter iter(fCmdBuffer); | 588 CmdBuffer::Iter iter(fCmdBuffer); |
589 | 589 |
590 int currCmdMarker = 0; | 590 int currCmdMarker = 0; |
591 | 591 |
592 int i = 0; | 592 int i = 0; |
593 while (iter.next()) { | 593 while (iter.next()) { |
594 i++; | 594 i++; |
595 GrGpuTraceMarker newMarker("", -1); | 595 GrGpuTraceMarker newMarker("", -1); |
596 SkString traceString; | 596 SkString traceString; |
597 if (iter->isTraced()) { | 597 if (iter->isTraced()) { |
598 traceString = fGpuCmdMarkers[currCmdMarker].toString(); | 598 traceString = this->getCmdString(currCmdMarker); |
599 newMarker.fMarker = traceString.c_str(); | 599 newMarker.fMarker = traceString.c_str(); |
600 this->getGpu()->addGpuTraceMarker(&newMarker); | 600 this->getGpu()->addGpuTraceMarker(&newMarker); |
601 ++currCmdMarker; | 601 ++currCmdMarker; |
602 } | 602 } |
603 | 603 |
604 // TODO temporary hack | 604 // TODO temporary hack |
605 if (Cmd::kDrawBatch_Cmd == iter->type()) { | 605 if (Cmd::kDrawBatch_Cmd == iter->type()) { |
606 DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get()); | 606 DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get()); |
607 fBatchTarget.flushNext(db->fBatch->numberOfDraws()); | 607 fBatchTarget.flushNext(db->fBatch->numberOfDraws()); |
608 continue; | 608 continue; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 | 695 |
696 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, | 696 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, |
697 GrSurface* src, | 697 GrSurface* src, |
698 const SkIRect& srcRect, | 698 const SkIRect& srcRect, |
699 const SkIPoint& dstPoint) { | 699 const SkIPoint& dstPoint) { |
700 if (getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) { | 700 if (getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) { |
701 this->closeBatch(); | 701 this->closeBatch(); |
702 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); | 702 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); |
703 cs->fSrcRect = srcRect; | 703 cs->fSrcRect = srcRect; |
704 cs->fDstPoint = dstPoint; | 704 cs->fDstPoint = dstPoint; |
705 this->recordTraceMarkersIfNecessary(); | 705 this->recordTraceMarkersIfNecessary(cs); |
706 return true; | 706 return true; |
707 } | 707 } |
708 return false; | 708 return false; |
709 } | 709 } |
710 | 710 |
711 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor*
primProc, | 711 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor*
primProc, |
712 const PipelineInfo& pipelin
eInfo) { | 712 const PipelineInfo& pipelin
eInfo) { |
713 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (primProc)); | 713 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (primProc)); |
714 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); | 714 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); |
715 | 715 |
716 if (ss->getPipeline()->mustSkip()) { | 716 if (ss->getPipeline()->mustSkip()) { |
717 fCmdBuffer.pop_back(); | 717 fCmdBuffer.pop_back(); |
718 return false; | 718 return false; |
719 } | 719 } |
720 | 720 |
721 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker, | 721 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker, |
722 ss->getPipeline()->getInitBatchTra
cker()); | 722 ss->getPipeline()->getInitBatchTra
cker()); |
723 | 723 |
724 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && | 724 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && |
725 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, | 725 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, |
726 *ss->fPrimitiveProcessor, | 726 *ss->fPrimitiveProcessor, |
727 ss->fBatchTracker) && | 727 ss->fBatchTracker) && |
728 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { | 728 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { |
729 fCmdBuffer.pop_back(); | 729 fCmdBuffer.pop_back(); |
730 } else { | 730 } else { |
731 fPrevState = ss; | 731 fPrevState = ss; |
732 this->recordTraceMarkersIfNecessary(); | 732 this->recordTraceMarkersIfNecessary(ss); |
733 } | 733 } |
734 return true; | 734 return true; |
735 } | 735 } |
736 | 736 |
737 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch, | 737 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch, |
738 const PipelineInfo& pipelin
eInfo) { | 738 const PipelineInfo& pipelin
eInfo) { |
739 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, ()); | 739 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, ()); |
740 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); | 740 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); |
741 | 741 |
742 if (ss->getPipeline()->mustSkip()) { | 742 if (ss->getPipeline()->mustSkip()) { |
743 fCmdBuffer.pop_back(); | 743 fCmdBuffer.pop_back(); |
744 return false; | 744 return false; |
745 } | 745 } |
746 | 746 |
747 batch->initBatchTracker(ss->getPipeline()->getInitBatchTracker()); | 747 batch->initBatchTracker(ss->getPipeline()->getInitBatchTracker()); |
748 | 748 |
749 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && | 749 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && |
750 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { | 750 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { |
751 fCmdBuffer.pop_back(); | 751 fCmdBuffer.pop_back(); |
752 } else { | 752 } else { |
753 this->closeBatch(); | 753 this->closeBatch(); |
754 fPrevState = ss; | 754 fPrevState = ss; |
755 this->recordTraceMarkersIfNecessary(); | 755 this->recordTraceMarkersIfNecessary(ss); |
756 } | 756 } |
757 return true; | 757 return true; |
758 } | 758 } |
759 | 759 |
760 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { | 760 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary(Cmd* cmd) { |
761 SkASSERT(!fCmdBuffer.empty()); | 761 if (!cmd) { |
762 SkASSERT(!fCmdBuffer.back().isTraced()); | 762 return; |
| 763 } |
763 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); | 764 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); |
764 if (activeTraceMarkers.count() > 0) { | 765 if (activeTraceMarkers.count() > 0) { |
765 fCmdBuffer.back().makeTraced(); | 766 if (cmd->isTraced()) { |
766 fGpuCmdMarkers.push_back(activeTraceMarkers); | 767 fGpuCmdMarkers.back().addSet(activeTraceMarkers); |
| 768 } else { |
| 769 cmd->makeTraced(); |
| 770 fGpuCmdMarkers.push_back(activeTraceMarkers); |
| 771 } |
767 } | 772 } |
768 } | 773 } |
769 | 774 |
770 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, | 775 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, |
771 size_t vertexStride, | 776 size_t vertexStride, |
772 int indexCount) { | 777 int indexCount) { |
773 this->closeBatch(); | 778 this->closeBatch(); |
774 | 779 |
775 this->INHERITED::willReserveVertexAndIndexSpace(vertexCount, vertexStride, i
ndexCount); | 780 this->INHERITED::willReserveVertexAndIndexSpace(vertexCount, vertexStride, i
ndexCount); |
776 } | 781 } |
OLD | NEW |