| OLD | NEW |
| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 } | 395 } |
| 396 | 396 |
| 397 void GrTargetCommands::ClearStencilClip::execute(GrGpu* gpu, const SetState*) { | 397 void GrTargetCommands::ClearStencilClip::execute(GrGpu* gpu, const SetState*) { |
| 398 gpu->clearStencilClip(fRect, fInsideClip, this->renderTarget()); | 398 gpu->clearStencilClip(fRect, fInsideClip, this->renderTarget()); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void GrTargetCommands::CopySurface::execute(GrGpu* gpu, const SetState*) { | 401 void GrTargetCommands::CopySurface::execute(GrGpu* gpu, const SetState*) { |
| 402 gpu->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint); | 402 gpu->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint); |
| 403 } | 403 } |
| 404 | 404 |
| 405 void GrTargetCommands::XferBarrier::execute(GrGpu* gpu, const SetState* state) { |
| 406 gpu->setXferBarrier(fBarrierType); |
| 407 } |
| 408 |
| 405 GrTargetCommands::Cmd* GrTargetCommands::recordCopySurface(GrInOrderDrawBuffer*
iodb, | 409 GrTargetCommands::Cmd* GrTargetCommands::recordCopySurface(GrInOrderDrawBuffer*
iodb, |
| 406 GrSurface* dst, | 410 GrSurface* dst, |
| 407 GrSurface* src, | 411 GrSurface* src, |
| 408 const SkIRect& srcRec
t, | 412 const SkIRect& srcRec
t, |
| 409 const SkIPoint& dstPo
int) { | 413 const SkIPoint& dstPo
int) { |
| 410 if (iodb->getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) { | 414 if (iodb->getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) { |
| 411 this->closeBatch(); | 415 this->closeBatch(); |
| 412 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); | 416 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); |
| 413 cs->fSrcRect = srcRect; | 417 cs->fSrcRect = srcRect; |
| 414 cs->fDstPoint = dstPoint; | 418 cs->fDstPoint = dstPoint; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 434 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && | 438 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && |
| 435 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, | 439 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, |
| 436 *ss->fPrimitiveProcessor, | 440 *ss->fPrimitiveProcessor, |
| 437 ss->fBatchTracker) && | 441 ss->fBatchTracker) && |
| 438 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { | 442 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { |
| 439 fCmdBuffer.pop_back(); | 443 fCmdBuffer.pop_back(); |
| 440 } else { | 444 } else { |
| 441 fPrevState = ss; | 445 fPrevState = ss; |
| 442 iodb->recordTraceMarkersIfNecessary(ss); | 446 iodb->recordTraceMarkersIfNecessary(ss); |
| 443 } | 447 } |
| 448 |
| 449 this->recordXferBarrierIfNecessary(iodb, pipelineInfo); |
| 444 return true; | 450 return true; |
| 445 } | 451 } |
| 446 | 452 |
| 447 bool GrTargetCommands::setupPipelineAndShouldDraw(GrInOrderDrawBuffer* iodb, | 453 bool GrTargetCommands::setupPipelineAndShouldDraw(GrInOrderDrawBuffer* iodb, |
| 448 GrBatch* batch, | 454 GrBatch* batch, |
| 449 const GrDrawTarget::PipelineIn
fo& pipelineInfo) { | 455 const GrDrawTarget::PipelineIn
fo& pipelineInfo) { |
| 450 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, ()); | 456 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, ()); |
| 451 iodb->setupPipeline(pipelineInfo, ss->pipelineLocation()); | 457 iodb->setupPipeline(pipelineInfo, ss->pipelineLocation()); |
| 452 | 458 |
| 453 if (ss->getPipeline()->mustSkip()) { | 459 if (ss->getPipeline()->mustSkip()) { |
| 454 fCmdBuffer.pop_back(); | 460 fCmdBuffer.pop_back(); |
| 455 return false; | 461 return false; |
| 456 } | 462 } |
| 457 | 463 |
| 458 batch->initBatchTracker(ss->getPipeline()->getInitBatchTracker()); | 464 batch->initBatchTracker(ss->getPipeline()->getInitBatchTracker()); |
| 459 | 465 |
| 460 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && | 466 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && |
| 461 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { | 467 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { |
| 462 fCmdBuffer.pop_back(); | 468 fCmdBuffer.pop_back(); |
| 463 } else { | 469 } else { |
| 464 this->closeBatch(); | 470 this->closeBatch(); |
| 465 fPrevState = ss; | 471 fPrevState = ss; |
| 466 iodb->recordTraceMarkersIfNecessary(ss); | 472 iodb->recordTraceMarkersIfNecessary(ss); |
| 467 } | 473 } |
| 474 |
| 475 this->recordXferBarrierIfNecessary(iodb, pipelineInfo); |
| 468 return true; | 476 return true; |
| 469 } | 477 } |
| 470 | 478 |
| 479 void GrTargetCommands::recordXferBarrierIfNecessary(GrInOrderDrawBuffer* iodb, |
| 480 const GrDrawTarget::Pipeline
Info& info) { |
| 481 SkASSERT(fPrevState); |
| 482 const GrXferProcessor& xp = *fPrevState->getXferProcessor(); |
| 483 GrRenderTarget* rt = fPrevState->getRenderTarget(); |
| 484 |
| 485 GrXferBarrierType barrierType; |
| 486 if (!xp.willNeedXferBarrier(rt, *iodb->caps(), &barrierType)) { |
| 487 return; |
| 488 } |
| 489 |
| 490 this->closeBatch(); |
| 491 |
| 492 XferBarrier* xb = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, XferBarrier, ()); |
| 493 xb->fBarrierType = barrierType; |
| 494 |
| 495 iodb->recordTraceMarkersIfNecessary(xb); |
| 496 } |
| 497 |
| OLD | NEW |