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" |
11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.h" |
12 #include "GrTextStrike.h" | 12 #include "GrTextStrike.h" |
13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
14 #include "GrTemplates.h" | 14 #include "GrTemplates.h" |
15 #include "GrTexture.h" | 15 #include "GrTexture.h" |
16 | 16 |
17 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, | 17 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, |
18 GrVertexBufferAllocPool* vertexPool, | 18 GrVertexBufferAllocPool* vertexPool, |
19 GrIndexBufferAllocPool* indexPool) | 19 GrIndexBufferAllocPool* indexPool) |
20 : GrDrawTarget(gpu->getContext()) | 20 : INHERITED(gpu->getContext()) |
21 , fCmdBuffer(kCmdBufferInitialSizeInBytes) | 21 , fCmdBuffer(kCmdBufferInitialSizeInBytes) |
22 , fLastState(NULL) | 22 , fLastState(NULL) |
23 , fLastClip(NULL) | 23 , fLastClip(NULL) |
24 , fDstGpu(gpu) | 24 , fDstGpu(gpu) |
25 , fClipSet(true) | 25 , fClipSet(true) |
26 , fClipProxyState(kUnknown_ClipProxyState) | 26 , fClipProxyState(kUnknown_ClipProxyState) |
27 , fVertexPool(*vertexPool) | 27 , fVertexPool(*vertexPool) |
28 , fIndexPool(*indexPool) | 28 , fIndexPool(*indexPool) |
29 , fFlushing(false) | 29 , fFlushing(false) |
30 , fDrawID(0) { | 30 , fDrawID(0) { |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 rect = &r; | 427 rect = &r; |
428 } | 428 } |
429 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); | 429 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); |
430 GrColorIsPMAssert(color); | 430 GrColorIsPMAssert(color); |
431 clr->fColor = color; | 431 clr->fColor = color; |
432 clr->fRect = *rect; | 432 clr->fRect = *rect; |
433 clr->fCanIgnoreRect = canIgnoreRect; | 433 clr->fCanIgnoreRect = canIgnoreRect; |
434 this->recordTraceMarkersIfNecessary(); | 434 this->recordTraceMarkersIfNecessary(); |
435 } | 435 } |
436 | 436 |
| 437 void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect, |
| 438 bool insideClip, |
| 439 GrRenderTarget* renderTarget) { |
| 440 if (NULL == renderTarget) { |
| 441 renderTarget = this->drawState()->getRenderTarget(); |
| 442 SkASSERT(renderTarget); |
| 443 } |
| 444 ClearStencilClip* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, ClearStencilCli
p, (renderTarget)); |
| 445 clr->fRect = rect; |
| 446 clr->fInsideClip = insideClip; |
| 447 this->recordTraceMarkersIfNecessary(); |
| 448 } |
| 449 |
437 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { | 450 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { |
438 if (!this->caps()->discardRenderTargetSupport()) { | 451 if (!this->caps()->discardRenderTargetSupport()) { |
439 return; | 452 return; |
440 } | 453 } |
441 if (NULL == renderTarget) { | 454 if (NULL == renderTarget) { |
442 renderTarget = this->drawState()->getRenderTarget(); | 455 renderTarget = this->drawState()->getRenderTarget(); |
443 SkASSERT(renderTarget); | 456 SkASSERT(renderTarget); |
444 } | 457 } |
445 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); | 458 Clear* clr = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Clear, (renderTarget)); |
446 clr->fColor = GrColor_ILLEGAL; | 459 clr->fColor = GrColor_ILLEGAL; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 | 529 |
517 fDstGpu->restoreActiveTraceMarkers(); | 530 fDstGpu->restoreActiveTraceMarkers(); |
518 SkASSERT(fGpuCmdMarkers.count() == currCmdMarker); | 531 SkASSERT(fGpuCmdMarkers.count() == currCmdMarker); |
519 | 532 |
520 fDstGpu->setDrawState(prevDrawState); | 533 fDstGpu->setDrawState(prevDrawState); |
521 prevDrawState->unref(); | 534 prevDrawState->unref(); |
522 this->reset(); | 535 this->reset(); |
523 ++fDrawID; | 536 ++fDrawID; |
524 } | 537 } |
525 | 538 |
526 void GrInOrderDrawBuffer::Draw::execute(GrDrawTarget* gpu) { | 539 void GrInOrderDrawBuffer::Draw::execute(GrClipTarget* gpu) { |
527 gpu->setVertexSourceToBuffer(this->vertexBuffer()); | 540 gpu->setVertexSourceToBuffer(this->vertexBuffer()); |
528 if (fInfo.isIndexed()) { | 541 if (fInfo.isIndexed()) { |
529 gpu->setIndexSourceToBuffer(this->indexBuffer()); | 542 gpu->setIndexSourceToBuffer(this->indexBuffer()); |
530 } | 543 } |
531 gpu->executeDraw(fInfo); | 544 gpu->executeDraw(fInfo); |
532 } | 545 } |
533 | 546 |
534 void GrInOrderDrawBuffer::StencilPath::execute(GrDrawTarget* gpu) { | 547 void GrInOrderDrawBuffer::StencilPath::execute(GrClipTarget* gpu) { |
535 gpu->stencilPath(this->path(), fFill); | 548 gpu->stencilPath(this->path(), fFill); |
536 } | 549 } |
537 | 550 |
538 void GrInOrderDrawBuffer::DrawPath::execute(GrDrawTarget* gpu) { | 551 void GrInOrderDrawBuffer::DrawPath::execute(GrClipTarget* gpu) { |
539 gpu->executeDrawPath(this->path(), fFill, fDstCopy.texture() ? &fDstCopy : N
ULL); | 552 gpu->executeDrawPath(this->path(), fFill, fDstCopy.texture() ? &fDstCopy : N
ULL); |
540 } | 553 } |
541 | 554 |
542 void GrInOrderDrawBuffer::DrawPaths::execute(GrDrawTarget* gpu) { | 555 void GrInOrderDrawBuffer::DrawPaths::execute(GrClipTarget* gpu) { |
543 gpu->executeDrawPaths(this->pathRange(), this->indices(), fCount, this->tran
sforms(), | 556 gpu->executeDrawPaths(this->pathRange(), this->indices(), fCount, this->tran
sforms(), |
544 fTransformsType, fFill, fDstCopy.texture() ? &fDstCopy
: NULL); | 557 fTransformsType, fFill, fDstCopy.texture() ? &fDstCopy
: NULL); |
545 } | 558 } |
546 | 559 |
547 void GrInOrderDrawBuffer::SetState::execute(GrDrawTarget* gpu) { | 560 void GrInOrderDrawBuffer::SetState::execute(GrClipTarget* gpu) { |
548 gpu->setDrawState(&fState); | 561 gpu->setDrawState(&fState); |
549 } | 562 } |
550 | 563 |
551 void GrInOrderDrawBuffer::SetClip::execute(GrDrawTarget* gpu) { | 564 void GrInOrderDrawBuffer::SetClip::execute(GrClipTarget* gpu) { |
552 // Our fClipData is referenced directly, so we must remain alive for the ent
ire | 565 // Our fClipData is referenced directly, so we must remain alive for the ent
ire |
553 // duration of the flush (after which the gpu's previous clip is restored). | 566 // duration of the flush (after which the gpu's previous clip is restored). |
554 gpu->setClip(&fClipData); | 567 gpu->setClip(&fClipData); |
555 } | 568 } |
556 | 569 |
557 void GrInOrderDrawBuffer::Clear::execute(GrDrawTarget* gpu) { | 570 void GrInOrderDrawBuffer::Clear::execute(GrClipTarget* gpu) { |
558 if (GrColor_ILLEGAL == fColor) { | 571 if (GrColor_ILLEGAL == fColor) { |
559 gpu->discard(this->renderTarget()); | 572 gpu->discard(this->renderTarget()); |
560 } else { | 573 } else { |
561 gpu->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget()); | 574 gpu->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget()); |
562 } | 575 } |
563 } | 576 } |
564 | 577 |
565 void GrInOrderDrawBuffer::CopySurface::execute(GrDrawTarget* gpu) { | 578 void GrInOrderDrawBuffer::ClearStencilClip::execute(GrClipTarget* gpu) { |
| 579 gpu->clearStencilClip(fRect, fInsideClip, this->renderTarget()); |
| 580 } |
| 581 |
| 582 void GrInOrderDrawBuffer::CopySurface::execute(GrClipTarget* gpu) { |
566 gpu->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint); | 583 gpu->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint); |
567 } | 584 } |
568 | 585 |
569 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, | 586 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, |
570 GrSurface* src, | 587 GrSurface* src, |
571 const SkIRect& srcRect, | 588 const SkIRect& srcRect, |
572 const SkIPoint& dstPoint) { | 589 const SkIPoint& dstPoint) { |
573 if (fDstGpu->canCopySurface(dst, src, srcRect, dstPoint)) { | 590 if (fDstGpu->canCopySurface(dst, src, srcRect, dstPoint)) { |
574 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); | 591 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); |
575 cs->fSrcRect = srcRect; | 592 cs->fSrcRect = srcRect; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); | 858 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); |
842 fGpuCmdMarkers.push_back(activeTraceMarkers); | 859 fGpuCmdMarkers.push_back(activeTraceMarkers); |
843 } | 860 } |
844 } | 861 } |
845 | 862 |
846 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { | 863 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { |
847 INHERITED::clipWillBeSet(newClipData); | 864 INHERITED::clipWillBeSet(newClipData); |
848 fClipSet = true; | 865 fClipSet = true; |
849 fClipProxyState = kUnknown_ClipProxyState; | 866 fClipProxyState = kUnknown_ClipProxyState; |
850 } | 867 } |
OLD | NEW |