| 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 | 9 | 
| 10 | 10 | 
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 300 | 300 | 
| 301     this->geometrySourceWillPop(fGeoSrcStateStack.fromBack(1)); | 301     this->geometrySourceWillPop(fGeoSrcStateStack.fromBack(1)); | 
| 302     this->releasePreviousVertexSource(); | 302     this->releasePreviousVertexSource(); | 
| 303     this->releasePreviousIndexSource(); | 303     this->releasePreviousIndexSource(); | 
| 304     fGeoSrcStateStack.pop_back(); | 304     fGeoSrcStateStack.pop_back(); | 
| 305 } | 305 } | 
| 306 | 306 | 
| 307 //////////////////////////////////////////////////////////////////////////////// | 307 //////////////////////////////////////////////////////////////////////////////// | 
| 308 | 308 | 
| 309 bool GrDrawTarget::checkDraw(const GrDrawState& drawState, | 309 bool GrDrawTarget::checkDraw(const GrDrawState& drawState, | 
|  | 310                              const GrGeometryProcessor* gp, | 
| 310                              GrPrimitiveType type, | 311                              GrPrimitiveType type, | 
| 311                              int startVertex, | 312                              int startVertex, | 
| 312                              int startIndex, | 313                              int startIndex, | 
| 313                              int vertexCount, | 314                              int vertexCount, | 
| 314                              int indexCount) const { | 315                              int indexCount) const { | 
| 315 #ifdef SK_DEBUG | 316 #ifdef SK_DEBUG | 
| 316     const GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); | 317     const GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); | 
| 317     int maxVertex = startVertex + vertexCount; | 318     int maxVertex = startVertex + vertexCount; | 
| 318     int maxValidVertex; | 319     int maxValidVertex; | 
| 319     switch (geoSrc.fVertexSrc) { | 320     switch (geoSrc.fVertexSrc) { | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 342                 maxValidIndex = static_cast<int>(geoSrc.fIndexBuffer->gpuMemoryS
      ize() / sizeof(uint16_t)); | 343                 maxValidIndex = static_cast<int>(geoSrc.fIndexBuffer->gpuMemoryS
      ize() / sizeof(uint16_t)); | 
| 343                 break; | 344                 break; | 
| 344         } | 345         } | 
| 345         if (maxIndex > maxValidIndex) { | 346         if (maxIndex > maxValidIndex) { | 
| 346             SkFAIL("Index reads outside valid index range."); | 347             SkFAIL("Index reads outside valid index range."); | 
| 347         } | 348         } | 
| 348     } | 349     } | 
| 349 | 350 | 
| 350     SkASSERT(drawState.getRenderTarget()); | 351     SkASSERT(drawState.getRenderTarget()); | 
| 351 | 352 | 
| 352     if (drawState.hasGeometryProcessor()) { | 353     if (gp) { | 
| 353         const GrGeometryProcessor* gp = drawState.getGeometryProcessor(); |  | 
| 354         int numTextures = gp->numTextures(); | 354         int numTextures = gp->numTextures(); | 
| 355         for (int t = 0; t < numTextures; ++t) { | 355         for (int t = 0; t < numTextures; ++t) { | 
| 356             GrTexture* texture = gp->texture(t); | 356             GrTexture* texture = gp->texture(t); | 
| 357             SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget()); | 357             SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget()); | 
| 358         } | 358         } | 
| 359     } | 359     } | 
| 360 | 360 | 
| 361     for (int s = 0; s < drawState.numColorStages(); ++s) { | 361     for (int s = 0; s < drawState.numColorStages(); ++s) { | 
| 362         const GrProcessor* effect = drawState.getColorStage(s).getProcessor(); | 362         const GrProcessor* effect = drawState.getColorStage(s).getProcessor(); | 
| 363         int numTextures = effect->numTextures(); | 363         int numTextures = effect->numTextures(); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 376     } | 376     } | 
| 377 | 377 | 
| 378 #endif | 378 #endif | 
| 379     if (NULL == drawState.getRenderTarget()) { | 379     if (NULL == drawState.getRenderTarget()) { | 
| 380         return false; | 380         return false; | 
| 381     } | 381     } | 
| 382     return true; | 382     return true; | 
| 383 } | 383 } | 
| 384 | 384 | 
| 385 bool GrDrawTarget::setupDstReadIfNecessary(GrDrawState* ds, | 385 bool GrDrawTarget::setupDstReadIfNecessary(GrDrawState* ds, | 
| 386                                            GrColor color, | 386                                            const GrPrimitiveProcessor* pp, | 
| 387                                            uint8_t coverage, |  | 
| 388                                            GrDeviceCoordTexture* dstCopy, | 387                                            GrDeviceCoordTexture* dstCopy, | 
| 389                                            const SkRect* drawBounds) { | 388                                            const SkRect* drawBounds) { | 
| 390     GrColor c = GrColorPackRGBA(coverage, coverage, coverage, coverage); | 389     if (this->caps()->dstReadInShaderSupport() || !ds->willEffectReadDstColor(pp
      )) { | 
| 391     if (this->caps()->dstReadInShaderSupport() || !ds->willEffectReadDstColor(co
      lor, c)) { |  | 
| 392         return true; | 390         return true; | 
| 393     } | 391     } | 
| 394     SkIRect copyRect; | 392     SkIRect copyRect; | 
| 395     const GrClipData* clip = this->getClip(); | 393     const GrClipData* clip = this->getClip(); | 
| 396     GrRenderTarget* rt = ds->getRenderTarget(); | 394     GrRenderTarget* rt = ds->getRenderTarget(); | 
| 397     clip->getConservativeBounds(rt, ©Rect); | 395     clip->getConservativeBounds(rt, ©Rect); | 
| 398 | 396 | 
| 399     if (drawBounds) { | 397     if (drawBounds) { | 
| 400         SkIRect drawIBounds; | 398         SkIRect drawIBounds; | 
| 401         drawBounds->roundOut(&drawIBounds); | 399         drawBounds->roundOut(&drawIBounds); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 429     if (this->copySurface(copy, rt, copyRect, dstPoint)) { | 427     if (this->copySurface(copy, rt, copyRect, dstPoint)) { | 
| 430         dstCopy->setTexture(copy); | 428         dstCopy->setTexture(copy); | 
| 431         dstCopy->setOffset(copyRect.fLeft, copyRect.fTop); | 429         dstCopy->setOffset(copyRect.fLeft, copyRect.fTop); | 
| 432         return true; | 430         return true; | 
| 433     } else { | 431     } else { | 
| 434         return false; | 432         return false; | 
| 435     } | 433     } | 
| 436 } | 434 } | 
| 437 | 435 | 
| 438 void GrDrawTarget::drawIndexed(GrDrawState* ds, | 436 void GrDrawTarget::drawIndexed(GrDrawState* ds, | 
|  | 437                                const GrGeometryProcessor* gp, | 
| 439                                GrPrimitiveType type, | 438                                GrPrimitiveType type, | 
| 440                                int startVertex, | 439                                int startVertex, | 
| 441                                int startIndex, | 440                                int startIndex, | 
| 442                                int vertexCount, | 441                                int vertexCount, | 
| 443                                int indexCount, | 442                                int indexCount, | 
| 444                                const SkRect* devBounds) { | 443                                const SkRect* devBounds) { | 
| 445     SkASSERT(ds); | 444     SkASSERT(ds); | 
| 446     if (indexCount > 0 && | 445     if (indexCount > 0 && | 
| 447         this->checkDraw(*ds, type, startVertex, startIndex, vertexCount, indexCo
      unt)) { | 446         this->checkDraw(*ds, gp, type, startVertex, startIndex, vertexCount, ind
      exCount)) { | 
| 448 | 447 | 
| 449         // Setup clip | 448         // Setup clip | 
| 450         GrClipMaskManager::ScissorState scissorState; | 449         GrClipMaskManager::ScissorState scissorState; | 
| 451         GrDrawState::AutoRestoreEffects are; | 450         GrDrawState::AutoRestoreEffects are; | 
| 452         GrDrawState::AutoRestoreStencil ars; | 451         GrDrawState::AutoRestoreStencil ars; | 
| 453         if (!this->setupClip(devBounds, &are, &ars, ds, &scissorState)) { | 452         if (!this->setupClip(devBounds, &are, &ars, ds, &scissorState)) { | 
| 454             return; | 453             return; | 
| 455         } | 454         } | 
| 456 | 455 | 
| 457         DrawInfo info; | 456         DrawInfo info; | 
| 458         info.fPrimitiveType = type; | 457         info.fPrimitiveType = type; | 
| 459         info.fStartVertex   = startVertex; | 458         info.fStartVertex   = startVertex; | 
| 460         info.fStartIndex    = startIndex; | 459         info.fStartIndex    = startIndex; | 
| 461         info.fVertexCount   = vertexCount; | 460         info.fVertexCount   = vertexCount; | 
| 462         info.fIndexCount    = indexCount; | 461         info.fIndexCount    = indexCount; | 
| 463 | 462 | 
| 464         info.fInstanceCount         = 0; | 463         info.fInstanceCount         = 0; | 
| 465         info.fVerticesPerInstance   = 0; | 464         info.fVerticesPerInstance   = 0; | 
| 466         info.fIndicesPerInstance    = 0; | 465         info.fIndicesPerInstance    = 0; | 
| 467 | 466 | 
| 468         if (devBounds) { | 467         if (devBounds) { | 
| 469             info.setDevBounds(*devBounds); | 468             info.setDevBounds(*devBounds); | 
| 470         } | 469         } | 
| 471 | 470 | 
| 472         // TODO: We should continue with incorrect blending. | 471         // TODO: We should continue with incorrect blending. | 
| 473         GrDeviceCoordTexture dstCopy; | 472         GrDeviceCoordTexture dstCopy; | 
| 474         const GrGeometryProcessor* gp = ds->getGeometryProcessor(); | 473         if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy, devBounds)) { | 
| 475         if (!this->setupDstReadIfNecessary(ds, gp->getColor(), gp->getCoverage()
      , &dstCopy, |  | 
| 476                                            devBounds)) { |  | 
| 477             return; | 474             return; | 
| 478         } | 475         } | 
| 479         this->setDrawBuffers(&info, gp->getVertexStride()); | 476         this->setDrawBuffers(&info, gp->getVertexStride()); | 
| 480 | 477 | 
| 481         this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NUL
      L); | 478         this->onDraw(*ds, gp, info, scissorState, dstCopy.texture() ? &dstCopy :
       NULL); | 
| 482     } | 479     } | 
| 483 } | 480 } | 
| 484 | 481 | 
| 485 void GrDrawTarget::drawNonIndexed(GrDrawState* ds, | 482 void GrDrawTarget::drawNonIndexed(GrDrawState* ds, | 
|  | 483                                   const GrGeometryProcessor* gp, | 
| 486                                   GrPrimitiveType type, | 484                                   GrPrimitiveType type, | 
| 487                                   int startVertex, | 485                                   int startVertex, | 
| 488                                   int vertexCount, | 486                                   int vertexCount, | 
| 489                                   const SkRect* devBounds) { | 487                                   const SkRect* devBounds) { | 
| 490     SkASSERT(ds); | 488     SkASSERT(ds); | 
| 491     if (vertexCount > 0 && this->checkDraw(*ds, type, startVertex, -1, vertexCou
      nt, -1)) { | 489     if (vertexCount > 0 && this->checkDraw(*ds, gp, type, startVertex, -1, verte
      xCount, -1)) { | 
| 492 | 490 | 
| 493         // Setup clip | 491         // Setup clip | 
| 494         GrClipMaskManager::ScissorState scissorState; | 492         GrClipMaskManager::ScissorState scissorState; | 
| 495         GrDrawState::AutoRestoreEffects are; | 493         GrDrawState::AutoRestoreEffects are; | 
| 496         GrDrawState::AutoRestoreStencil ars; | 494         GrDrawState::AutoRestoreStencil ars; | 
| 497         if (!this->setupClip(devBounds, &are, &ars, ds, &scissorState)) { | 495         if (!this->setupClip(devBounds, &are, &ars, ds, &scissorState)) { | 
| 498             return; | 496             return; | 
| 499         } | 497         } | 
| 500 | 498 | 
| 501         DrawInfo info; | 499         DrawInfo info; | 
| 502         info.fPrimitiveType = type; | 500         info.fPrimitiveType = type; | 
| 503         info.fStartVertex   = startVertex; | 501         info.fStartVertex   = startVertex; | 
| 504         info.fStartIndex    = 0; | 502         info.fStartIndex    = 0; | 
| 505         info.fVertexCount   = vertexCount; | 503         info.fVertexCount   = vertexCount; | 
| 506         info.fIndexCount    = 0; | 504         info.fIndexCount    = 0; | 
| 507 | 505 | 
| 508         info.fInstanceCount         = 0; | 506         info.fInstanceCount         = 0; | 
| 509         info.fVerticesPerInstance   = 0; | 507         info.fVerticesPerInstance   = 0; | 
| 510         info.fIndicesPerInstance    = 0; | 508         info.fIndicesPerInstance    = 0; | 
| 511 | 509 | 
| 512         if (devBounds) { | 510         if (devBounds) { | 
| 513             info.setDevBounds(*devBounds); | 511             info.setDevBounds(*devBounds); | 
| 514         } | 512         } | 
| 515 | 513 | 
| 516         // TODO: We should continue with incorrect blending. | 514         // TODO: We should continue with incorrect blending. | 
| 517         GrDeviceCoordTexture dstCopy; | 515         GrDeviceCoordTexture dstCopy; | 
| 518         const GrGeometryProcessor* gp = ds->getGeometryProcessor(); | 516         if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy, devBounds)) { | 
| 519         if (!this->setupDstReadIfNecessary(ds, gp->getColor(), gp->getCoverage()
      , &dstCopy, |  | 
| 520                                            devBounds)) { |  | 
| 521             return; | 517             return; | 
| 522         } | 518         } | 
| 523 | 519 | 
| 524         this->setDrawBuffers(&info, gp->getVertexStride()); | 520         this->setDrawBuffers(&info, gp->getVertexStride()); | 
| 525 | 521 | 
| 526         this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NUL
      L); | 522         this->onDraw(*ds, gp, info, scissorState, dstCopy.texture() ? &dstCopy :
       NULL); | 
| 527     } | 523     } | 
| 528 } | 524 } | 
| 529 | 525 | 
| 530 static const GrStencilSettings& winding_path_stencil_settings() { | 526 static const GrStencilSettings& winding_path_stencil_settings() { | 
| 531     GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | 527     GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | 
| 532         kIncClamp_StencilOp, | 528         kIncClamp_StencilOp, | 
| 533         kIncClamp_StencilOp, | 529         kIncClamp_StencilOp, | 
| 534         kAlwaysIfInClip_StencilFunc, | 530         kAlwaysIfInClip_StencilFunc, | 
| 535         0xFFFF, 0xFFFF, 0xFFFF); | 531         0xFFFF, 0xFFFF, 0xFFFF); | 
| 536     return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | 532     return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 556             *outStencilSettings = winding_path_stencil_settings(); | 552             *outStencilSettings = winding_path_stencil_settings(); | 
| 557             break; | 553             break; | 
| 558         case GrPathRendering::kEvenOdd_FillType: | 554         case GrPathRendering::kEvenOdd_FillType: | 
| 559             *outStencilSettings = even_odd_path_stencil_settings(); | 555             *outStencilSettings = even_odd_path_stencil_settings(); | 
| 560             break; | 556             break; | 
| 561     } | 557     } | 
| 562     this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings); | 558     this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings); | 
| 563 } | 559 } | 
| 564 | 560 | 
| 565 void GrDrawTarget::stencilPath(GrDrawState* ds, | 561 void GrDrawTarget::stencilPath(GrDrawState* ds, | 
|  | 562                                const GrPathProcessor* pp, | 
| 566                                const GrPath* path, | 563                                const GrPath* path, | 
| 567                                GrPathRendering::FillType fill) { | 564                                GrPathRendering::FillType fill) { | 
| 568     // TODO: extract portions of checkDraw that are relevant to path stenciling. | 565     // TODO: extract portions of checkDraw that are relevant to path stenciling. | 
| 569     SkASSERT(path); | 566     SkASSERT(path); | 
| 570     SkASSERT(this->caps()->pathRenderingSupport()); | 567     SkASSERT(this->caps()->pathRenderingSupport()); | 
| 571     SkASSERT(ds); | 568     SkASSERT(ds); | 
| 572 | 569 | 
| 573     // Setup clip | 570     // Setup clip | 
| 574     GrClipMaskManager::ScissorState scissorState; | 571     GrClipMaskManager::ScissorState scissorState; | 
| 575     GrDrawState::AutoRestoreEffects are; | 572     GrDrawState::AutoRestoreEffects are; | 
| 576     GrDrawState::AutoRestoreStencil ars; | 573     GrDrawState::AutoRestoreStencil ars; | 
| 577     if (!this->setupClip(NULL, &are, &ars, ds, &scissorState)) { | 574     if (!this->setupClip(NULL, &are, &ars, ds, &scissorState)) { | 
| 578         return; | 575         return; | 
| 579     } | 576     } | 
| 580 | 577 | 
| 581     // set stencil settings for path | 578     // set stencil settings for path | 
| 582     GrStencilSettings stencilSettings; | 579     GrStencilSettings stencilSettings; | 
| 583     this->getPathStencilSettingsForFilltype(fill, | 580     this->getPathStencilSettingsForFilltype(fill, | 
| 584                                             ds->getRenderTarget()->getStencilBuf
      fer(), | 581                                             ds->getRenderTarget()->getStencilBuf
      fer(), | 
| 585                                             &stencilSettings); | 582                                             &stencilSettings); | 
| 586 | 583 | 
| 587     this->onStencilPath(*ds, path, scissorState, stencilSettings); | 584     this->onStencilPath(*ds, pp, path, scissorState, stencilSettings); | 
| 588 } | 585 } | 
| 589 | 586 | 
| 590 void GrDrawTarget::drawPath(GrDrawState* ds, | 587 void GrDrawTarget::drawPath(GrDrawState* ds, | 
| 591                             GrColor color, | 588                             const GrPathProcessor* pp, | 
| 592                             const GrPath* path, | 589                             const GrPath* path, | 
| 593                             GrPathRendering::FillType fill) { | 590                             GrPathRendering::FillType fill) { | 
| 594     // TODO: extract portions of checkDraw that are relevant to path rendering. | 591     // TODO: extract portions of checkDraw that are relevant to path rendering. | 
| 595     SkASSERT(path); | 592     SkASSERT(path); | 
| 596     SkASSERT(this->caps()->pathRenderingSupport()); | 593     SkASSERT(this->caps()->pathRenderingSupport()); | 
| 597     SkASSERT(ds); | 594     SkASSERT(ds); | 
| 598 | 595 | 
| 599     SkRect devBounds = path->getBounds(); | 596     SkRect devBounds = path->getBounds(); | 
| 600     SkMatrix viewM = ds->getViewMatrix(); | 597     SkMatrix viewM = ds->getViewMatrix(); | 
| 601     viewM.mapRect(&devBounds); | 598     viewM.mapRect(&devBounds); | 
| 602 | 599 | 
| 603     // Setup clip | 600     // Setup clip | 
| 604     GrClipMaskManager::ScissorState scissorState; | 601     GrClipMaskManager::ScissorState scissorState; | 
| 605     GrDrawState::AutoRestoreEffects are; | 602     GrDrawState::AutoRestoreEffects are; | 
| 606     GrDrawState::AutoRestoreStencil ars; | 603     GrDrawState::AutoRestoreStencil ars; | 
| 607     if (!this->setupClip(&devBounds, &are, &ars, ds, &scissorState)) { | 604     if (!this->setupClip(&devBounds, &are, &ars, ds, &scissorState)) { | 
| 608        return; | 605        return; | 
| 609     } | 606     } | 
| 610 | 607 | 
| 611     // set stencil settings for path | 608     // set stencil settings for path | 
| 612     GrStencilSettings stencilSettings; | 609     GrStencilSettings stencilSettings; | 
| 613     this->getPathStencilSettingsForFilltype(fill, | 610     this->getPathStencilSettingsForFilltype(fill, | 
| 614                                             ds->getRenderTarget()->getStencilBuf
      fer(), | 611                                             ds->getRenderTarget()->getStencilBuf
      fer(), | 
| 615                                             &stencilSettings); | 612                                             &stencilSettings); | 
| 616 | 613 | 
| 617     GrDeviceCoordTexture dstCopy; | 614     GrDeviceCoordTexture dstCopy; | 
| 618     if (!this->setupDstReadIfNecessary(ds, color, 0xff, &dstCopy, &devBounds)) { | 615     if (!this->setupDstReadIfNecessary(ds, pp, &dstCopy, &devBounds)) { | 
| 619         return; | 616         return; | 
| 620     } | 617     } | 
| 621 | 618 | 
| 622     this->onDrawPath(*ds, color, path, scissorState, stencilSettings, dstCopy.te
      xture() ? &dstCopy : | 619     this->onDrawPath(*ds, pp, path, scissorState, stencilSettings, dstCopy.textu
      re() ? &dstCopy : | 
| 623                                                                                 
                NULL); | 620                                                                                 
             NULL); | 
| 624 } | 621 } | 
| 625 | 622 | 
| 626 void GrDrawTarget::drawPaths(GrDrawState* ds, | 623 void GrDrawTarget::drawPaths(GrDrawState* ds, | 
| 627                              GrColor color, | 624                              const GrPathProcessor* pp, | 
| 628                              const GrPathRange* pathRange, | 625                              const GrPathRange* pathRange, | 
| 629                              const void* indices, | 626                              const void* indices, | 
| 630                              PathIndexType indexType, | 627                              PathIndexType indexType, | 
| 631                              const float transformValues[], | 628                              const float transformValues[], | 
| 632                              PathTransformType transformType, | 629                              PathTransformType transformType, | 
| 633                              int count, | 630                              int count, | 
| 634                              GrPathRendering::FillType fill) { | 631                              GrPathRendering::FillType fill) { | 
| 635     SkASSERT(this->caps()->pathRenderingSupport()); | 632     SkASSERT(this->caps()->pathRenderingSupport()); | 
| 636     SkASSERT(pathRange); | 633     SkASSERT(pathRange); | 
| 637     SkASSERT(indices); | 634     SkASSERT(indices); | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 652     GrStencilSettings stencilSettings; | 649     GrStencilSettings stencilSettings; | 
| 653     this->getPathStencilSettingsForFilltype(fill, | 650     this->getPathStencilSettingsForFilltype(fill, | 
| 654                                             ds->getRenderTarget()->getStencilBuf
      fer(), | 651                                             ds->getRenderTarget()->getStencilBuf
      fer(), | 
| 655                                             &stencilSettings); | 652                                             &stencilSettings); | 
| 656 | 653 | 
| 657     // Don't compute a bounding box for setupDstReadIfNecessary(), we'll opt | 654     // Don't compute a bounding box for setupDstReadIfNecessary(), we'll opt | 
| 658     // instead for it to just copy the entire dst. Realistically this is a moot | 655     // instead for it to just copy the entire dst. Realistically this is a moot | 
| 659     // point, because any context that supports NV_path_rendering will also | 656     // point, because any context that supports NV_path_rendering will also | 
| 660     // support NV_blend_equation_advanced. | 657     // support NV_blend_equation_advanced. | 
| 661     GrDeviceCoordTexture dstCopy; | 658     GrDeviceCoordTexture dstCopy; | 
| 662     if (!this->setupDstReadIfNecessary(ds, color, 0xff, &dstCopy, NULL)) { | 659     if (!this->setupDstReadIfNecessary(ds, pp, &dstCopy, NULL)) { | 
| 663         return; | 660         return; | 
| 664     } | 661     } | 
| 665 | 662 | 
| 666     this->onDrawPaths(*ds, color, pathRange, indices, indexType, transformValues
      , transformType, | 663     this->onDrawPaths(*ds, pp, pathRange, indices, indexType, transformValues, t
      ransformType, | 
| 667                       count, scissorState, stencilSettings, dstCopy.texture() ? 
      &dstCopy : NULL); | 664                       count, scissorState, stencilSettings, dstCopy.texture() ? 
      &dstCopy : NULL); | 
| 668 } | 665 } | 
| 669 | 666 | 
| 670 void GrDrawTarget::clear(const SkIRect* rect, | 667 void GrDrawTarget::clear(const SkIRect* rect, | 
| 671                          GrColor color, | 668                          GrColor color, | 
| 672                          bool canIgnoreRect, | 669                          bool canIgnoreRect, | 
| 673                          GrRenderTarget* renderTarget) { | 670                          GrRenderTarget* renderTarget) { | 
| 674     if (fCaps->useDrawInsteadOfClear()) { | 671     if (fCaps->useDrawInsteadOfClear()) { | 
| 675         // This works around a driver bug with clear by drawing a rect instead. | 672         // This works around a driver bug with clear by drawing a rect instead. | 
| 676         // The driver will ignore a clear if it is the only thing rendered to a | 673         // The driver will ignore a clear if it is the only thing rendered to a | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 726     if (this->caps()->gpuTracingSupport()) { | 723     if (this->caps()->gpuTracingSupport()) { | 
| 727         SkASSERT(fGpuTraceMarkerCount >= 1); | 724         SkASSERT(fGpuTraceMarkerCount >= 1); | 
| 728         this->fActiveTraceMarkers.remove(*marker); | 725         this->fActiveTraceMarkers.remove(*marker); | 
| 729         --fGpuTraceMarkerCount; | 726         --fGpuTraceMarkerCount; | 
| 730     } | 727     } | 
| 731 } | 728 } | 
| 732 | 729 | 
| 733 //////////////////////////////////////////////////////////////////////////////// | 730 //////////////////////////////////////////////////////////////////////////////// | 
| 734 | 731 | 
| 735 void GrDrawTarget::drawIndexedInstances(GrDrawState* ds, | 732 void GrDrawTarget::drawIndexedInstances(GrDrawState* ds, | 
|  | 733                                         const GrGeometryProcessor* gp, | 
| 736                                         GrPrimitiveType type, | 734                                         GrPrimitiveType type, | 
| 737                                         int instanceCount, | 735                                         int instanceCount, | 
| 738                                         int verticesPerInstance, | 736                                         int verticesPerInstance, | 
| 739                                         int indicesPerInstance, | 737                                         int indicesPerInstance, | 
| 740                                         const SkRect* devBounds) { | 738                                         const SkRect* devBounds) { | 
| 741     SkASSERT(ds); | 739     SkASSERT(ds); | 
| 742 | 740 | 
| 743     if (!verticesPerInstance || !indicesPerInstance) { | 741     if (!verticesPerInstance || !indicesPerInstance) { | 
| 744         return; | 742         return; | 
| 745     } | 743     } | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 764     info.fIndicesPerInstance = indicesPerInstance; | 762     info.fIndicesPerInstance = indicesPerInstance; | 
| 765     info.fVerticesPerInstance = verticesPerInstance; | 763     info.fVerticesPerInstance = verticesPerInstance; | 
| 766 | 764 | 
| 767     // Set the same bounds for all the draws. | 765     // Set the same bounds for all the draws. | 
| 768     if (devBounds) { | 766     if (devBounds) { | 
| 769         info.setDevBounds(*devBounds); | 767         info.setDevBounds(*devBounds); | 
| 770     } | 768     } | 
| 771 | 769 | 
| 772     // TODO: We should continue with incorrect blending. | 770     // TODO: We should continue with incorrect blending. | 
| 773     GrDeviceCoordTexture dstCopy; | 771     GrDeviceCoordTexture dstCopy; | 
| 774     const GrGeometryProcessor* gp = ds->getGeometryProcessor(); | 772     if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy,devBounds)) { | 
| 775     if (!this->setupDstReadIfNecessary(ds, gp->getColor(), gp->getCoverage(), &d
      stCopy,devBounds)) { |  | 
| 776         return; | 773         return; | 
| 777     } | 774     } | 
| 778 | 775 | 
| 779     while (instanceCount) { | 776     while (instanceCount) { | 
| 780         info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); | 777         info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); | 
| 781         info.fVertexCount = info.fInstanceCount * verticesPerInstance; | 778         info.fVertexCount = info.fInstanceCount * verticesPerInstance; | 
| 782         info.fIndexCount = info.fInstanceCount * indicesPerInstance; | 779         info.fIndexCount = info.fInstanceCount * indicesPerInstance; | 
| 783 | 780 | 
| 784         if (this->checkDraw(*ds, | 781         if (this->checkDraw(*ds, | 
|  | 782                             gp, | 
| 785                             type, | 783                             type, | 
| 786                             info.fStartVertex, | 784                             info.fStartVertex, | 
| 787                             info.fStartIndex, | 785                             info.fStartIndex, | 
| 788                             info.fVertexCount, | 786                             info.fVertexCount, | 
| 789                             info.fIndexCount)) { | 787                             info.fIndexCount)) { | 
| 790             this->setDrawBuffers(&info, gp->getVertexStride()); | 788             this->setDrawBuffers(&info, gp->getVertexStride()); | 
| 791             this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy :
       NULL); | 789             this->onDraw(*ds, gp, info, scissorState, dstCopy.texture() ? &dstCo
      py : NULL); | 
| 792         } | 790         } | 
| 793         info.fStartVertex += info.fVertexCount; | 791         info.fStartVertex += info.fVertexCount; | 
| 794         instanceCount -= info.fInstanceCount; | 792         instanceCount -= info.fInstanceCount; | 
| 795     } | 793     } | 
| 796 } | 794 } | 
| 797 | 795 | 
| 798 //////////////////////////////////////////////////////////////////////////////// | 796 //////////////////////////////////////////////////////////////////////////////// | 
| 799 | 797 | 
| 800 GrDrawTarget::AutoReleaseGeometry::AutoReleaseGeometry( | 798 GrDrawTarget::AutoReleaseGeometry::AutoReleaseGeometry( | 
| 801                                          GrDrawTarget*  target, | 799                                          GrDrawTarget*  target, | 
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1217                              GrDrawState::AutoRestoreStencil* ars, | 1215                              GrDrawState::AutoRestoreStencil* ars, | 
| 1218                              GrDrawState* ds, | 1216                              GrDrawState* ds, | 
| 1219                              GrClipMaskManager::ScissorState* scissorState) { | 1217                              GrClipMaskManager::ScissorState* scissorState) { | 
| 1220     return fClipMaskManager.setupClipping(ds, | 1218     return fClipMaskManager.setupClipping(ds, | 
| 1221                                           are, | 1219                                           are, | 
| 1222                                           ars, | 1220                                           ars, | 
| 1223                                           scissorState, | 1221                                           scissorState, | 
| 1224                                           this->getClip(), | 1222                                           this->getClip(), | 
| 1225                                           devBounds); | 1223                                           devBounds); | 
| 1226 } | 1224 } | 
| OLD | NEW | 
|---|