Chromium Code Reviews| 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()) { |
| 403 this->closeBatch(); | |
|
joshualitt
2015/02/27 19:43:24
I should have been paying more attention. This cl
robertphillips
2015/02/27 20:52:39
Done.
| |
| 402 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget)); | 404 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget)); |
| 405 this->recordTraceMarkersIfNecessary(fDrawBatch); | |
| 403 return; | 406 return; |
| 404 } | 407 } |
| 405 | 408 |
| 406 DrawBatch* draw = static_cast<DrawBatch*>(&fCmdBuffer.back()); | 409 DrawBatch* draw = static_cast<DrawBatch*>(&fCmdBuffer.back()); |
|
egdaniel
2015/02/27 20:09:36
I'm pretty sure this draw is fDrawBatch so we can
robertphillips
2015/02/27 20:52:39
Done.
robertphillips
2015/02/27 21:06:16
Done.
| |
| 407 if (draw->fBatch->combineIfPossible(batch)) { | 410 if (draw->fBatch->combineIfPossible(batch)) { |
| 408 return; | 411 return; |
| 409 } else { | 412 } else { |
| 410 this->closeBatch(); | 413 this->closeBatch(); |
| 411 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget)); | 414 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fB atchTarget)); |
| 412 } | 415 } |
| 413 this->recordTraceMarkersIfNecessary(); | 416 this->recordTraceMarkersIfNecessary(fDrawBatch); |
| 414 } | 417 } |
| 415 | 418 |
| 416 void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder , | 419 void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder , |
| 417 const GrPathProcessor* pathProc, | 420 const GrPathProcessor* pathProc, |
| 418 const GrPath* path, | 421 const GrPath* path, |
| 419 const GrScissorState& scissorState, | 422 const GrScissorState& scissorState, |
| 420 const GrStencilSettings& stencilSettings ) { | 423 const GrStencilSettings& stencilSettings ) { |
| 421 this->closeBatch(); | 424 this->closeBatch(); |
| 422 | 425 |
| 423 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, | 426 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, |
| 424 (path, pipelineBuilder.getRenderT arget())); | 427 (path, pipelineBuilder.getRenderT arget())); |
| 425 | 428 |
| 426 sp->fScissor = scissorState; | 429 sp->fScissor = scissorState; |
| 427 sp->fUseHWAA = pipelineBuilder.isHWAntialias(); | 430 sp->fUseHWAA = pipelineBuilder.isHWAntialias(); |
| 428 sp->fViewMatrix = pathProc->viewMatrix(); | 431 sp->fViewMatrix = pathProc->viewMatrix(); |
| 429 sp->fStencil = stencilSettings; | 432 sp->fStencil = stencilSettings; |
| 430 this->recordTraceMarkersIfNecessary(); | 433 this->recordTraceMarkersIfNecessary(sp); |
| 431 } | 434 } |
| 432 | 435 |
| 433 void GrInOrderDrawBuffer::onDrawPath(const GrPathProcessor* pathProc, | 436 void GrInOrderDrawBuffer::onDrawPath(const GrPathProcessor* pathProc, |
| 434 const GrPath* path, | 437 const GrPath* path, |
| 435 const GrStencilSettings& stencilSettings, | 438 const GrStencilSettings& stencilSettings, |
| 436 const PipelineInfo& pipelineInfo) { | 439 const PipelineInfo& pipelineInfo) { |
| 437 this->closeBatch(); | 440 this->closeBatch(); |
| 438 | 441 |
| 439 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover ing? | 442 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover ing? |
| 440 if (!this->setupPipelineAndShouldDraw(pathProc, pipelineInfo)) { | 443 if (!this->setupPipelineAndShouldDraw(pathProc, pipelineInfo)) { |
| 441 return; | 444 return; |
| 442 } | 445 } |
| 443 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); | 446 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); |
| 444 dp->fStencilSettings = stencilSettings; | 447 dp->fStencilSettings = stencilSettings; |
| 445 this->recordTraceMarkersIfNecessary(); | 448 this->recordTraceMarkersIfNecessary(dp); |
| 446 } | 449 } |
| 447 | 450 |
| 448 void GrInOrderDrawBuffer::onDrawPaths(const GrPathProcessor* pathProc, | 451 void GrInOrderDrawBuffer::onDrawPaths(const GrPathProcessor* pathProc, |
| 449 const GrPathRange* pathRange, | 452 const GrPathRange* pathRange, |
| 450 const void* indices, | 453 const void* indices, |
| 451 PathIndexType indexType, | 454 PathIndexType indexType, |
| 452 const float transformValues[], | 455 const float transformValues[], |
| 453 PathTransformType transformType, | 456 PathTransformType transformType, |
| 454 int count, | 457 int count, |
| 455 const GrStencilSettings& stencilSettings, | 458 const GrStencilSettings& stencilSettings, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 } | 508 } |
| 506 | 509 |
| 507 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange)) ; | 510 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange)) ; |
| 508 dp->fIndices = savedIndices; | 511 dp->fIndices = savedIndices; |
| 509 dp->fIndexType = indexType; | 512 dp->fIndexType = indexType; |
| 510 dp->fTransforms = savedTransforms; | 513 dp->fTransforms = savedTransforms; |
| 511 dp->fTransformType = transformType; | 514 dp->fTransformType = transformType; |
| 512 dp->fCount = count; | 515 dp->fCount = count; |
| 513 dp->fStencilSettings = stencilSettings; | 516 dp->fStencilSettings = stencilSettings; |
| 514 | 517 |
| 515 this->recordTraceMarkersIfNecessary(); | 518 this->recordTraceMarkersIfNecessary(dp); |
| 516 } | 519 } |
| 517 | 520 |
| 518 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color, | 521 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color, |
| 519 bool canIgnoreRect, GrRenderTarget* renderTarg et) { | 522 bool canIgnoreRect, GrRenderTarget* renderTarg et) { |
| 520 SkASSERT(renderTarget); | 523 SkASSERT(renderTarget); |
| 521 this->closeBatch(); | 524 this->closeBatch(); |
| 522 | 525 |
| 523 SkIRect r; | 526 SkIRect r; |
| 524 if (NULL == rect) { | 527 if (NULL == rect) { |
| 525 // We could do something smart and remove previous draws and clears to | 528 // 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 | 529 // 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). | 530 // those draws aren't read before this clear (render-to-texture). |
| 528 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height()); | 531 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height()); |
| 529 rect = &r; | 532 rect = &r; |
| 530 } | 533 } |
| 531 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); | 534 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); |
| 532 GrColorIsPMAssert(color); | 535 GrColorIsPMAssert(color); |
| 533 clr->fColor = color; | 536 clr->fColor = color; |
| 534 clr->fRect = *rect; | 537 clr->fRect = *rect; |
| 535 clr->fCanIgnoreRect = canIgnoreRect; | 538 clr->fCanIgnoreRect = canIgnoreRect; |
| 536 this->recordTraceMarkersIfNecessary(); | 539 this->recordTraceMarkersIfNecessary(clr); |
| 537 } | 540 } |
| 538 | 541 |
| 539 void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect, | 542 void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect, |
| 540 bool insideClip, | 543 bool insideClip, |
| 541 GrRenderTarget* renderTarget) { | 544 GrRenderTarget* renderTarget) { |
| 542 SkASSERT(renderTarget); | 545 SkASSERT(renderTarget); |
| 543 this->closeBatch(); | 546 this->closeBatch(); |
| 544 | 547 |
| 545 ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilCli p, (renderTarget)); | 548 ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilCli p, (renderTarget)); |
| 546 clr->fRect = rect; | 549 clr->fRect = rect; |
| 547 clr->fInsideClip = insideClip; | 550 clr->fInsideClip = insideClip; |
| 548 this->recordTraceMarkersIfNecessary(); | 551 this->recordTraceMarkersIfNecessary(clr); |
| 549 } | 552 } |
| 550 | 553 |
| 551 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { | 554 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { |
| 552 SkASSERT(renderTarget); | 555 SkASSERT(renderTarget); |
| 553 this->closeBatch(); | 556 this->closeBatch(); |
| 554 | 557 |
| 555 if (!this->caps()->discardRenderTargetSupport()) { | 558 if (!this->caps()->discardRenderTargetSupport()) { |
| 556 return; | 559 return; |
| 557 } | 560 } |
| 558 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); | 561 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); |
| 559 clr->fColor = GrColor_ILLEGAL; | 562 clr->fColor = GrColor_ILLEGAL; |
| 560 this->recordTraceMarkersIfNecessary(); | 563 this->recordTraceMarkersIfNecessary(clr); |
| 561 } | 564 } |
| 562 | 565 |
| 563 void GrInOrderDrawBuffer::onReset() { | 566 void GrInOrderDrawBuffer::onReset() { |
| 564 fCmdBuffer.reset(); | 567 fCmdBuffer.reset(); |
| 565 fPrevState = NULL; | 568 fPrevState = NULL; |
| 566 fPathIndexBuffer.rewind(); | 569 fPathIndexBuffer.rewind(); |
| 567 fPathTransformBuffer.rewind(); | 570 fPathTransformBuffer.rewind(); |
| 568 fGpuCmdMarkers.reset(); | 571 fGpuCmdMarkers.reset(); |
| 569 fDrawBatch = NULL; | 572 fDrawBatch = NULL; |
| 570 } | 573 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 588 CmdBuffer::Iter iter(fCmdBuffer); | 591 CmdBuffer::Iter iter(fCmdBuffer); |
| 589 | 592 |
| 590 int currCmdMarker = 0; | 593 int currCmdMarker = 0; |
| 591 | 594 |
| 592 int i = 0; | 595 int i = 0; |
| 593 while (iter.next()) { | 596 while (iter.next()) { |
| 594 i++; | 597 i++; |
| 595 GrGpuTraceMarker newMarker("", -1); | 598 GrGpuTraceMarker newMarker("", -1); |
| 596 SkString traceString; | 599 SkString traceString; |
| 597 if (iter->isTraced()) { | 600 if (iter->isTraced()) { |
| 598 traceString = fGpuCmdMarkers[currCmdMarker].toString(); | 601 traceString = this->getCmdString(currCmdMarker); |
| 599 newMarker.fMarker = traceString.c_str(); | 602 newMarker.fMarker = traceString.c_str(); |
| 600 this->getGpu()->addGpuTraceMarker(&newMarker); | 603 this->getGpu()->addGpuTraceMarker(&newMarker); |
| 601 ++currCmdMarker; | 604 ++currCmdMarker; |
| 602 } | 605 } |
| 603 | 606 |
| 604 // TODO temporary hack | 607 // TODO temporary hack |
| 605 if (Cmd::kDrawBatch_Cmd == iter->type()) { | 608 if (Cmd::kDrawBatch_Cmd == iter->type()) { |
| 606 DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get()); | 609 DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get()); |
| 607 fBatchTarget.flushNext(db->fBatch->numberOfDraws()); | 610 fBatchTarget.flushNext(db->fBatch->numberOfDraws()); |
| 608 continue; | 611 continue; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 | 698 |
| 696 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, | 699 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, |
| 697 GrSurface* src, | 700 GrSurface* src, |
| 698 const SkIRect& srcRect, | 701 const SkIRect& srcRect, |
| 699 const SkIPoint& dstPoint) { | 702 const SkIPoint& dstPoint) { |
| 700 if (getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) { | 703 if (getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) { |
| 701 this->closeBatch(); | 704 this->closeBatch(); |
| 702 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst , src)); | 705 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst , src)); |
| 703 cs->fSrcRect = srcRect; | 706 cs->fSrcRect = srcRect; |
| 704 cs->fDstPoint = dstPoint; | 707 cs->fDstPoint = dstPoint; |
| 705 this->recordTraceMarkersIfNecessary(); | 708 this->recordTraceMarkersIfNecessary(cs); |
| 706 return true; | 709 return true; |
| 707 } | 710 } |
| 708 return false; | 711 return false; |
| 709 } | 712 } |
| 710 | 713 |
| 711 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor* primProc, | 714 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor* primProc, |
| 712 const PipelineInfo& pipelin eInfo) { | 715 const PipelineInfo& pipelin eInfo) { |
| 713 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (primProc)); | 716 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (primProc)); |
| 714 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); | 717 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); |
| 715 | 718 |
| 716 if (ss->getPipeline()->mustSkip()) { | 719 if (ss->getPipeline()->mustSkip()) { |
| 717 fCmdBuffer.pop_back(); | 720 fCmdBuffer.pop_back(); |
| 718 return false; | 721 return false; |
| 719 } | 722 } |
| 720 | 723 |
| 721 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker, | 724 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker, |
| 722 ss->getPipeline()->getInitBatchTra cker()); | 725 ss->getPipeline()->getInitBatchTra cker()); |
| 723 | 726 |
| 724 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && | 727 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && |
| 725 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, | 728 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, |
| 726 *ss->fPrimitiveProcessor, | 729 *ss->fPrimitiveProcessor, |
| 727 ss->fBatchTracker) && | 730 ss->fBatchTracker) && |
| 728 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { | 731 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { |
| 729 fCmdBuffer.pop_back(); | 732 fCmdBuffer.pop_back(); |
| 730 } else { | 733 } else { |
| 731 fPrevState = ss; | 734 fPrevState = ss; |
| 732 this->recordTraceMarkersIfNecessary(); | 735 this->recordTraceMarkersIfNecessary(ss); |
| 733 } | 736 } |
| 734 return true; | 737 return true; |
| 735 } | 738 } |
| 736 | 739 |
| 737 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch, | 740 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch, |
| 738 const PipelineInfo& pipelin eInfo) { | 741 const PipelineInfo& pipelin eInfo) { |
| 739 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, ()); | 742 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, ()); |
| 740 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); | 743 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); |
| 741 | 744 |
| 742 if (ss->getPipeline()->mustSkip()) { | 745 if (ss->getPipeline()->mustSkip()) { |
| 743 fCmdBuffer.pop_back(); | 746 fCmdBuffer.pop_back(); |
| 744 return false; | 747 return false; |
| 745 } | 748 } |
| 746 | 749 |
| 747 batch->initBatchTracker(ss->getPipeline()->getInitBatchTracker()); | 750 batch->initBatchTracker(ss->getPipeline()->getInitBatchTracker()); |
| 748 | 751 |
| 749 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && | 752 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && |
| 750 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { | 753 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { |
| 751 fCmdBuffer.pop_back(); | 754 fCmdBuffer.pop_back(); |
| 752 } else { | 755 } else { |
| 753 this->closeBatch(); | 756 this->closeBatch(); |
| 754 fPrevState = ss; | 757 fPrevState = ss; |
| 755 this->recordTraceMarkersIfNecessary(); | 758 this->recordTraceMarkersIfNecessary(ss); |
| 756 } | 759 } |
| 757 return true; | 760 return true; |
| 758 } | 761 } |
| 759 | 762 |
| 760 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { | 763 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary(Cmd* cmd) { |
| 761 SkASSERT(!fCmdBuffer.empty()); | 764 if (!cmd) { |
| 762 SkASSERT(!fCmdBuffer.back().isTraced()); | 765 return; |
| 766 } | |
| 763 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); | 767 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); |
| 764 if (activeTraceMarkers.count() > 0) { | 768 if (activeTraceMarkers.count() > 0) { |
| 765 fCmdBuffer.back().makeTraced(); | 769 if (cmd->isTraced()) { |
| 766 fGpuCmdMarkers.push_back(activeTraceMarkers); | 770 fGpuCmdMarkers.back().addSet(activeTraceMarkers); |
| 771 } else { | |
| 772 cmd->makeTraced(); | |
| 773 fGpuCmdMarkers.push_back(activeTraceMarkers); | |
| 774 } | |
| 767 } | 775 } |
| 768 } | 776 } |
| 769 | 777 |
| 770 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, | 778 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, |
| 771 size_t vertexStride, | 779 size_t vertexStride, |
| 772 int indexCount) { | 780 int indexCount) { |
| 773 this->closeBatch(); | 781 this->closeBatch(); |
| 774 | 782 |
| 775 this->INHERITED::willReserveVertexAndIndexSpace(vertexCount, vertexStride, i ndexCount); | 783 this->INHERITED::willReserveVertexAndIndexSpace(vertexCount, vertexStride, i ndexCount); |
| 776 } | 784 } |
| OLD | NEW |