| 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 int indexCount, | 442 int indexCount, |
| 443 const SkRect* devBounds) { | 443 const SkRect* devBounds) { |
| 444 SkASSERT(ds); | 444 SkASSERT(ds); |
| 445 if (indexCount > 0 && | 445 if (indexCount > 0 && |
| 446 this->checkDraw(*ds, gp, type, startVertex, startIndex, vertexCount, ind
exCount)) { | 446 this->checkDraw(*ds, gp, type, startVertex, startIndex, vertexCount, ind
exCount)) { |
| 447 | 447 |
| 448 // Setup clip | 448 // Setup clip |
| 449 GrScissorState scissorState; | 449 GrScissorState scissorState; |
| 450 GrDrawState::AutoRestoreEffects are; | 450 GrDrawState::AutoRestoreEffects are; |
| 451 GrDrawState::AutoRestoreStencil ars; | 451 GrDrawState::AutoRestoreStencil ars; |
| 452 if (!this->setupClip(devBounds, &are, &ars, ds, &scissorState)) { | 452 if (!this->setupClip(ds, &are, &ars, &scissorState, devBounds)) { |
| 453 return; | 453 return; |
| 454 } | 454 } |
| 455 | 455 |
| 456 DrawInfo info; | 456 DrawInfo info; |
| 457 info.fPrimitiveType = type; | 457 info.fPrimitiveType = type; |
| 458 info.fStartVertex = startVertex; | 458 info.fStartVertex = startVertex; |
| 459 info.fStartIndex = startIndex; | 459 info.fStartIndex = startIndex; |
| 460 info.fVertexCount = vertexCount; | 460 info.fVertexCount = vertexCount; |
| 461 info.fIndexCount = indexCount; | 461 info.fIndexCount = indexCount; |
| 462 | 462 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 485 int startVertex, | 485 int startVertex, |
| 486 int vertexCount, | 486 int vertexCount, |
| 487 const SkRect* devBounds) { | 487 const SkRect* devBounds) { |
| 488 SkASSERT(ds); | 488 SkASSERT(ds); |
| 489 if (vertexCount > 0 && this->checkDraw(*ds, gp, type, startVertex, -1, verte
xCount, -1)) { | 489 if (vertexCount > 0 && this->checkDraw(*ds, gp, type, startVertex, -1, verte
xCount, -1)) { |
| 490 | 490 |
| 491 // Setup clip | 491 // Setup clip |
| 492 GrScissorState scissorState; | 492 GrScissorState scissorState; |
| 493 GrDrawState::AutoRestoreEffects are; | 493 GrDrawState::AutoRestoreEffects are; |
| 494 GrDrawState::AutoRestoreStencil ars; | 494 GrDrawState::AutoRestoreStencil ars; |
| 495 if (!this->setupClip(devBounds, &are, &ars, ds, &scissorState)) { | 495 if (!this->setupClip(ds, &are, &ars, &scissorState, devBounds)) { |
| 496 return; | 496 return; |
| 497 } | 497 } |
| 498 | 498 |
| 499 DrawInfo info; | 499 DrawInfo info; |
| 500 info.fPrimitiveType = type; | 500 info.fPrimitiveType = type; |
| 501 info.fStartVertex = startVertex; | 501 info.fStartVertex = startVertex; |
| 502 info.fStartIndex = 0; | 502 info.fStartIndex = 0; |
| 503 info.fVertexCount = vertexCount; | 503 info.fVertexCount = vertexCount; |
| 504 info.fIndexCount = 0; | 504 info.fIndexCount = 0; |
| 505 | 505 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 GrPathRendering::FillType fill) { | 564 GrPathRendering::FillType fill) { |
| 565 // TODO: extract portions of checkDraw that are relevant to path stenciling. | 565 // TODO: extract portions of checkDraw that are relevant to path stenciling. |
| 566 SkASSERT(path); | 566 SkASSERT(path); |
| 567 SkASSERT(this->caps()->pathRenderingSupport()); | 567 SkASSERT(this->caps()->pathRenderingSupport()); |
| 568 SkASSERT(ds); | 568 SkASSERT(ds); |
| 569 | 569 |
| 570 // Setup clip | 570 // Setup clip |
| 571 GrScissorState scissorState; | 571 GrScissorState scissorState; |
| 572 GrDrawState::AutoRestoreEffects are; | 572 GrDrawState::AutoRestoreEffects are; |
| 573 GrDrawState::AutoRestoreStencil ars; | 573 GrDrawState::AutoRestoreStencil ars; |
| 574 if (!this->setupClip(NULL, &are, &ars, ds, &scissorState)) { | 574 if (!this->setupClip(ds, &are, &ars, &scissorState, NULL)) { |
| 575 return; | 575 return; |
| 576 } | 576 } |
| 577 | 577 |
| 578 // set stencil settings for path | 578 // set stencil settings for path |
| 579 GrStencilSettings stencilSettings; | 579 GrStencilSettings stencilSettings; |
| 580 this->getPathStencilSettingsForFilltype(fill, | 580 this->getPathStencilSettingsForFilltype(fill, |
| 581 ds->getRenderTarget()->getStencilBuf
fer(), | 581 ds->getRenderTarget()->getStencilBuf
fer(), |
| 582 &stencilSettings); | 582 &stencilSettings); |
| 583 | 583 |
| 584 this->onStencilPath(*ds, pathProc, path, scissorState, stencilSettings); | 584 this->onStencilPath(*ds, pathProc, path, scissorState, stencilSettings); |
| 585 } | 585 } |
| 586 | 586 |
| 587 void GrDrawTarget::drawPath(GrDrawState* ds, | 587 void GrDrawTarget::drawPath(GrDrawState* ds, |
| 588 const GrPathProcessor* pathProc, | 588 const GrPathProcessor* pathProc, |
| 589 const GrPath* path, | 589 const GrPath* path, |
| 590 GrPathRendering::FillType fill) { | 590 GrPathRendering::FillType fill) { |
| 591 // TODO: extract portions of checkDraw that are relevant to path rendering. | 591 // TODO: extract portions of checkDraw that are relevant to path rendering. |
| 592 SkASSERT(path); | 592 SkASSERT(path); |
| 593 SkASSERT(this->caps()->pathRenderingSupport()); | 593 SkASSERT(this->caps()->pathRenderingSupport()); |
| 594 SkASSERT(ds); | 594 SkASSERT(ds); |
| 595 | 595 |
| 596 SkRect devBounds = path->getBounds(); | 596 SkRect devBounds = path->getBounds(); |
| 597 SkMatrix viewM = ds->getViewMatrix(); | 597 pathProc->viewMatrix().mapRect(&devBounds); |
| 598 viewM.mapRect(&devBounds); | |
| 599 | 598 |
| 600 // Setup clip | 599 // Setup clip |
| 601 GrScissorState scissorState; | 600 GrScissorState scissorState; |
| 602 GrDrawState::AutoRestoreEffects are; | 601 GrDrawState::AutoRestoreEffects are; |
| 603 GrDrawState::AutoRestoreStencil ars; | 602 GrDrawState::AutoRestoreStencil ars; |
| 604 if (!this->setupClip(&devBounds, &are, &ars, ds, &scissorState)) { | 603 if (!this->setupClip(ds, &are, &ars, &scissorState, &devBounds)) { |
| 605 return; | 604 return; |
| 606 } | 605 } |
| 607 | 606 |
| 608 // set stencil settings for path | 607 // set stencil settings for path |
| 609 GrStencilSettings stencilSettings; | 608 GrStencilSettings stencilSettings; |
| 610 this->getPathStencilSettingsForFilltype(fill, | 609 this->getPathStencilSettingsForFilltype(fill, |
| 611 ds->getRenderTarget()->getStencilBuf
fer(), | 610 ds->getRenderTarget()->getStencilBuf
fer(), |
| 612 &stencilSettings); | 611 &stencilSettings); |
| 613 | 612 |
| 614 GrDeviceCoordTexture dstCopy; | 613 GrDeviceCoordTexture dstCopy; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 634 SkASSERT(indices); | 633 SkASSERT(indices); |
| 635 SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeIn
Bytes(indexType)); | 634 SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeIn
Bytes(indexType)); |
| 636 SkASSERT(transformValues); | 635 SkASSERT(transformValues); |
| 637 SkASSERT(ds); | 636 SkASSERT(ds); |
| 638 | 637 |
| 639 // Setup clip | 638 // Setup clip |
| 640 GrScissorState scissorState; | 639 GrScissorState scissorState; |
| 641 GrDrawState::AutoRestoreEffects are; | 640 GrDrawState::AutoRestoreEffects are; |
| 642 GrDrawState::AutoRestoreStencil ars; | 641 GrDrawState::AutoRestoreStencil ars; |
| 643 | 642 |
| 644 if (!this->setupClip(NULL, &are, &ars, ds, &scissorState)) { | 643 if (!this->setupClip(ds, &are, &ars, &scissorState, NULL)) { |
| 645 return; | 644 return; |
| 646 } | 645 } |
| 647 | 646 |
| 648 // set stencil settings for path | 647 // set stencil settings for path |
| 649 GrStencilSettings stencilSettings; | 648 GrStencilSettings stencilSettings; |
| 650 this->getPathStencilSettingsForFilltype(fill, | 649 this->getPathStencilSettingsForFilltype(fill, |
| 651 ds->getRenderTarget()->getStencilBuf
fer(), | 650 ds->getRenderTarget()->getStencilBuf
fer(), |
| 652 &stencilSettings); | 651 &stencilSettings); |
| 653 | 652 |
| 654 // Don't compute a bounding box for setupDstReadIfNecessary(), we'll opt | 653 // Don't compute a bounding box for setupDstReadIfNecessary(), we'll opt |
| (...skipping 20 matching lines...) Expand all Loading... |
| 675 SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->he
ight()); | 674 SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->he
ight()); |
| 676 if (NULL == rect || canIgnoreRect || rect->contains(rtRect)) { | 675 if (NULL == rect || canIgnoreRect || rect->contains(rtRect)) { |
| 677 rect = &rtRect; | 676 rect = &rtRect; |
| 678 // We first issue a discard() since that may help tilers. | 677 // We first issue a discard() since that may help tilers. |
| 679 this->discard(renderTarget); | 678 this->discard(renderTarget); |
| 680 } | 679 } |
| 681 | 680 |
| 682 GrDrawState drawState; | 681 GrDrawState drawState; |
| 683 drawState.setRenderTarget(renderTarget); | 682 drawState.setRenderTarget(renderTarget); |
| 684 | 683 |
| 685 this->drawSimpleRect(&drawState, color, *rect); | 684 this->drawSimpleRect(&drawState, color, SkMatrix::I(), *rect); |
| 686 } else { | 685 } else { |
| 687 this->onClear(rect, color, canIgnoreRect, renderTarget); | 686 this->onClear(rect, color, canIgnoreRect, renderTarget); |
| 688 } | 687 } |
| 689 } | 688 } |
| 690 | 689 |
| 691 typedef GrTraceMarkerSet::Iter TMIter; | 690 typedef GrTraceMarkerSet::Iter TMIter; |
| 692 void GrDrawTarget::saveActiveTraceMarkers() { | 691 void GrDrawTarget::saveActiveTraceMarkers() { |
| 693 if (this->caps()->gpuTracingSupport()) { | 692 if (this->caps()->gpuTracingSupport()) { |
| 694 SkASSERT(0 == fStoredTraceMarkers.count()); | 693 SkASSERT(0 == fStoredTraceMarkers.count()); |
| 695 fStoredTraceMarkers.addSet(fActiveTraceMarkers); | 694 fStoredTraceMarkers.addSet(fActiveTraceMarkers); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 | 743 |
| 745 int maxInstancesPerDraw = this->indexCountInCurrentSource() / indicesPerInst
ance; | 744 int maxInstancesPerDraw = this->indexCountInCurrentSource() / indicesPerInst
ance; |
| 746 if (!maxInstancesPerDraw) { | 745 if (!maxInstancesPerDraw) { |
| 747 return; | 746 return; |
| 748 } | 747 } |
| 749 | 748 |
| 750 // Setup clip | 749 // Setup clip |
| 751 GrScissorState scissorState; | 750 GrScissorState scissorState; |
| 752 GrDrawState::AutoRestoreEffects are; | 751 GrDrawState::AutoRestoreEffects are; |
| 753 GrDrawState::AutoRestoreStencil ars; | 752 GrDrawState::AutoRestoreStencil ars; |
| 754 if (!this->setupClip(devBounds, &are, &ars, ds, &scissorState)) { | 753 if (!this->setupClip(ds, &are, &ars, &scissorState, devBounds)) { |
| 755 return; | 754 return; |
| 756 } | 755 } |
| 757 | 756 |
| 758 DrawInfo info; | 757 DrawInfo info; |
| 759 info.fPrimitiveType = type; | 758 info.fPrimitiveType = type; |
| 760 info.fStartIndex = 0; | 759 info.fStartIndex = 0; |
| 761 info.fStartVertex = 0; | 760 info.fStartVertex = 0; |
| 762 info.fIndicesPerInstance = indicesPerInstance; | 761 info.fIndicesPerInstance = indicesPerInstance; |
| 763 info.fVerticesPerInstance = verticesPerInstance; | 762 info.fVerticesPerInstance = verticesPerInstance; |
| 764 | 763 |
| 765 // Set the same bounds for all the draws. | 764 // Set the same bounds for all the draws. |
| 766 if (devBounds) { | 765 if (devBounds) { |
| 767 info.setDevBounds(*devBounds); | 766 info.setDevBounds(*devBounds); |
| 768 } | 767 } |
| 769 | 768 |
| 770 // TODO: We should continue with incorrect blending. | 769 // TODO: We should continue with incorrect blending. |
| 771 GrDeviceCoordTexture dstCopy; | 770 GrDeviceCoordTexture dstCopy; |
| 772 if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy,devBounds)) { | 771 if (!this->setupDstReadIfNecessary(ds, gp, &dstCopy, devBounds)) { |
| 773 return; | 772 return; |
| 774 } | 773 } |
| 775 | 774 |
| 776 while (instanceCount) { | 775 while (instanceCount) { |
| 777 info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); | 776 info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); |
| 778 info.fVertexCount = info.fInstanceCount * verticesPerInstance; | 777 info.fVertexCount = info.fInstanceCount * verticesPerInstance; |
| 779 info.fIndexCount = info.fInstanceCount * indicesPerInstance; | 778 info.fIndexCount = info.fInstanceCount * indicesPerInstance; |
| 780 | 779 |
| 781 if (this->checkDraw(*ds, | 780 if (this->checkDraw(*ds, |
| 782 gp, | 781 gp, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 drawState.setRenderTarget(rt); | 943 drawState.setRenderTarget(rt); |
| 945 SkMatrix matrix; | 944 SkMatrix matrix; |
| 946 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX)
, | 945 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX)
, |
| 947 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY))
; | 946 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY))
; |
| 948 matrix.postIDiv(tex->width(), tex->height()); | 947 matrix.postIDiv(tex->width(), tex->height()); |
| 949 drawState.addColorTextureProcessor(tex, matrix); | 948 drawState.addColorTextureProcessor(tex, matrix); |
| 950 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX, | 949 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX, |
| 951 clippedDstPoint.fY, | 950 clippedDstPoint.fY, |
| 952 clippedSrcRect.width(), | 951 clippedSrcRect.width(), |
| 953 clippedSrcRect.height()); | 952 clippedSrcRect.height()); |
| 954 this->drawSimpleRect(&drawState, GrColor_WHITE, dstRect); | 953 this->drawSimpleRect(&drawState, GrColor_WHITE, SkMatrix::I(), dstRect); |
| 955 return true; | 954 return true; |
| 956 } | 955 } |
| 957 | 956 |
| 958 bool GrDrawTarget::canCopySurface(const GrSurface* dst, | 957 bool GrDrawTarget::canCopySurface(const GrSurface* dst, |
| 959 const GrSurface* src, | 958 const GrSurface* src, |
| 960 const SkIRect& srcRect, | 959 const SkIRect& srcRect, |
| 961 const SkIPoint& dstPoint) { | 960 const SkIPoint& dstPoint) { |
| 962 SkASSERT(dst); | 961 SkASSERT(dst); |
| 963 SkASSERT(src); | 962 SkASSERT(src); |
| 964 | 963 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 static int32_t gUniqueID = SK_InvalidUniqueID; | 1204 static int32_t gUniqueID = SK_InvalidUniqueID; |
| 1206 uint32_t id; | 1205 uint32_t id; |
| 1207 do { | 1206 do { |
| 1208 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 1207 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 1209 } while (id == SK_InvalidUniqueID); | 1208 } while (id == SK_InvalidUniqueID); |
| 1210 return id; | 1209 return id; |
| 1211 } | 1210 } |
| 1212 | 1211 |
| 1213 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 1212 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 1214 | 1213 |
| 1215 bool GrClipTarget::setupClip(const SkRect* devBounds, | 1214 bool GrClipTarget::setupClip(GrDrawState* ds, |
| 1216 GrDrawState::AutoRestoreEffects* are, | 1215 GrDrawState::AutoRestoreEffects* are, |
| 1217 GrDrawState::AutoRestoreStencil* ars, | 1216 GrDrawState::AutoRestoreStencil* ars, |
| 1218 GrDrawState* ds, | 1217 GrScissorState* scissorState, |
| 1219 GrScissorState* scissorState) { | 1218 const SkRect* devBounds) { |
| 1220 return fClipMaskManager.setupClipping(ds, | 1219 return fClipMaskManager.setupClipping(ds, |
| 1221 are, | 1220 are, |
| 1222 ars, | 1221 ars, |
| 1223 scissorState, | 1222 scissorState, |
| 1224 this->getClip(), | 1223 this->getClip(), |
| 1225 devBounds); | 1224 devBounds); |
| 1226 } | 1225 } |
| OLD | NEW |