 Chromium Code Reviews
 Chromium Code Reviews Issue 885923002:
  Move DstCopy on gpu into the GrXferProcessor.  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master
    
  
    Issue 885923002:
  Move DstCopy on gpu into the GrXferProcessor.  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master| 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 } | 377 } | 
| 378 } | 378 } | 
| 379 | 379 | 
| 380 #endif | 380 #endif | 
| 381 if (NULL == pipelineBuilder.getRenderTarget()) { | 381 if (NULL == pipelineBuilder.getRenderTarget()) { | 
| 382 return false; | 382 return false; | 
| 383 } | 383 } | 
| 384 return true; | 384 return true; | 
| 385 } | 385 } | 
| 386 | 386 | 
| 387 bool GrDrawTarget::setupDstReadIfNecessary(GrPipelineBuilder* pipelineBuilder, | 387 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil der, | 
| 388 GrDeviceCoordTexture* dstCopy, | 388 GrDeviceCoordTexture* dstCopy, | 
| 389 const SkRect* drawBounds) { | 389 const SkRect* drawBounds) { | 
| 390 if (this->caps()->dstReadInShaderSupport() || !pipelineBuilder->willEffectRe adDstColor()) { | 390 if (!pipelineBuilder.willXPNeedDstCopy(*this->caps())) { | 
| 391 return true; | 391 return true; | 
| 392 } | 392 } | 
| 393 SkIRect copyRect; | 393 SkIRect copyRect; | 
| 394 const GrClipData* clip = this->getClip(); | 394 const GrClipData* clip = this->getClip(); | 
| 395 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | 395 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 
| 396 clip->getConservativeBounds(rt, ©Rect); | 396 clip->getConservativeBounds(rt, ©Rect); | 
| 397 | 397 | 
| 398 if (drawBounds) { | 398 if (drawBounds) { | 
| 399 SkIRect drawIBounds; | 399 SkIRect drawIBounds; | 
| 400 drawBounds->roundOut(&drawIBounds); | 400 drawBounds->roundOut(&drawIBounds); | 
| 401 if (!copyRect.intersect(drawIBounds)) { | 401 if (!copyRect.intersect(drawIBounds)) { | 
| 402 #ifdef SK_DEBUG | 402 #ifdef SK_DEBUG | 
| 403 SkDebugf("Missed an early reject. Bailing on draw from setupDstReadI fNecessary.\n"); | 403 SkDebugf("Missed an early reject. Bailing on draw from setupDstReadI fNecessary.\n"); | 
| 404 #endif | 404 #endif | 
| 405 return false; | 405 return false; | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 info.fIndexCount = indexCount; | 463 info.fIndexCount = indexCount; | 
| 464 | 464 | 
| 465 info.fInstanceCount = 0; | 465 info.fInstanceCount = 0; | 
| 466 info.fVerticesPerInstance = 0; | 466 info.fVerticesPerInstance = 0; | 
| 467 info.fIndicesPerInstance = 0; | 467 info.fIndicesPerInstance = 0; | 
| 468 | 468 | 
| 469 if (devBounds) { | 469 if (devBounds) { | 
| 470 info.setDevBounds(*devBounds); | 470 info.setDevBounds(*devBounds); | 
| 471 } | 471 } | 
| 472 | 472 | 
| 473 // TODO: We should continue with incorrect blending. | |
| 474 GrDeviceCoordTexture dstCopy; | |
| 475 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds) ) { | |
| 476 return; | |
| 477 } | |
| 478 this->setDrawBuffers(&info, gp->getVertexStride()); | 473 this->setDrawBuffers(&info, gp->getVertexStride()); | 
| 479 | 474 | 
| 480 this->onDraw(*pipelineBuilder, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL); | 475 this->onDraw(*pipelineBuilder, gp, info, scissorState); | 
| 481 } | 476 } | 
| 482 } | 477 } | 
| 483 | 478 | 
| 484 void GrDrawTarget::drawNonIndexed(GrPipelineBuilder* pipelineBuilder, | 479 void GrDrawTarget::drawNonIndexed(GrPipelineBuilder* pipelineBuilder, | 
| 485 const GrGeometryProcessor* gp, | 480 const GrGeometryProcessor* gp, | 
| 486 GrPrimitiveType type, | 481 GrPrimitiveType type, | 
| 487 int startVertex, | 482 int startVertex, | 
| 488 int vertexCount, | 483 int vertexCount, | 
| 489 const SkRect* devBounds) { | 484 const SkRect* devBounds) { | 
| 490 SkASSERT(pipelineBuilder); | 485 SkASSERT(pipelineBuilder); | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 507 info.fIndexCount = 0; | 502 info.fIndexCount = 0; | 
| 508 | 503 | 
| 509 info.fInstanceCount = 0; | 504 info.fInstanceCount = 0; | 
| 510 info.fVerticesPerInstance = 0; | 505 info.fVerticesPerInstance = 0; | 
| 511 info.fIndicesPerInstance = 0; | 506 info.fIndicesPerInstance = 0; | 
| 512 | 507 | 
| 513 if (devBounds) { | 508 if (devBounds) { | 
| 514 info.setDevBounds(*devBounds); | 509 info.setDevBounds(*devBounds); | 
| 515 } | 510 } | 
| 516 | 511 | 
| 517 // TODO: We should continue with incorrect blending. | |
| 518 GrDeviceCoordTexture dstCopy; | |
| 519 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds) ) { | |
| 520 return; | |
| 521 } | |
| 522 | |
| 523 this->setDrawBuffers(&info, gp->getVertexStride()); | 512 this->setDrawBuffers(&info, gp->getVertexStride()); | 
| 524 | 513 | 
| 525 this->onDraw(*pipelineBuilder, gp, info, scissorState, dstCopy.texture() ? &dstCopy : NULL); | 514 this->onDraw(*pipelineBuilder, gp, info, scissorState); | 
| 526 } | 515 } | 
| 527 } | 516 } | 
| 528 | 517 | 
| 529 | 518 | 
| 530 void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder, | 519 void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder, | 
| 531 GrBatch* batch, | 520 GrBatch* batch, | 
| 532 const SkRect* devBounds) { | 521 const SkRect* devBounds) { | 
| 533 SkASSERT(pipelineBuilder); | 522 SkASSERT(pipelineBuilder); | 
| 534 // TODO some kind of checkdraw, but not at this level | 523 // TODO some kind of checkdraw, but not at this level | 
| 535 | 524 | 
| 536 // Setup clip | 525 // Setup clip | 
| 537 GrScissorState scissorState; | 526 GrScissorState scissorState; | 
| 538 GrPipelineBuilder::AutoRestoreEffects are; | 527 GrPipelineBuilder::AutoRestoreEffects are; | 
| 539 GrPipelineBuilder::AutoRestoreStencil ars; | 528 GrPipelineBuilder::AutoRestoreStencil ars; | 
| 540 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBounds)) { | 529 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBounds)) { | 
| 541 return; | 530 return; | 
| 542 } | 531 } | 
| 543 | 532 | 
| 544 GrDeviceCoordTexture dstCopy; | 533 this->onDrawBatch(batch, *pipelineBuilder, scissorState, devBounds); | 
| 545 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) { | |
| 546 return; | |
| 547 } | |
| 548 | |
| 549 this->onDrawBatch(batch, *pipelineBuilder, scissorState, dstCopy.texture() ? &dstCopy : NULL); | |
| 550 } | 534 } | 
| 551 | 535 | 
| 552 static const GrStencilSettings& winding_path_stencil_settings() { | 536 static const GrStencilSettings& winding_path_stencil_settings() { | 
| 553 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | 537 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | 
| 554 kIncClamp_StencilOp, | 538 kIncClamp_StencilOp, | 
| 555 kIncClamp_StencilOp, | 539 kIncClamp_StencilOp, | 
| 556 kAlwaysIfInClip_StencilFunc, | 540 kAlwaysIfInClip_StencilFunc, | 
| 557 0xFFFF, 0xFFFF, 0xFFFF); | 541 0xFFFF, 0xFFFF, 0xFFFF); | 
| 558 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | 542 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | 
| 559 } | 543 } | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, &devBounds) ) { | 613 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, &devBounds) ) { | 
| 630 return; | 614 return; | 
| 631 } | 615 } | 
| 632 | 616 | 
| 633 // set stencil settings for path | 617 // set stencil settings for path | 
| 634 GrStencilSettings stencilSettings; | 618 GrStencilSettings stencilSettings; | 
| 635 this->getPathStencilSettingsForFilltype(fill, | 619 this->getPathStencilSettingsForFilltype(fill, | 
| 636 pipelineBuilder->getRenderTarget()-> getStencilBuffer(), | 620 pipelineBuilder->getRenderTarget()-> getStencilBuffer(), | 
| 637 &stencilSettings); | 621 &stencilSettings); | 
| 638 | 622 | 
| 639 GrDeviceCoordTexture dstCopy; | |
| 640 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, &devBounds)) { | |
| 641 return; | |
| 642 } | |
| 643 | |
| 644 this->onDrawPath(*pipelineBuilder, pathProc, path, scissorState, stencilSett ings, | 623 this->onDrawPath(*pipelineBuilder, pathProc, path, scissorState, stencilSett ings, | 
| 645 dstCopy.texture() ? &dstCopy : NULL); | 624 &devBounds); | 
| 646 } | 625 } | 
| 647 | 626 | 
| 648 void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder, | 627 void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder, | 
| 649 const GrPathProcessor* pathProc, | 628 const GrPathProcessor* pathProc, | 
| 650 const GrPathRange* pathRange, | 629 const GrPathRange* pathRange, | 
| 651 const void* indices, | 630 const void* indices, | 
| 652 PathIndexType indexType, | 631 PathIndexType indexType, | 
| 653 const float transformValues[], | 632 const float transformValues[], | 
| 654 PathTransformType transformType, | 633 PathTransformType transformType, | 
| 655 int count, | 634 int count, | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 672 | 651 | 
| 673 // set stencil settings for path | 652 // set stencil settings for path | 
| 674 GrStencilSettings stencilSettings; | 653 GrStencilSettings stencilSettings; | 
| 675 this->getPathStencilSettingsForFilltype(fill, | 654 this->getPathStencilSettingsForFilltype(fill, | 
| 676 pipelineBuilder->getRenderTarget()-> getStencilBuffer(), | 655 pipelineBuilder->getRenderTarget()-> getStencilBuffer(), | 
| 677 &stencilSettings); | 656 &stencilSettings); | 
| 678 | 657 | 
| 679 // Don't compute a bounding box for setupDstReadIfNecessary(), we'll opt | 658 // Don't compute a bounding box for setupDstReadIfNecessary(), we'll opt | 
| 680 // instead for it to just copy the entire dst. Realistically this is a moot | 659 // instead for it to just copy the entire dst. Realistically this is a moot | 
| 681 // point, because any context that supports NV_path_rendering will also | 660 // point, because any context that supports NV_path_rendering will also | 
| 682 // support NV_blend_equation_advanced. | 661 // support NV_blend_equation_advanced. | 
| 
joshualitt
2015/02/02 15:42:25
Comment no longer applies
 
