| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrDrawTarget.h" | 9 #include "GrDrawTarget.h" |
| 10 | 10 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 SkASSERT(pipelineBuilder.getRenderTarget()); | 346 SkASSERT(pipelineBuilder.getRenderTarget()); |
| 347 | 347 |
| 348 if (gp) { | 348 if (gp) { |
| 349 int numTextures = gp->numTextures(); | 349 int numTextures = gp->numTextures(); |
| 350 for (int t = 0; t < numTextures; ++t) { | 350 for (int t = 0; t < numTextures; ++t) { |
| 351 GrTexture* texture = gp->texture(t); | 351 GrTexture* texture = gp->texture(t); |
| 352 SkASSERT(texture->asRenderTarget() != pipelineBuilder.getRenderTarge
t()); | 352 SkASSERT(texture->asRenderTarget() != pipelineBuilder.getRenderTarge
t()); |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 | 355 |
| 356 for (int s = 0; s < pipelineBuilder.numColorStages(); ++s) { | 356 for (int s = 0; s < pipelineBuilder.numColorFragmentStages(); ++s) { |
| 357 const GrProcessor* effect = pipelineBuilder.getColorStage(s).processor()
; | 357 const GrProcessor* effect = pipelineBuilder.getColorFragmentStage(s).pro
cessor(); |
| 358 int numTextures = effect->numTextures(); | 358 int numTextures = effect->numTextures(); |
| 359 for (int t = 0; t < numTextures; ++t) { | 359 for (int t = 0; t < numTextures; ++t) { |
| 360 GrTexture* texture = effect->texture(t); | 360 GrTexture* texture = effect->texture(t); |
| 361 SkASSERT(texture->asRenderTarget() != pipelineBuilder.getRenderTarge
t()); | 361 SkASSERT(texture->asRenderTarget() != pipelineBuilder.getRenderTarge
t()); |
| 362 } | 362 } |
| 363 } | 363 } |
| 364 for (int s = 0; s < pipelineBuilder.numCoverageStages(); ++s) { | 364 for (int s = 0; s < pipelineBuilder.numCoverageFragmentStages(); ++s) { |
| 365 const GrProcessor* effect = pipelineBuilder.getCoverageStage(s).processo
r(); | 365 const GrProcessor* effect = pipelineBuilder.getCoverageFragmentStage(s).
processor(); |
| 366 int numTextures = effect->numTextures(); | 366 int numTextures = effect->numTextures(); |
| 367 for (int t = 0; t < numTextures; ++t) { | 367 for (int t = 0; t < numTextures; ++t) { |
| 368 GrTexture* texture = effect->texture(t); | 368 GrTexture* texture = effect->texture(t); |
| 369 SkASSERT(texture->asRenderTarget() != pipelineBuilder.getRenderTarge
t()); | 369 SkASSERT(texture->asRenderTarget() != pipelineBuilder.getRenderTarge
t()); |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 #endif | 373 #endif |
| 374 if (NULL == pipelineBuilder.getRenderTarget()) { | 374 if (NULL == pipelineBuilder.getRenderTarget()) { |
| 375 return false; | 375 return false; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 int vertexCount, | 436 int vertexCount, |
| 437 int indexCount, | 437 int indexCount, |
| 438 const SkRect* devBounds) { | 438 const SkRect* devBounds) { |
| 439 SkASSERT(pipelineBuilder); | 439 SkASSERT(pipelineBuilder); |
| 440 if (indexCount > 0 && | 440 if (indexCount > 0 && |
| 441 this->checkDraw(*pipelineBuilder, gp, type, startVertex, startIndex, ver
texCount, | 441 this->checkDraw(*pipelineBuilder, gp, type, startVertex, startIndex, ver
texCount, |
| 442 indexCount)) { | 442 indexCount)) { |
| 443 | 443 |
| 444 // Setup clip | 444 // Setup clip |
| 445 GrScissorState scissorState; | 445 GrScissorState scissorState; |
| 446 GrPipelineBuilder::AutoRestoreEffects are; | 446 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; |
| 447 GrPipelineBuilder::AutoRestoreStencil ars; | 447 GrPipelineBuilder::AutoRestoreStencil ars; |
| 448 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBoun
ds)) { | 448 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, devBou
nds)) { |
| 449 return; | 449 return; |
| 450 } | 450 } |
| 451 | 451 |
| 452 DrawInfo info; | 452 DrawInfo info; |
| 453 info.fPrimitiveType = type; | 453 info.fPrimitiveType = type; |
| 454 info.fStartVertex = startVertex; | 454 info.fStartVertex = startVertex; |
| 455 info.fStartIndex = startIndex; | 455 info.fStartIndex = startIndex; |
| 456 info.fVertexCount = vertexCount; | 456 info.fVertexCount = vertexCount; |
| 457 info.fIndexCount = indexCount; | 457 info.fIndexCount = indexCount; |
| 458 | 458 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 481 GrPrimitiveType type, | 481 GrPrimitiveType type, |
| 482 int startVertex, | 482 int startVertex, |
| 483 int vertexCount, | 483 int vertexCount, |
| 484 const SkRect* devBounds) { | 484 const SkRect* devBounds) { |
| 485 SkASSERT(pipelineBuilder); | 485 SkASSERT(pipelineBuilder); |
| 486 if (vertexCount > 0 && this->checkDraw(*pipelineBuilder, gp, type, startVert
ex, -1, vertexCount, | 486 if (vertexCount > 0 && this->checkDraw(*pipelineBuilder, gp, type, startVert
ex, -1, vertexCount, |
| 487 -1)) { | 487 -1)) { |
| 488 | 488 |
| 489 // Setup clip | 489 // Setup clip |
| 490 GrScissorState scissorState; | 490 GrScissorState scissorState; |
| 491 GrPipelineBuilder::AutoRestoreEffects are; | 491 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; |
| 492 GrPipelineBuilder::AutoRestoreStencil ars; | 492 GrPipelineBuilder::AutoRestoreStencil ars; |
| 493 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBoun
ds)) { | 493 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, devBou
nds)) { |
| 494 return; | 494 return; |
| 495 } | 495 } |
| 496 | 496 |
| 497 DrawInfo info; | 497 DrawInfo info; |
| 498 info.fPrimitiveType = type; | 498 info.fPrimitiveType = type; |
| 499 info.fStartVertex = startVertex; | 499 info.fStartVertex = startVertex; |
| 500 info.fStartIndex = 0; | 500 info.fStartIndex = 0; |
| 501 info.fVertexCount = vertexCount; | 501 info.fVertexCount = vertexCount; |
| 502 info.fIndexCount = 0; | 502 info.fIndexCount = 0; |
| 503 | 503 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 523 | 523 |
| 524 | 524 |
| 525 void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder, | 525 void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder, |
| 526 GrBatch* batch, | 526 GrBatch* batch, |
| 527 const SkRect* devBounds) { | 527 const SkRect* devBounds) { |
| 528 SkASSERT(pipelineBuilder); | 528 SkASSERT(pipelineBuilder); |
| 529 // TODO some kind of checkdraw, but not at this level | 529 // TODO some kind of checkdraw, but not at this level |
| 530 | 530 |
| 531 // Setup clip | 531 // Setup clip |
| 532 GrScissorState scissorState; | 532 GrScissorState scissorState; |
| 533 GrPipelineBuilder::AutoRestoreEffects are; | 533 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; |
| 534 GrPipelineBuilder::AutoRestoreStencil ars; | 534 GrPipelineBuilder::AutoRestoreStencil ars; |
| 535 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBounds))
{ | 535 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, devBounds)
) { |
| 536 return; | 536 return; |
| 537 } | 537 } |
| 538 | 538 |
| 539 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batc
h, devBounds, this); | 539 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batc
h, devBounds, this); |
| 540 if (pipelineInfo.mustSkipDraw()) { | 540 if (pipelineInfo.mustSkipDraw()) { |
| 541 return; | 541 return; |
| 542 } | 542 } |
| 543 | 543 |
| 544 this->onDrawBatch(batch, pipelineInfo); | 544 this->onDrawBatch(batch, pipelineInfo); |
| 545 } | 545 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 const GrPathProcessor* pathProc, | 583 const GrPathProcessor* pathProc, |
| 584 const GrPath* path, | 584 const GrPath* path, |
| 585 GrPathRendering::FillType fill) { | 585 GrPathRendering::FillType fill) { |
| 586 // TODO: extract portions of checkDraw that are relevant to path stenciling. | 586 // TODO: extract portions of checkDraw that are relevant to path stenciling. |
| 587 SkASSERT(path); | 587 SkASSERT(path); |
| 588 SkASSERT(this->caps()->pathRenderingSupport()); | 588 SkASSERT(this->caps()->pathRenderingSupport()); |
| 589 SkASSERT(pipelineBuilder); | 589 SkASSERT(pipelineBuilder); |
| 590 | 590 |
| 591 // Setup clip | 591 // Setup clip |
| 592 GrScissorState scissorState; | 592 GrScissorState scissorState; |
| 593 GrPipelineBuilder::AutoRestoreEffects are; | 593 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; |
| 594 GrPipelineBuilder::AutoRestoreStencil ars; | 594 GrPipelineBuilder::AutoRestoreStencil ars; |
| 595 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, NULL)) { | 595 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, NULL)) { |
| 596 return; | 596 return; |
| 597 } | 597 } |
| 598 | 598 |
| 599 // set stencil settings for path | 599 // set stencil settings for path |
| 600 GrStencilSettings stencilSettings; | 600 GrStencilSettings stencilSettings; |
| 601 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | 601 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); |
| 602 GrStencilBuffer* sb = rt->renderTargetPriv().attachStencilBuffer(); | 602 GrStencilBuffer* sb = rt->renderTargetPriv().attachStencilBuffer(); |
| 603 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 603 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
| 604 | 604 |
| 605 this->onStencilPath(*pipelineBuilder, pathProc, path, scissorState, stencilS
ettings); | 605 this->onStencilPath(*pipelineBuilder, pathProc, path, scissorState, stencilS
ettings); |
| 606 } | 606 } |
| 607 | 607 |
| 608 void GrDrawTarget::drawPath(GrPipelineBuilder* pipelineBuilder, | 608 void GrDrawTarget::drawPath(GrPipelineBuilder* pipelineBuilder, |
| 609 const GrPathProcessor* pathProc, | 609 const GrPathProcessor* pathProc, |
| 610 const GrPath* path, | 610 const GrPath* path, |
| 611 GrPathRendering::FillType fill) { | 611 GrPathRendering::FillType fill) { |
| 612 // TODO: extract portions of checkDraw that are relevant to path rendering. | 612 // TODO: extract portions of checkDraw that are relevant to path rendering. |
| 613 SkASSERT(path); | 613 SkASSERT(path); |
| 614 SkASSERT(this->caps()->pathRenderingSupport()); | 614 SkASSERT(this->caps()->pathRenderingSupport()); |
| 615 SkASSERT(pipelineBuilder); | 615 SkASSERT(pipelineBuilder); |
| 616 | 616 |
| 617 SkRect devBounds = path->getBounds(); | 617 SkRect devBounds = path->getBounds(); |
| 618 pathProc->viewMatrix().mapRect(&devBounds); | 618 pathProc->viewMatrix().mapRect(&devBounds); |
| 619 | 619 |
| 620 // Setup clip | 620 // Setup clip |
| 621 GrScissorState scissorState; | 621 GrScissorState scissorState; |
| 622 GrPipelineBuilder::AutoRestoreEffects are; | 622 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; |
| 623 GrPipelineBuilder::AutoRestoreStencil ars; | 623 GrPipelineBuilder::AutoRestoreStencil ars; |
| 624 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, &devBounds)
) { | 624 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, &devBounds
)) { |
| 625 return; | 625 return; |
| 626 } | 626 } |
| 627 | 627 |
| 628 // set stencil settings for path | 628 // set stencil settings for path |
| 629 GrStencilSettings stencilSettings; | 629 GrStencilSettings stencilSettings; |
| 630 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | 630 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); |
| 631 GrStencilBuffer* sb = rt->renderTargetPriv().attachStencilBuffer(); | 631 GrStencilBuffer* sb = rt->renderTargetPriv().attachStencilBuffer(); |
| 632 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 632 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
| 633 | 633 |
| 634 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path
Proc, &devBounds, | 634 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path
Proc, &devBounds, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 651 GrPathRendering::FillType fill) { | 651 GrPathRendering::FillType fill) { |
| 652 SkASSERT(this->caps()->pathRenderingSupport()); | 652 SkASSERT(this->caps()->pathRenderingSupport()); |
| 653 SkASSERT(pathRange); | 653 SkASSERT(pathRange); |
| 654 SkASSERT(indices); | 654 SkASSERT(indices); |
| 655 SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeIn
Bytes(indexType)); | 655 SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeIn
Bytes(indexType)); |
| 656 SkASSERT(transformValues); | 656 SkASSERT(transformValues); |
| 657 SkASSERT(pipelineBuilder); | 657 SkASSERT(pipelineBuilder); |
| 658 | 658 |
| 659 // Setup clip | 659 // Setup clip |
| 660 GrScissorState scissorState; | 660 GrScissorState scissorState; |
| 661 GrPipelineBuilder::AutoRestoreEffects are; | 661 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; |
| 662 GrPipelineBuilder::AutoRestoreStencil ars; | 662 GrPipelineBuilder::AutoRestoreStencil ars; |
| 663 | 663 |
| 664 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, NULL)) { | 664 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, NULL)) { |
| 665 return; | 665 return; |
| 666 } | 666 } |
| 667 | 667 |
| 668 // set stencil settings for path | 668 // set stencil settings for path |
| 669 GrStencilSettings stencilSettings; | 669 GrStencilSettings stencilSettings; |
| 670 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | 670 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); |
| 671 GrStencilBuffer* sb = rt->renderTargetPriv().attachStencilBuffer(); | 671 GrStencilBuffer* sb = rt->renderTargetPriv().attachStencilBuffer(); |
| 672 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 672 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
| 673 | 673 |
| 674 // Don't compute a bounding box for dst copy texture, we'll opt | 674 // Don't compute a bounding box for dst copy texture, we'll opt |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 return; | 762 return; |
| 763 } | 763 } |
| 764 | 764 |
| 765 int maxInstancesPerDraw = this->indexCountInCurrentSource() / indicesPerInst
ance; | 765 int maxInstancesPerDraw = this->indexCountInCurrentSource() / indicesPerInst
ance; |
| 766 if (!maxInstancesPerDraw) { | 766 if (!maxInstancesPerDraw) { |
| 767 return; | 767 return; |
| 768 } | 768 } |
| 769 | 769 |
| 770 // Setup clip | 770 // Setup clip |
| 771 GrScissorState scissorState; | 771 GrScissorState scissorState; |
| 772 GrPipelineBuilder::AutoRestoreEffects are; | 772 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; |
| 773 GrPipelineBuilder::AutoRestoreStencil ars; | 773 GrPipelineBuilder::AutoRestoreStencil ars; |
| 774 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBounds))
{ | 774 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, devBounds)
) { |
| 775 return; | 775 return; |
| 776 } | 776 } |
| 777 | 777 |
| 778 DrawInfo info; | 778 DrawInfo info; |
| 779 info.fPrimitiveType = type; | 779 info.fPrimitiveType = type; |
| 780 info.fStartIndex = 0; | 780 info.fStartIndex = 0; |
| 781 info.fStartVertex = 0; | 781 info.fStartVertex = 0; |
| 782 info.fIndicesPerInstance = indicesPerInstance; | 782 info.fIndicesPerInstance = indicesPerInstance; |
| 783 info.fVerticesPerInstance = verticesPerInstance; | 783 info.fVerticesPerInstance = verticesPerInstance; |
| 784 | 784 |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 uint32_t id; | 1261 uint32_t id; |
| 1262 do { | 1262 do { |
| 1263 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 1263 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 1264 } while (id == SK_InvalidUniqueID); | 1264 } while (id == SK_InvalidUniqueID); |
| 1265 return id; | 1265 return id; |
| 1266 } | 1266 } |
| 1267 | 1267 |
| 1268 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 1268 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 1269 | 1269 |
| 1270 bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder, | 1270 bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder, |
| 1271 GrPipelineBuilder::AutoRestoreEffects* are, | 1271 GrPipelineBuilder::AutoRestoreFragmentProcessors* a
rfp, |
| 1272 GrPipelineBuilder::AutoRestoreStencil* ars, | 1272 GrPipelineBuilder::AutoRestoreStencil* ars, |
| 1273 GrScissorState* scissorState, | 1273 GrScissorState* scissorState, |
| 1274 const SkRect* devBounds) { | 1274 const SkRect* devBounds) { |
| 1275 return fClipMaskManager.setupClipping(pipelineBuilder, | 1275 return fClipMaskManager.setupClipping(pipelineBuilder, |
| 1276 are, | 1276 arfp, |
| 1277 ars, | 1277 ars, |
| 1278 scissorState, | 1278 scissorState, |
| 1279 devBounds); | 1279 devBounds); |
| 1280 } | 1280 } |
| OLD | NEW |