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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 if (NULL == pr) { | 425 if (NULL == pr) { |
426 GrPathRendererChain::DrawType type; | 426 GrPathRendererChain::DrawType type; |
427 type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_Dr
awType : | 427 type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_Dr
awType : |
428 GrPathRendererChain::kColor_DrawType; | 428 GrPathRendererChain::kColor_DrawType; |
429 pr = this->getContext()->getPathRenderer(fClipTarget, pipelineBu
ilder, viewMatrix, | 429 pr = this->getContext()->getPathRenderer(fClipTarget, pipelineBu
ilder, viewMatrix, |
430 path, stroke, false, ty
pe); | 430 path, stroke, false, ty
pe); |
431 } | 431 } |
432 if (NULL == pr) { | 432 if (NULL == pr) { |
433 return false; | 433 return false; |
434 } | 434 } |
435 | 435 GrPathRenderer::DrawPathArgs args; |
436 pr->drawPath(fClipTarget, pipelineBuilder, color, viewMatrix, path,
stroke, | 436 args.fTarget = fClipTarget; |
437 element->isAA()); | 437 args.fResourceProvider = this->getContext()->resourceProvider(); |
| 438 args.fPipelineBuilder = pipelineBuilder; |
| 439 args.fColor = color; |
| 440 args.fViewMatrix = &viewMatrix; |
| 441 args.fPath = &path; |
| 442 args.fStroke = &stroke; |
| 443 args.fAntiAlias = element->isAA(); |
| 444 pr->drawPath(args); |
438 break; | 445 break; |
439 } | 446 } |
440 } | 447 } |
441 return true; | 448 return true; |
442 } | 449 } |
443 | 450 |
444 bool GrClipMaskManager::canStencilAndDrawElement(GrPipelineBuilder* pipelineBuil
der, | 451 bool GrClipMaskManager::canStencilAndDrawElement(GrPipelineBuilder* pipelineBuil
der, |
445 GrTexture* target, | 452 GrTexture* target, |
446 GrPathRenderer** pr, | 453 GrPathRenderer** pr, |
447 const SkClipStack::Element* ele
ment) { | 454 const SkClipStack::Element* ele
ment) { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 | 829 |
823 // We need this AGP until everything is in GrBatch | 830 // We need this AGP until everything is in GrBatch |
824 fClipTarget->drawSimpleRect(pipelineBuilder, | 831 fClipTarget->drawSimpleRect(pipelineBuilder, |
825 GrColor_WHITE, | 832 GrColor_WHITE, |
826 viewMatrix, | 833 viewMatrix, |
827 element->getRect()); | 834 element->getRect()); |
828 } else { | 835 } else { |
829 if (!clipPath.isEmpty()) { | 836 if (!clipPath.isEmpty()) { |
830 if (canRenderDirectToStencil) { | 837 if (canRenderDirectToStencil) { |
831 *pipelineBuilder.stencil() = gDrawToStencil; | 838 *pipelineBuilder.stencil() = gDrawToStencil; |
832 pr->drawPath(fClipTarget, &pipelineBuilder, GrColor_
WHITE, | 839 |
833 viewMatrix, clipPath, stroke, false); | 840 GrPathRenderer::DrawPathArgs args; |
| 841 args.fTarget = fClipTarget; |
| 842 args.fResourceProvider = this->getContext()->resourc
eProvider(); |
| 843 args.fPipelineBuilder = &pipelineBuilder; |
| 844 args.fColor = GrColor_WHITE; |
| 845 args.fViewMatrix = &viewMatrix; |
| 846 args.fPath = &clipPath; |
| 847 args.fStroke = &stroke; |
| 848 args.fAntiAlias = false; |
| 849 pr->drawPath(args); |
834 } else { | 850 } else { |
835 pr->stencilPath(fClipTarget, &pipelineBuilder, viewM
atrix, | 851 GrPathRenderer::StencilPathArgs args; |
836 clipPath, stroke); | 852 args.fTarget = fClipTarget; |
| 853 args.fResourceProvider = this->getContext()->resourc
eProvider(); |
| 854 args.fPipelineBuilder = &pipelineBuilder; |
| 855 args.fViewMatrix = &viewMatrix; |
| 856 args.fPath = &clipPath; |
| 857 args.fStroke = &stroke; |
| 858 pr->stencilPath(args); |
837 } | 859 } |
838 } | 860 } |
839 } | 861 } |
840 } | 862 } |
841 | 863 |
842 // now we modify the clip bit by rendering either the clip | 864 // now we modify the clip bit by rendering either the clip |
843 // element directly or a bounding rect of the entire clip. | 865 // element directly or a bounding rect of the entire clip. |
844 fClipMode = kModifyClip_StencilClipMode; | 866 fClipMode = kModifyClip_StencilClipMode; |
845 for (int p = 0; p < passes; ++p) { | 867 for (int p = 0; p < passes; ++p) { |
846 *pipelineBuilder.stencil() = stencilSettings[p]; | 868 *pipelineBuilder.stencil() = stencilSettings[p]; |
847 | 869 |
848 if (canDrawDirectToClip) { | 870 if (canDrawDirectToClip) { |
849 if (Element::kRect_Type == element->getType()) { | 871 if (Element::kRect_Type == element->getType()) { |
850 // We need this AGP until everything is in GrBatch | 872 // We need this AGP until everything is in GrBatch |
851 fClipTarget->drawSimpleRect(pipelineBuilder, | 873 fClipTarget->drawSimpleRect(pipelineBuilder, |
852 GrColor_WHITE, | 874 GrColor_WHITE, |
853 viewMatrix, | 875 viewMatrix, |
854 element->getRect()); | 876 element->getRect()); |
855 } else { | 877 } else { |
856 pr->drawPath(fClipTarget, &pipelineBuilder, GrColor_WHIT
E, | 878 GrPathRenderer::DrawPathArgs args; |
857 viewMatrix, clipPath, stroke, false); | 879 args.fTarget = fClipTarget; |
| 880 args.fResourceProvider = this->getContext()->resourcePro
vider(); |
| 881 args.fPipelineBuilder = &pipelineBuilder; |
| 882 args.fColor = GrColor_WHITE; |
| 883 args.fViewMatrix = &viewMatrix; |
| 884 args.fPath = &clipPath; |
| 885 args.fStroke = &stroke; |
| 886 args.fAntiAlias = false; |
| 887 pr->drawPath(args); |
858 } | 888 } |
859 } else { | 889 } else { |
860 // The view matrix is setup to do clip space -> stencil spac
e translation, so | 890 // The view matrix is setup to do clip space -> stencil spac
e translation, so |
861 // draw rect in clip space. | 891 // draw rect in clip space. |
862 fClipTarget->drawSimpleRect(pipelineBuilder, | 892 fClipTarget->drawSimpleRect(pipelineBuilder, |
863 GrColor_WHITE, | 893 GrColor_WHITE, |
864 viewMatrix, | 894 viewMatrix, |
865 SkRect::Make(clipSpaceIBounds)); | 895 SkRect::Make(clipSpaceIBounds)); |
866 } | 896 } |
867 } | 897 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 fAACache.purgeResources(); | 1151 fAACache.purgeResources(); |
1122 } | 1152 } |
1123 | 1153 |
1124 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, | 1154 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, |
1125 GrStencilSettings* settings) { | 1155 GrStencilSettings* settings) { |
1126 if (stencilAttachment) { | 1156 if (stencilAttachment) { |
1127 int stencilBits = stencilAttachment->bits(); | 1157 int stencilBits = stencilAttachment->bits(); |
1128 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1158 this->adjustStencilParams(settings, fClipMode, stencilBits); |
1129 } | 1159 } |
1130 } | 1160 } |
OLD | NEW |