| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrClipMaskManager.h" | 8 #include "GrClipMaskManager.h" |
| 9 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
| 10 #include "GrAAHairLinePathRenderer.h" | 10 #include "GrAAHairLinePathRenderer.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 472 |
| 473 SkMatrix sampleM; | 473 SkMatrix sampleM; |
| 474 sampleM.setIDiv(srcMask->width(), srcMask->height()); | 474 sampleM.setIDiv(srcMask->width(), srcMask->height()); |
| 475 | 475 |
| 476 pipelineBuilder->addCoverageProcessor( | 476 pipelineBuilder->addCoverageProcessor( |
| 477 GrTextureDomainEffect::Create(srcMask, | 477 GrTextureDomainEffect::Create(srcMask, |
| 478 sampleM, | 478 sampleM, |
| 479 GrTextureDomain::MakeTexelDomain(srcMask,
srcBound), | 479 GrTextureDomain::MakeTexelDomain(srcMask,
srcBound), |
| 480 GrTextureDomain::kDecal_Mode, | 480 GrTextureDomain::kDecal_Mode, |
| 481 GrTextureParams::kNone_FilterMode))->unref
(); | 481 GrTextureParams::kNone_FilterMode))->unref
(); |
| 482 // We need this AGP until everything is in GrBatch |
| 483 GrDrawTarget::AutoGeometryPush agp(fClipTarget); |
| 484 |
| 482 // The color passed in here does not matter since the coverageSetOpXP won't
read it. | 485 // The color passed in here does not matter since the coverageSetOpXP won't
read it. |
| 483 fClipTarget->drawSimpleRect(pipelineBuilder, | 486 fClipTarget->drawSimpleRect(pipelineBuilder, |
| 484 GrColor_WHITE, | 487 GrColor_WHITE, |
| 485 SkMatrix::I(), | 488 SkMatrix::I(), |
| 486 SkRect::Make(dstBound)); | 489 SkRect::Make(dstBound)); |
| 487 } | 490 } |
| 488 | 491 |
| 489 GrTexture* GrClipMaskManager::createTempMask(int width, int height) { | 492 GrTexture* GrClipMaskManager::createTempMask(int width, int height) { |
| 490 GrSurfaceDesc desc; | 493 GrSurfaceDesc desc; |
| 491 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 494 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 set_coverage_drawing_xpf(op, !invert, &backgroundPipelineBuilder
); | 666 set_coverage_drawing_xpf(op, !invert, &backgroundPipelineBuilder
); |
| 664 // Draw to the exterior pixels (those with a zero stencil value)
. | 667 // Draw to the exterior pixels (those with a zero stencil value)
. |
| 665 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, | 668 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, |
| 666 kZero_StencilOp, | 669 kZero_StencilOp, |
| 667 kZero_StencilOp, | 670 kZero_StencilOp, |
| 668 kEqual_StencilFunc, | 671 kEqual_StencilFunc, |
| 669 0xffff, | 672 0xffff, |
| 670 0x0000, | 673 0x0000, |
| 671 0xffff); | 674 0xffff); |
| 672 backgroundPipelineBuilder.setStencil(kDrawOutsideElement); | 675 backgroundPipelineBuilder.setStencil(kDrawOutsideElement); |
| 676 |
| 677 // We need this AGP until everything is in GrBatch |
| 678 GrDrawTarget::AutoGeometryPush agp(fClipTarget); |
| 673 // The color passed in here does not matter since the coverageSe
tOpXP won't read it. | 679 // The color passed in here does not matter since the coverageSe
tOpXP won't read it. |
| 674 fClipTarget->drawSimpleRect(&backgroundPipelineBuilder, GrColor_
WHITE, translate, | 680 fClipTarget->drawSimpleRect(&backgroundPipelineBuilder, GrColor_
WHITE, translate, |
| 675 clipSpaceIBounds); | 681 clipSpaceIBounds); |
| 676 } | 682 } |
| 677 } else { | 683 } else { |
| 678 GrPipelineBuilder pipelineBuilder; | 684 GrPipelineBuilder pipelineBuilder; |
| 679 | 685 |
| 680 // all the remaining ops can just be directly draw into the accumula
tion buffer | 686 // all the remaining ops can just be directly draw into the accumula
tion buffer |
| 681 set_coverage_drawing_xpf(op, false, &pipelineBuilder); | 687 set_coverage_drawing_xpf(op, false, &pipelineBuilder); |
| 682 // The color passed in here does not matter since the coverageSetOpX
P won't read it. | 688 // The color passed in here does not matter since the coverageSetOpX
P won't read it. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 if (!canDrawDirectToClip) { | 805 if (!canDrawDirectToClip) { |
| 800 GR_STATIC_CONST_SAME_STENCIL(gDrawToStencil, | 806 GR_STATIC_CONST_SAME_STENCIL(gDrawToStencil, |
| 801 kIncClamp_StencilOp, | 807 kIncClamp_StencilOp, |
| 802 kIncClamp_StencilOp, | 808 kIncClamp_StencilOp, |
| 803 kAlways_StencilFunc, | 809 kAlways_StencilFunc, |
| 804 0xffff, | 810 0xffff, |
| 805 0x0000, | 811 0x0000, |
| 806 0xffff); | 812 0xffff); |
| 807 if (Element::kRect_Type == element->getType()) { | 813 if (Element::kRect_Type == element->getType()) { |
| 808 *pipelineBuilder.stencil() = gDrawToStencil; | 814 *pipelineBuilder.stencil() = gDrawToStencil; |
| 815 |
| 816 // We need this AGP until everything is in GrBatch |
| 817 GrDrawTarget::AutoGeometryPush agp(fClipTarget); |
| 809 fClipTarget->drawSimpleRect(&pipelineBuilder, | 818 fClipTarget->drawSimpleRect(&pipelineBuilder, |
| 810 GrColor_WHITE, | 819 GrColor_WHITE, |
| 811 viewMatrix, | 820 viewMatrix, |
| 812 element->getRect()); | 821 element->getRect()); |
| 813 } else { | 822 } else { |
| 814 if (!clipPath.isEmpty()) { | 823 if (!clipPath.isEmpty()) { |
| 815 GrDrawTarget::AutoGeometryPush agp(fClipTarget); | 824 GrDrawTarget::AutoGeometryPush agp(fClipTarget); |
| 816 if (canRenderDirectToStencil) { | 825 if (canRenderDirectToStencil) { |
| 817 *pipelineBuilder.stencil() = gDrawToStencil; | 826 *pipelineBuilder.stencil() = gDrawToStencil; |
| 818 pr->drawPath(fClipTarget, &pipelineBuilder, GrColor_
WHITE, | 827 pr->drawPath(fClipTarget, &pipelineBuilder, GrColor_
WHITE, |
| 819 viewMatrix, clipPath, stroke, false); | 828 viewMatrix, clipPath, stroke, false); |
| 820 } else { | 829 } else { |
| 821 pr->stencilPath(fClipTarget, &pipelineBuilder, viewM
atrix, | 830 pr->stencilPath(fClipTarget, &pipelineBuilder, viewM
atrix, |
| 822 clipPath, stroke); | 831 clipPath, stroke); |
| 823 } | 832 } |
| 824 } | 833 } |
| 825 } | 834 } |
| 826 } | 835 } |
| 827 | 836 |
| 828 // now we modify the clip bit by rendering either the clip | 837 // now we modify the clip bit by rendering either the clip |
| 829 // element directly or a bounding rect of the entire clip. | 838 // element directly or a bounding rect of the entire clip. |
| 830 fClipMode = kModifyClip_StencilClipMode; | 839 fClipMode = kModifyClip_StencilClipMode; |
| 831 for (int p = 0; p < passes; ++p) { | 840 for (int p = 0; p < passes; ++p) { |
| 832 GrPipelineBuilder pipelineBuilderCopy(pipelineBuilder); | 841 GrPipelineBuilder pipelineBuilderCopy(pipelineBuilder); |
| 833 *pipelineBuilderCopy.stencil() = stencilSettings[p]; | 842 *pipelineBuilderCopy.stencil() = stencilSettings[p]; |
| 834 | 843 |
| 835 if (canDrawDirectToClip) { | 844 if (canDrawDirectToClip) { |
| 836 if (Element::kRect_Type == element->getType()) { | 845 if (Element::kRect_Type == element->getType()) { |
| 846 // We need this AGP until everything is in GrBatch |
| 847 GrDrawTarget::AutoGeometryPush agp(fClipTarget); |
| 837 fClipTarget->drawSimpleRect(&pipelineBuilderCopy, | 848 fClipTarget->drawSimpleRect(&pipelineBuilderCopy, |
| 838 GrColor_WHITE, | 849 GrColor_WHITE, |
| 839 viewMatrix, | 850 viewMatrix, |
| 840 element->getRect()); | 851 element->getRect()); |
| 841 } else { | 852 } else { |
| 842 GrDrawTarget::AutoGeometryPush agp(fClipTarget); | 853 GrDrawTarget::AutoGeometryPush agp(fClipTarget); |
| 843 pr->drawPath(fClipTarget, &pipelineBuilderCopy, GrColor_
WHITE, | 854 pr->drawPath(fClipTarget, &pipelineBuilderCopy, GrColor_
WHITE, |
| 844 viewMatrix, clipPath, stroke, false); | 855 viewMatrix, clipPath, stroke, false); |
| 845 } | 856 } |
| 846 } else { | 857 } else { |
| 858 // We need this AGP until everything is in GrBatch |
| 859 GrDrawTarget::AutoGeometryPush agp(fClipTarget); |
| 860 |
| 847 // The view matrix is setup to do clip space -> stencil spac
e translation, so | 861 // The view matrix is setup to do clip space -> stencil spac
e translation, so |
| 848 // draw rect in clip space. | 862 // draw rect in clip space. |
| 849 fClipTarget->drawSimpleRect(&pipelineBuilderCopy, | 863 fClipTarget->drawSimpleRect(&pipelineBuilderCopy, |
| 850 GrColor_WHITE, | 864 GrColor_WHITE, |
| 851 viewMatrix, | 865 viewMatrix, |
| 852 SkRect::Make(clipSpaceIBounds)); | 866 SkRect::Make(clipSpaceIBounds)); |
| 853 } | 867 } |
| 854 } | 868 } |
| 855 } | 869 } |
| 856 } | 870 } |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 fAACache.setContext(clipTarget->getContext()); | 1127 fAACache.setContext(clipTarget->getContext()); |
| 1114 } | 1128 } |
| 1115 | 1129 |
| 1116 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, | 1130 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, |
| 1117 GrStencilSettings* settings) { | 1131 GrStencilSettings* settings) { |
| 1118 if (stencilBuffer) { | 1132 if (stencilBuffer) { |
| 1119 int stencilBits = stencilBuffer->bits(); | 1133 int stencilBits = stencilBuffer->bits(); |
| 1120 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1134 this->adjustStencilParams(settings, fClipMode, stencilBits); |
| 1121 } | 1135 } |
| 1122 } | 1136 } |
| OLD | NEW |