egdaniel
2015/02/03 16:47:44
Done.
 | |
| 683 GrDeviceCoordTexture dstCopy; | |
| 684 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, NULL)) { | |
| 685 return; | |
| 686 } | |
| 687 | |
| 688 this->onDrawPaths(*pipelineBuilder, pathProc, pathRange, indices, indexType, transformValues, | 662 this->onDrawPaths(*pipelineBuilder, pathProc, pathRange, indices, indexType, transformValues, | 
| 689 transformType, count, scissorState, stencilSettings, | 663 transformType, count, scissorState, stencilSettings, NULL) ; | 
| 690 dstCopy.texture() ? &dstCopy : NULL); | |
| 691 } | 664 } | 
| 692 | 665 | 
| 693 void GrDrawTarget::clear(const SkIRect* rect, | 666 void GrDrawTarget::clear(const SkIRect* rect, | 
| 694 GrColor color, | 667 GrColor color, | 
| 695 bool canIgnoreRect, | 668 bool canIgnoreRect, | 
| 696 GrRenderTarget* renderTarget) { | 669 GrRenderTarget* renderTarget) { | 
| 697 if (fCaps->useDrawInsteadOfClear()) { | 670 if (fCaps->useDrawInsteadOfClear()) { | 
| 698 // This works around a driver bug with clear by drawing a rect instead. | 671 // This works around a driver bug with clear by drawing a rect instead. | 
| 699 // The driver will ignore a clear if it is the only thing rendered to a | 672 // The driver will ignore a clear if it is the only thing rendered to a | 
| 700 // target before the target is read. | 673 // target before the target is read. | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 info.fStartIndex = 0; | 759 info.fStartIndex = 0; | 
| 787 info.fStartVertex = 0; | 760 info.fStartVertex = 0; | 
| 788 info.fIndicesPerInstance = indicesPerInstance; | 761 info.fIndicesPerInstance = indicesPerInstance; | 
| 789 info.fVerticesPerInstance = verticesPerInstance; | 762 info.fVerticesPerInstance = verticesPerInstance; | 
| 790 | 763 | 
| 791 // Set the same bounds for all the draws. | 764 // Set the same bounds for all the draws. | 
| 792 if (devBounds) { | 765 if (devBounds) { | 
| 793 info.setDevBounds(*devBounds); | 766 info.setDevBounds(*devBounds); | 
| 794 } | 767 } | 
| 795 | 768 | 
| 796 // TODO: We should continue with incorrect blending. | |
| 797 GrDeviceCoordTexture dstCopy; | |
| 798 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) { | |
| 799 return; | |
| 800 } | |
| 801 | |
| 802 while (instanceCount) { | 769 while (instanceCount) { | 
| 803 info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); | 770 info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); | 
| 804 info.fVertexCount = info.fInstanceCount * verticesPerInstance; | 771 info.fVertexCount = info.fInstanceCount * verticesPerInstance; | 
| 805 info.fIndexCount = info.fInstanceCount * indicesPerInstance; | 772 info.fIndexCount = info.fInstanceCount * indicesPerInstance; | 
| 806 | 773 | 
| 807 if (this->checkDraw(*pipelineBuilder, | 774 if (this->checkDraw(*pipelineBuilder, | 
| 808 gp, | 775 gp, | 
| 809 type, | 776 type, | 
| 810 info.fStartVertex, | 777 info.fStartVertex, | 
| 811 info.fStartIndex, | 778 info.fStartIndex, | 
| 812 info.fVertexCount, | 779 info.fVertexCount, | 
| 813 info.fIndexCount)) { | 780 info.fIndexCount)) { | 
| 814 this->setDrawBuffers(&info, gp->getVertexStride()); | 781 this->setDrawBuffers(&info, gp->getVertexStride()); | 
| 815 this->onDraw(*pipelineBuilder, gp, info, scissorState, | 782 this->onDraw(*pipelineBuilder, gp, info, scissorState); | 
| 816 dstCopy.texture() ? &dstCopy : NULL); | |
| 817 } | 783 } | 
| 818 info.fStartVertex += info.fVertexCount; | 784 info.fStartVertex += info.fVertexCount; | 
| 819 instanceCount -= info.fInstanceCount; | 785 instanceCount -= info.fInstanceCount; | 
| 820 } | 786 } | 
| 821 } | 787 } | 
| 822 | 788 | 
| 823 //////////////////////////////////////////////////////////////////////////////// | 789 //////////////////////////////////////////////////////////////////////////////// | 
| 824 | 790 | 
| 825 GrDrawTarget::AutoReleaseGeometry::AutoReleaseGeometry( | 791 GrDrawTarget::AutoReleaseGeometry::AutoReleaseGeometry( | 
| 826 GrDrawTarget* target, | 792 GrDrawTarget* target, | 
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1244 GrPipelineBuilder::AutoRestoreStencil* ars, | 1210 GrPipelineBuilder::AutoRestoreStencil* ars, | 
| 1245 GrScissorState* scissorState, | 1211 GrScissorState* scissorState, | 
| 1246 const SkRect* devBounds) { | 1212 const SkRect* devBounds) { | 
| 1247 return fClipMaskManager.setupClipping(pipelineBuilder, | 1213 return fClipMaskManager.setupClipping(pipelineBuilder, | 
| 1248 are, | 1214 are, | 
| 1249 ars, | 1215 ars, | 
| 1250 scissorState, | 1216 scissorState, | 
| 1251 this->getClip(), | 1217 this->getClip(), | 
| 1252 devBounds); | 1218 devBounds); | 
| 1253 } | 1219 } | 
| OLD | NEW |