Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: src/gpu/GrDrawTarget.cpp

Issue 912413002: Pass in ProcOptInfos into willNeedDstCopy on XPs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Review cleanup Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "GrBatch.h" 11 #include "GrBatch.h"
12 #include "GrContext.h" 12 #include "GrContext.h"
13 #include "GrDrawTargetCaps.h" 13 #include "GrDrawTargetCaps.h"
14 #include "GrPath.h" 14 #include "GrPath.h"
15 #include "GrPipeline.h"
15 #include "GrRenderTarget.h" 16 #include "GrRenderTarget.h"
16 #include "GrSurfacePriv.h" 17 #include "GrSurfacePriv.h"
17 #include "GrTemplates.h" 18 #include "GrTemplates.h"
18 #include "GrTexture.h" 19 #include "GrTexture.h"
19 #include "GrVertexBuffer.h" 20 #include "GrVertexBuffer.h"
20 21
21 #include "SkStrokeRec.h" 22 #include "SkStrokeRec.h"
22 23
23 //////////////////////////////////////////////////////////////////////////////// 24 ////////////////////////////////////////////////////////////////////////////////
24 25
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 379 }
379 380
380 #endif 381 #endif
381 if (NULL == pipelineBuilder.getRenderTarget()) { 382 if (NULL == pipelineBuilder.getRenderTarget()) {
382 return false; 383 return false;
383 } 384 }
384 return true; 385 return true;
385 } 386 }
386 387
387 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil der, 388 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil der,
389 const GrProcOptInfo& colorPOI,
390 const GrProcOptInfo& coveragePOI,
388 GrDeviceCoordTexture* dstCopy, 391 GrDeviceCoordTexture* dstCopy,
389 const SkRect* drawBounds) { 392 const SkRect* drawBounds) {
390 if (!pipelineBuilder.willXPNeedDstCopy(*this->caps())) { 393 if (!pipelineBuilder.willXPNeedDstCopy(*this->caps(), colorPOI, coveragePOI) ) {
391 return true; 394 return true;
392 } 395 }
393 SkIRect copyRect; 396 SkIRect copyRect;
394 const GrClipData* clip = this->getClip(); 397 const GrClipData* clip = this->getClip();
395 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); 398 GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
396 clip->getConservativeBounds(rt, &copyRect); 399 clip->getConservativeBounds(rt, &copyRect);
397 400
398 if (drawBounds) { 401 if (drawBounds) {
399 SkIRect drawIBounds; 402 SkIRect drawIBounds;
400 drawBounds->roundOut(&drawIBounds); 403 drawBounds->roundOut(&drawIBounds);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 info.fIndexCount = indexCount; 466 info.fIndexCount = indexCount;
464 467
465 info.fInstanceCount = 0; 468 info.fInstanceCount = 0;
466 info.fVerticesPerInstance = 0; 469 info.fVerticesPerInstance = 0;
467 info.fIndicesPerInstance = 0; 470 info.fIndicesPerInstance = 0;
468 471
469 if (devBounds) { 472 if (devBounds) {
470 info.setDevBounds(*devBounds); 473 info.setDevBounds(*devBounds);
471 } 474 }
472 475
476 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, gp, devBounds,
477 this);
478 if (pipelineInfo.mustSkipDraw()) {
479 return;
480 }
481
473 this->setDrawBuffers(&info, gp->getVertexStride()); 482 this->setDrawBuffers(&info, gp->getVertexStride());
474 483
475 this->onDraw(*pipelineBuilder, gp, info, scissorState); 484 this->onDraw(gp, info, pipelineInfo);
476 } 485 }
477 } 486 }
478 487
479 void GrDrawTarget::drawNonIndexed(GrPipelineBuilder* pipelineBuilder, 488 void GrDrawTarget::drawNonIndexed(GrPipelineBuilder* pipelineBuilder,
480 const GrGeometryProcessor* gp, 489 const GrGeometryProcessor* gp,
481 GrPrimitiveType type, 490 GrPrimitiveType type,
482 int startVertex, 491 int startVertex,
483 int vertexCount, 492 int vertexCount,
484 const SkRect* devBounds) { 493 const SkRect* devBounds) {
485 SkASSERT(pipelineBuilder); 494 SkASSERT(pipelineBuilder);
(...skipping 16 matching lines...) Expand all
502 info.fIndexCount = 0; 511 info.fIndexCount = 0;
503 512
504 info.fInstanceCount = 0; 513 info.fInstanceCount = 0;
505 info.fVerticesPerInstance = 0; 514 info.fVerticesPerInstance = 0;
506 info.fIndicesPerInstance = 0; 515 info.fIndicesPerInstance = 0;
507 516
508 if (devBounds) { 517 if (devBounds) {
509 info.setDevBounds(*devBounds); 518 info.setDevBounds(*devBounds);
510 } 519 }
511 520
521 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, gp, devBounds,
522 this);
523 if (pipelineInfo.mustSkipDraw()) {
524 return;
525 }
526
512 this->setDrawBuffers(&info, gp->getVertexStride()); 527 this->setDrawBuffers(&info, gp->getVertexStride());
513 528
514 this->onDraw(*pipelineBuilder, gp, info, scissorState); 529 this->onDraw(gp, info, pipelineInfo);
515 } 530 }
516 } 531 }
517 532
518 533
519 void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder, 534 void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder,
520 GrBatch* batch, 535 GrBatch* batch,
521 const SkRect* devBounds) { 536 const SkRect* devBounds) {
522 SkASSERT(pipelineBuilder); 537 SkASSERT(pipelineBuilder);
523 // TODO some kind of checkdraw, but not at this level 538 // TODO some kind of checkdraw, but not at this level
524 539
525 // Setup clip 540 // Setup clip
526 GrScissorState scissorState; 541 GrScissorState scissorState;
527 GrPipelineBuilder::AutoRestoreEffects are; 542 GrPipelineBuilder::AutoRestoreEffects are;
528 GrPipelineBuilder::AutoRestoreStencil ars; 543 GrPipelineBuilder::AutoRestoreStencil ars;
529 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBounds)) { 544 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, devBounds)) {
530 return; 545 return;
531 } 546 }
532 547
533 this->onDrawBatch(batch, *pipelineBuilder, scissorState, devBounds); 548 // init batch and my other crap
549 GrBatchOpt batchOpt;
550 batchOpt.fCanTweakAlphaForCoverage = pipelineBuilder->canTweakAlphaForCovera ge();
551 batch->initBatchOpt(batchOpt);
552
553 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batc h, devBounds, this);
554 if (pipelineInfo.mustSkipDraw()) {
555 return;
556 }
557
558 this->onDrawBatch(batch, pipelineInfo);
534 } 559 }
535 560
536 static const GrStencilSettings& winding_path_stencil_settings() { 561 static const GrStencilSettings& winding_path_stencil_settings() {
537 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, 562 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
538 kIncClamp_StencilOp, 563 kIncClamp_StencilOp,
539 kIncClamp_StencilOp, 564 kIncClamp_StencilOp,
540 kAlwaysIfInClip_StencilFunc, 565 kAlwaysIfInClip_StencilFunc,
541 0xFFFF, 0xFFFF, 0xFFFF); 566 0xFFFF, 0xFFFF, 0xFFFF);
542 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); 567 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
543 } 568 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, &devBounds) ) { 638 if (!this->setupClip(pipelineBuilder, &are, &ars, &scissorState, &devBounds) ) {
614 return; 639 return;
615 } 640 }
616 641
617 // set stencil settings for path 642 // set stencil settings for path
618 GrStencilSettings stencilSettings; 643 GrStencilSettings stencilSettings;
619 this->getPathStencilSettingsForFilltype(fill, 644 this->getPathStencilSettingsForFilltype(fill,
620 pipelineBuilder->getRenderTarget()-> getStencilBuffer(), 645 pipelineBuilder->getRenderTarget()-> getStencilBuffer(),
621 &stencilSettings); 646 &stencilSettings);
622 647
623 this->onDrawPath(*pipelineBuilder, pathProc, path, scissorState, stencilSett ings, 648 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path Proc, &devBounds,
624 &devBounds); 649 this);
650 if (pipelineInfo.mustSkipDraw()) {
651 return;
652 }
653
654 this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo);
625 } 655 }
626 656
627 void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder, 657 void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder,
628 const GrPathProcessor* pathProc, 658 const GrPathProcessor* pathProc,
629 const GrPathRange* pathRange, 659 const GrPathRange* pathRange,
630 const void* indices, 660 const void* indices,
631 PathIndexType indexType, 661 PathIndexType indexType,
632 const float transformValues[], 662 const float transformValues[],
633 PathTransformType transformType, 663 PathTransformType transformType,
634 int count, 664 int count,
(...skipping 17 matching lines...) Expand all
652 // set stencil settings for path 682 // set stencil settings for path
653 GrStencilSettings stencilSettings; 683 GrStencilSettings stencilSettings;
654 this->getPathStencilSettingsForFilltype(fill, 684 this->getPathStencilSettingsForFilltype(fill,
655 pipelineBuilder->getRenderTarget()-> getStencilBuffer(), 685 pipelineBuilder->getRenderTarget()-> getStencilBuffer(),
656 &stencilSettings); 686 &stencilSettings);
657 687
658 // Don't compute a bounding box for dst copy texture, we'll opt 688 // Don't compute a bounding box for dst copy texture, we'll opt
659 // instead for it to just copy the entire dst. Realistically this is a moot 689 // instead for it to just copy the entire dst. Realistically this is a moot
660 // point, because any context that supports NV_path_rendering will also 690 // point, because any context that supports NV_path_rendering will also
661 // support NV_blend_equation_advanced. 691 // support NV_blend_equation_advanced.
662 this->onDrawPaths(*pipelineBuilder, pathProc, pathRange, indices, indexType, transformValues, 692 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, path Proc, NULL, this);
663 transformType, count, scissorState, stencilSettings, NULL) ; 693 if (pipelineInfo.mustSkipDraw()) {
694 return;
695 }
696
697 this->onDrawPaths(pathProc, pathRange, indices, indexType, transformValues,
698 transformType, count, stencilSettings, pipelineInfo);
664 } 699 }
665 700
666 void GrDrawTarget::clear(const SkIRect* rect, 701 void GrDrawTarget::clear(const SkIRect* rect,
667 GrColor color, 702 GrColor color,
668 bool canIgnoreRect, 703 bool canIgnoreRect,
669 GrRenderTarget* renderTarget) { 704 GrRenderTarget* renderTarget) {
670 if (fCaps->useDrawInsteadOfClear()) { 705 if (fCaps->useDrawInsteadOfClear()) {
671 // This works around a driver bug with clear by drawing a rect instead. 706 // This works around a driver bug with clear by drawing a rect instead.
672 // The driver will ignore a clear if it is the only thing rendered to a 707 // The driver will ignore a clear if it is the only thing rendered to a
673 // target before the target is read. 708 // target before the target is read.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 info.fVertexCount = info.fInstanceCount * verticesPerInstance; 806 info.fVertexCount = info.fInstanceCount * verticesPerInstance;
772 info.fIndexCount = info.fInstanceCount * indicesPerInstance; 807 info.fIndexCount = info.fInstanceCount * indicesPerInstance;
773 808
774 if (this->checkDraw(*pipelineBuilder, 809 if (this->checkDraw(*pipelineBuilder,
775 gp, 810 gp,
776 type, 811 type,
777 info.fStartVertex, 812 info.fStartVertex,
778 info.fStartIndex, 813 info.fStartIndex,
779 info.fVertexCount, 814 info.fVertexCount,
780 info.fIndexCount)) { 815 info.fIndexCount)) {
816
817 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorSta te, gp, devBounds,
818 this);
819 if (pipelineInfo.mustSkipDraw()) {
820 return;
821 }
822
781 this->setDrawBuffers(&info, gp->getVertexStride()); 823 this->setDrawBuffers(&info, gp->getVertexStride());
782 this->onDraw(*pipelineBuilder, gp, info, scissorState); 824 this->onDraw(gp, info, pipelineInfo);
783 } 825 }
784 info.fStartVertex += info.fVertexCount; 826 info.fStartVertex += info.fVertexCount;
785 instanceCount -= info.fInstanceCount; 827 instanceCount -= info.fInstanceCount;
786 } 828 }
787 } 829 }
788 830
789 //////////////////////////////////////////////////////////////////////////////// 831 ////////////////////////////////////////////////////////////////////////////////
790 832
791 GrDrawTarget::AutoReleaseGeometry::AutoReleaseGeometry( 833 GrDrawTarget::AutoReleaseGeometry::AutoReleaseGeometry(
792 GrDrawTarget* target, 834 GrDrawTarget* target,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRec t)); 1020 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(clippedSrcRec t));
979 SkASSERT(clippedDstPoint.fX >= 0 && clippedDstPoint.fY >= 0); 1021 SkASSERT(clippedDstPoint.fX >= 0 && clippedDstPoint.fY >= 0);
980 SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() && 1022 SkASSERT(clippedDstPoint.fX + clippedSrcRect.width() <= dst->width() &&
981 clippedDstPoint.fY + clippedSrcRect.height() <= dst->height()); 1023 clippedDstPoint.fY + clippedSrcRect.height() <= dst->height());
982 1024
983 // The base class can do it as a draw or the subclass may be able to handle it. 1025 // The base class can do it as a draw or the subclass may be able to handle it.
984 return ((dst != src) && dst->asRenderTarget() && src->asTexture()) || 1026 return ((dst != src) && dst->asRenderTarget() && src->asTexture()) ||
985 this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint); 1027 this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
986 } 1028 }
987 1029
1030 void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo,
1031 GrPipeline* pipeline) {
1032 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder,
1033 pipelineInfo.fColorPOI,
1034 pipelineInfo.fCoveragePOI,
1035 *this->caps(),
1036 *pipelineInfo.fScissor,
1037 &pipelineInfo.fDstCopy));
1038 }
1039 ///////////////////////////////////////////////////////////////////////////////
1040
1041 GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder,
1042 GrScissorState* scissor,
1043 const GrPrimitiveProcessor* primProc,
1044 const SkRect* devBounds,
1045 GrDrawTarget* target)
1046 : fPipelineBuilder(pipelineBuilder)
1047 , fScissor(scissor) {
1048 fColorPOI = fPipelineBuilder->colorProcInfo(primProc);
1049 fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc);
1050 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI,
1051 &fDstCopy, devBounds)) {
1052 fPipelineBuilder = NULL;
1053 }
1054 }
1055
1056 GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder,
1057 GrScissorState* scissor,
1058 const GrBatch* batch,
1059 const SkRect* devBounds,
1060 GrDrawTarget* target)
1061 : fPipelineBuilder(pipelineBuilder)
1062 , fScissor(scissor) {
1063 fColorPOI = fPipelineBuilder->colorProcInfo(batch);
1064 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch);
1065 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage POI,
1066 &fDstCopy, devBounds)) {
1067 fPipelineBuilder = NULL;
1068 }
1069 }
1070
988 /////////////////////////////////////////////////////////////////////////////// 1071 ///////////////////////////////////////////////////////////////////////////////
989 1072
990 void GrDrawTargetCaps::reset() { 1073 void GrDrawTargetCaps::reset() {
991 fMipMapSupport = false; 1074 fMipMapSupport = false;
992 fNPOTTextureTileSupport = false; 1075 fNPOTTextureTileSupport = false;
993 fTwoSidedStencilSupport = false; 1076 fTwoSidedStencilSupport = false;
994 fStencilWrapOpsSupport = false; 1077 fStencilWrapOpsSupport = false;
995 fHWAALineSupport = false; 1078 fHWAALineSupport = false;
996 fShaderDerivativeSupport = false; 1079 fShaderDerivativeSupport = false;
997 fGeometryShaderSupport = false; 1080 fGeometryShaderSupport = false;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 GrPipelineBuilder::AutoRestoreStencil* ars, 1293 GrPipelineBuilder::AutoRestoreStencil* ars,
1211 GrScissorState* scissorState, 1294 GrScissorState* scissorState,
1212 const SkRect* devBounds) { 1295 const SkRect* devBounds) {
1213 return fClipMaskManager.setupClipping(pipelineBuilder, 1296 return fClipMaskManager.setupClipping(pipelineBuilder,
1214 are, 1297 are,
1215 ars, 1298 ars,
1216 scissorState, 1299 scissorState,
1217 this->getClip(), 1300 this->getClip(),
1218 devBounds); 1301 devBounds);
1219 } 1302 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698