| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 case Element::kRect_Type: | 403 case Element::kRect_Type: |
| 404 // TODO: Do rects directly to the accumulator using a aa-rect GrProc
essor that covers | 404 // TODO: Do rects directly to the accumulator using a aa-rect GrProc
essor that covers |
| 405 // the entire mask bounds and writes 0 outside the rect. | 405 // the entire mask bounds and writes 0 outside the rect. |
| 406 if (element->isAA()) { | 406 if (element->isAA()) { |
| 407 SkRect devRect = element->getRect(); | 407 SkRect devRect = element->getRect(); |
| 408 viewMatrix.mapRect(&devRect); | 408 viewMatrix.mapRect(&devRect); |
| 409 | 409 |
| 410 fClipTarget->drawAARect(*pipelineBuilder, color, viewMatrix, | 410 fClipTarget->drawAARect(*pipelineBuilder, color, viewMatrix, |
| 411 element->getRect(), devRect); | 411 element->getRect(), devRect); |
| 412 } else { | 412 } else { |
| 413 fClipTarget->drawBWRect(*pipelineBuilder, color, viewMatrix, | 413 fClipTarget->drawNonAARect(*pipelineBuilder, color, viewMatrix, |
| 414 element->getRect()); | 414 element->getRect()); |
| 415 } | 415 } |
| 416 return true; | 416 return true; |
| 417 default: { | 417 default: { |
| 418 SkPath path; | 418 SkPath path; |
| 419 element->asPath(&path); | 419 element->asPath(&path); |
| 420 path.setIsVolatile(true); | 420 path.setIsVolatile(true); |
| 421 if (path.isInverseFillType()) { | 421 if (path.isInverseFillType()) { |
| 422 path.toggleInverseFillType(); | 422 path.toggleInverseFillType(); |
| 423 } | 423 } |
| 424 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle); | 424 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 490 |
| 491 pipelineBuilder->addCoverageProcessor( | 491 pipelineBuilder->addCoverageProcessor( |
| 492 GrTextureDomainEffect::Create(pipelineBuilder->getProcessorDataManager()
, | 492 GrTextureDomainEffect::Create(pipelineBuilder->getProcessorDataManager()
, |
| 493 srcMask, | 493 srcMask, |
| 494 sampleM, | 494 sampleM, |
| 495 GrTextureDomain::MakeTexelDomain(srcMask,
srcBound), | 495 GrTextureDomain::MakeTexelDomain(srcMask,
srcBound), |
| 496 GrTextureDomain::kDecal_Mode, | 496 GrTextureDomain::kDecal_Mode, |
| 497 GrTextureParams::kNone_FilterMode))->unref
(); | 497 GrTextureParams::kNone_FilterMode))->unref
(); |
| 498 | 498 |
| 499 // The color passed in here does not matter since the coverageSetOpXP won't
read it. | 499 // The color passed in here does not matter since the coverageSetOpXP won't
read it. |
| 500 fClipTarget->drawBWRect(*pipelineBuilder, | 500 fClipTarget->drawNonAARect(*pipelineBuilder, |
| 501 GrColor_WHITE, | 501 GrColor_WHITE, |
| 502 SkMatrix::I(), | 502 SkMatrix::I(), |
| 503 SkRect::Make(dstBound)); | 503 SkRect::Make(dstBound)); |
| 504 } | 504 } |
| 505 | 505 |
| 506 GrTexture* GrClipMaskManager::createTempMask(int width, int height) { | 506 GrTexture* GrClipMaskManager::createTempMask(int width, int height) { |
| 507 GrSurfaceDesc desc; | 507 GrSurfaceDesc desc; |
| 508 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 508 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 509 desc.fWidth = width; | 509 desc.fWidth = width; |
| 510 desc.fHeight = height; | 510 desc.fHeight = height; |
| 511 if (this->getContext()->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, f
alse)) { | 511 if (this->getContext()->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, f
alse)) { |
| 512 desc.fConfig = kAlpha_8_GrPixelConfig; | 512 desc.fConfig = kAlpha_8_GrPixelConfig; |
| 513 } else { | 513 } else { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, | 683 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, |
| 684 kZero_StencilOp, | 684 kZero_StencilOp, |
| 685 kZero_StencilOp, | 685 kZero_StencilOp, |
| 686 kEqual_StencilFunc, | 686 kEqual_StencilFunc, |
| 687 0xffff, | 687 0xffff, |
| 688 0x0000, | 688 0x0000, |
| 689 0xffff); | 689 0xffff); |
| 690 backgroundPipelineBuilder.setStencil(kDrawOutsideElement); | 690 backgroundPipelineBuilder.setStencil(kDrawOutsideElement); |
| 691 | 691 |
| 692 // The color passed in here does not matter since the coverageSe
tOpXP won't read it. | 692 // The color passed in here does not matter since the coverageSe
tOpXP won't read it. |
| 693 fClipTarget->drawSimpleRect(backgroundPipelineBuilder, GrColor_W
HITE, translate, | 693 fClipTarget->drawNonAARect(backgroundPipelineBuilder, GrColor_WH
ITE, translate, |
| 694 clipSpaceIBounds); | 694 clipSpaceIBounds); |
| 695 } | 695 } |
| 696 } else { | 696 } else { |
| 697 GrPipelineBuilder pipelineBuilder; | 697 GrPipelineBuilder pipelineBuilder; |
| 698 | 698 |
| 699 // all the remaining ops can just be directly draw into the accumula
tion buffer | 699 // all the remaining ops can just be directly draw into the accumula
tion buffer |
| 700 set_coverage_drawing_xpf(op, false, &pipelineBuilder); | 700 set_coverage_drawing_xpf(op, false, &pipelineBuilder); |
| 701 // The color passed in here does not matter since the coverageSetOpX
P won't read it. | 701 // The color passed in here does not matter since the coverageSetOpX
P won't read it. |
| 702 this->drawElement(&pipelineBuilder, translate, result, element); | 702 this->drawElement(&pipelineBuilder, translate, result, element); |
| 703 } | 703 } |
| 704 } | 704 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 kIncClamp_StencilOp, | 820 kIncClamp_StencilOp, |
| 821 kIncClamp_StencilOp, | 821 kIncClamp_StencilOp, |
| 822 kAlways_StencilFunc, | 822 kAlways_StencilFunc, |
| 823 0xffff, | 823 0xffff, |
| 824 0x0000, | 824 0x0000, |
| 825 0xffff); | 825 0xffff); |
| 826 if (Element::kRect_Type == element->getType()) { | 826 if (Element::kRect_Type == element->getType()) { |
| 827 *pipelineBuilder.stencil() = gDrawToStencil; | 827 *pipelineBuilder.stencil() = gDrawToStencil; |
| 828 | 828 |
| 829 // We need this AGP until everything is in GrBatch | 829 // We need this AGP until everything is in GrBatch |
| 830 fClipTarget->drawBWRect(pipelineBuilder, | 830 fClipTarget->drawNonAARect(pipelineBuilder, |
| 831 GrColor_WHITE, | 831 GrColor_WHITE, |
| 832 viewMatrix, | 832 viewMatrix, |
| 833 element->getRect()); | 833 element->getRect()); |
| 834 } else { | 834 } else { |
| 835 if (!clipPath.isEmpty()) { | 835 if (!clipPath.isEmpty()) { |
| 836 if (canRenderDirectToStencil) { | 836 if (canRenderDirectToStencil) { |
| 837 *pipelineBuilder.stencil() = gDrawToStencil; | 837 *pipelineBuilder.stencil() = gDrawToStencil; |
| 838 | 838 |
| 839 GrPathRenderer::DrawPathArgs args; | 839 GrPathRenderer::DrawPathArgs args; |
| 840 args.fTarget = fClipTarget; | 840 args.fTarget = fClipTarget; |
| 841 args.fResourceProvider = this->getContext()->resourc
eProvider(); | 841 args.fResourceProvider = this->getContext()->resourc
eProvider(); |
| 842 args.fPipelineBuilder = &pipelineBuilder; | 842 args.fPipelineBuilder = &pipelineBuilder; |
| 843 args.fColor = GrColor_WHITE; | 843 args.fColor = GrColor_WHITE; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 862 | 862 |
| 863 // now we modify the clip bit by rendering either the clip | 863 // now we modify the clip bit by rendering either the clip |
| 864 // element directly or a bounding rect of the entire clip. | 864 // element directly or a bounding rect of the entire clip. |
| 865 fClipMode = kModifyClip_StencilClipMode; | 865 fClipMode = kModifyClip_StencilClipMode; |
| 866 for (int p = 0; p < passes; ++p) { | 866 for (int p = 0; p < passes; ++p) { |
| 867 *pipelineBuilder.stencil() = stencilSettings[p]; | 867 *pipelineBuilder.stencil() = stencilSettings[p]; |
| 868 | 868 |
| 869 if (canDrawDirectToClip) { | 869 if (canDrawDirectToClip) { |
| 870 if (Element::kRect_Type == element->getType()) { | 870 if (Element::kRect_Type == element->getType()) { |
| 871 // We need this AGP until everything is in GrBatch | 871 // We need this AGP until everything is in GrBatch |
| 872 fClipTarget->drawBWRect(pipelineBuilder, | 872 fClipTarget->drawNonAARect(pipelineBuilder, |
| 873 GrColor_WHITE, | 873 GrColor_WHITE, |
| 874 viewMatrix, | 874 viewMatrix, |
| 875 element->getRect()); | 875 element->getRect()); |
| 876 } else { | 876 } else { |
| 877 GrPathRenderer::DrawPathArgs args; | 877 GrPathRenderer::DrawPathArgs args; |
| 878 args.fTarget = fClipTarget; | 878 args.fTarget = fClipTarget; |
| 879 args.fResourceProvider = this->getContext()->resourcePro
vider(); | 879 args.fResourceProvider = this->getContext()->resourcePro
vider(); |
| 880 args.fPipelineBuilder = &pipelineBuilder; | 880 args.fPipelineBuilder = &pipelineBuilder; |
| 881 args.fColor = GrColor_WHITE; | 881 args.fColor = GrColor_WHITE; |
| 882 args.fViewMatrix = &viewMatrix; | 882 args.fViewMatrix = &viewMatrix; |
| 883 args.fPath = &clipPath; | 883 args.fPath = &clipPath; |
| 884 args.fStroke = &stroke; | 884 args.fStroke = &stroke; |
| 885 args.fAntiAlias = false; | 885 args.fAntiAlias = false; |
| 886 pr->drawPath(args); | 886 pr->drawPath(args); |
| 887 } | 887 } |
| 888 } else { | 888 } else { |
| 889 // The view matrix is setup to do clip space -> stencil spac
e translation, so | 889 // The view matrix is setup to do clip space -> stencil spac
e translation, so |
| 890 // draw rect in clip space. | 890 // draw rect in clip space. |
| 891 fClipTarget->drawBWRect(pipelineBuilder, | 891 fClipTarget->drawNonAARect(pipelineBuilder, |
| 892 GrColor_WHITE, | 892 GrColor_WHITE, |
| 893 viewMatrix, | 893 viewMatrix, |
| 894 SkRect::Make(clipSpaceIBounds)); | 894 SkRect::Make(clipSpaceIBounds)); |
| 895 } | 895 } |
| 896 } | 896 } |
| 897 } | 897 } |
| 898 } | 898 } |
| 899 // set this last because recursive draws may overwrite it back to kNone. | 899 // set this last because recursive draws may overwrite it back to kNone. |
| 900 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); | 900 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); |
| 901 fCurrClipMaskType = kStencil_ClipMaskType; | 901 fCurrClipMaskType = kStencil_ClipMaskType; |
| 902 fClipMode = kRespectClip_StencilClipMode; | 902 fClipMode = kRespectClip_StencilClipMode; |
| 903 return true; | 903 return true; |
| 904 } | 904 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 fAACache.purgeResources(); | 1150 fAACache.purgeResources(); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, | 1153 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, |
| 1154 GrStencilSettings* settings) { | 1154 GrStencilSettings* settings) { |
| 1155 if (stencilAttachment) { | 1155 if (stencilAttachment) { |
| 1156 int stencilBits = stencilAttachment->bits(); | 1156 int stencilBits = stencilAttachment->bits(); |
| 1157 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1157 this->adjustStencilParams(settings, fClipMode, stencilBits); |
| 1158 } | 1158 } |
| 1159 } | 1159 } |
| OLD | NEW |