Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: src/gpu/GrClipMaskManager.cpp

Issue 1957363002: Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
Patch Set: Fix issue where hairlines were going to MSAAPathRenderer Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "GrCaps.h" 9 #include "GrCaps.h"
10 #include "GrDrawingManager.h" 10 #include "GrDrawingManager.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } else { 78 } else {
79 // We shouldn't get here with an empty clip element. 79 // We shouldn't get here with an empty clip element.
80 SkASSERT(Element::kEmpty_Type != element->getType()); 80 SkASSERT(Element::kEmpty_Type != element->getType());
81 81
82 // the gpu alpha mask will draw the inverse paths as non-inverse to a te mp buffer 82 // the gpu alpha mask will draw the inverse paths as non-inverse to a te mp buffer
83 SkPath path; 83 SkPath path;
84 element->asPath(&path); 84 element->asPath(&path);
85 if (path.isInverseFillType()) { 85 if (path.isInverseFillType()) {
86 path.toggleInverseFillType(); 86 path.toggleInverseFillType();
87 } 87 }
88 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
89 88
90 GrPathRendererChain::DrawType type; 89 GrPathRendererChain::DrawType type;
91 90
92 if (needsStencil) { 91 if (needsStencil) {
93 type = element->isAA() 92 type = element->isAA()
94 ? GrPathRendererChain::kStencilAndColorAntiAlias_Dra wType 93 ? GrPathRendererChain::kStencilAndColorAntiAlias_Dra wType
95 : GrPathRendererChain::kStencilAndColor_DrawType; 94 : GrPathRendererChain::kStencilAndColor_DrawType;
96 } else { 95 } else {
97 type = element->isAA() 96 type = element->isAA()
98 ? GrPathRendererChain::kColorAntiAlias_DrawType 97 ? GrPathRendererChain::kColorAntiAlias_DrawType
99 : GrPathRendererChain::kColor_DrawType; 98 : GrPathRendererChain::kColor_DrawType;
100 } 99 }
101 100
102 GrPathRenderer::CanDrawPathArgs canDrawArgs; 101 GrPathRenderer::CanDrawPathArgs canDrawArgs;
103 canDrawArgs.fShaderCaps = context->caps()->shaderCaps(); 102 canDrawArgs.fShaderCaps = context->caps()->shaderCaps();
104 canDrawArgs.fViewMatrix = &viewMatrix; 103 canDrawArgs.fViewMatrix = &viewMatrix;
105 canDrawArgs.fPath = &path; 104 canDrawArgs.fPath = &path;
106 canDrawArgs.fStroke = &stroke; 105 canDrawArgs.fStyle = &GrStyle::SimpleFill();
107 canDrawArgs.fAntiAlias = element->isAA(); 106 canDrawArgs.fAntiAlias = element->isAA();
108 canDrawArgs.fIsStencilDisabled = isStencilDisabled; 107 canDrawArgs.fIsStencilDisabled = isStencilDisabled;
109 canDrawArgs.fIsStencilBufferMSAA = rt->isStencilBufferMultisampled(); 108 canDrawArgs.fIsStencilBufferMSAA = rt->isStencilBufferMultisampled();
110 109
111 // the 'false' parameter disallows use of the SW path renderer 110 // the 'false' parameter disallows use of the SW path renderer
112 GrPathRenderer* pr = context->drawingManager()->getPathRenderer(canDrawA rgs, false, type); 111 GrPathRenderer* pr = context->drawingManager()->getPathRenderer(canDrawA rgs, false, type);
113 if (prOut) { 112 if (prOut) {
114 *prOut = pr; 113 *prOut = pr;
115 } 114 }
116 return SkToBool(!pr); 115 return SkToBool(!pr);
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 case Element::kRect_Type: 583 case Element::kRect_Type:
585 dc->drawRect(clip, paint, viewMatrix, element->getRect()); 584 dc->drawRect(clip, paint, viewMatrix, element->getRect());
586 break; 585 break;
587 default: { 586 default: {
588 SkPath path; 587 SkPath path;
589 element->asPath(&path); 588 element->asPath(&path);
590 if (path.isInverseFillType()) { 589 if (path.isInverseFillType()) {
591 path.toggleInverseFillType(); 590 path.toggleInverseFillType();
592 } 591 }
593 592
594 dc->drawPath(clip, paint, viewMatrix, path, GrStrokeInfo::FillInfo() ); 593 dc->drawPath(clip, paint, viewMatrix, path, GrStyle::SimpleFill());
595 break; 594 break;
596 } 595 }
597 } 596 }
598 } 597 }
599 598
600 //////////////////////////////////////////////////////////////////////////////// 599 ////////////////////////////////////////////////////////////////////////////////
601 // Create a 8-bit clip mask in alpha 600 // Create a 8-bit clip mask in alpha
602 601
603 static void GetClipMaskKey(int32_t clipGenID, const SkIRect& bounds, GrUniqueKey * key) { 602 static void GetClipMaskKey(int32_t clipGenID, const SkIRect& bounds, GrUniqueKey * key) {
604 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); 603 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 777 }
779 778
780 bool fillInverted = false; 779 bool fillInverted = false;
781 // enabled at bottom of loop 780 // enabled at bottom of loop
782 fClipMode = kIgnoreClip_StencilClipMode; 781 fClipMode = kIgnoreClip_StencilClipMode;
783 782
784 // This will be used to determine whether the clip shape can be rend ered into the 783 // This will be used to determine whether the clip shape can be rend ered into the
785 // stencil with arbitrary stencil settings. 784 // stencil with arbitrary stencil settings.
786 GrPathRenderer::StencilSupport stencilSupport; 785 GrPathRenderer::StencilSupport stencilSupport;
787 786
788 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
789 SkRegion::Op op = element->getOp(); 787 SkRegion::Op op = element->getOp();
790 788
791 GrPathRenderer* pr = nullptr; 789 GrPathRenderer* pr = nullptr;
792 SkPath clipPath; 790 SkPath clipPath;
793 if (Element::kRect_Type == element->getType()) { 791 if (Element::kRect_Type == element->getType()) {
794 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; 792 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport;
795 fillInverted = false; 793 fillInverted = false;
796 } else { 794 } else {
797 element->asPath(&clipPath); 795 element->asPath(&clipPath);
798 fillInverted = clipPath.isInverseFillType(); 796 fillInverted = clipPath.isInverseFillType();
799 if (fillInverted) { 797 if (fillInverted) {
800 clipPath.toggleInverseFillType(); 798 clipPath.toggleInverseFillType();
801 } 799 }
802 800
803 SkASSERT(pipelineBuilder.getStencil().isDisabled()); 801 SkASSERT(pipelineBuilder.getStencil().isDisabled());
804 802
805 GrPathRenderer::CanDrawPathArgs canDrawArgs; 803 GrPathRenderer::CanDrawPathArgs canDrawArgs;
806 canDrawArgs.fShaderCaps = this->getContext()->caps()->shaderCaps (); 804 canDrawArgs.fShaderCaps = this->getContext()->caps()->shaderCaps ();
807 canDrawArgs.fViewMatrix = &viewMatrix; 805 canDrawArgs.fViewMatrix = &viewMatrix;
808 canDrawArgs.fPath = &clipPath; 806 canDrawArgs.fPath = &clipPath;
809 canDrawArgs.fStroke = &stroke; 807 canDrawArgs.fStyle = &GrStyle::SimpleFill();
810 canDrawArgs.fAntiAlias = false; 808 canDrawArgs.fAntiAlias = false;
811 canDrawArgs.fIsStencilDisabled = pipelineBuilder.getStencil().is Disabled(); 809 canDrawArgs.fIsStencilDisabled = pipelineBuilder.getStencil().is Disabled();
812 canDrawArgs.fIsStencilBufferMSAA = rt->isStencilBufferMultisampl ed(); 810 canDrawArgs.fIsStencilBufferMSAA = rt->isStencilBufferMultisampl ed();
813 811
814 pr = this->getContext()->drawingManager()->getPathRenderer(canDr awArgs, false, 812 pr = this->getContext()->drawingManager()->getPathRenderer(canDr awArgs, false,
815 GrPat hRendererChain::kStencilOnly_DrawType, 813 GrPat hRendererChain::kStencilOnly_DrawType,
816 &sten cilSupport); 814 &sten cilSupport);
817 if (nullptr == pr) { 815 if (nullptr == pr) {
818 return false; 816 return false;
819 } 817 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 if (canRenderDirectToStencil) { 852 if (canRenderDirectToStencil) {
855 *pipelineBuilder.stencil() = kDrawToStencil; 853 *pipelineBuilder.stencil() = kDrawToStencil;
856 854
857 GrPathRenderer::DrawPathArgs args; 855 GrPathRenderer::DrawPathArgs args;
858 args.fTarget = fDrawTarget; 856 args.fTarget = fDrawTarget;
859 args.fResourceProvider = this->getContext()->resourc eProvider(); 857 args.fResourceProvider = this->getContext()->resourc eProvider();
860 args.fPipelineBuilder = &pipelineBuilder; 858 args.fPipelineBuilder = &pipelineBuilder;
861 args.fColor = GrColor_WHITE; 859 args.fColor = GrColor_WHITE;
862 args.fViewMatrix = &viewMatrix; 860 args.fViewMatrix = &viewMatrix;
863 args.fPath = &clipPath; 861 args.fPath = &clipPath;
864 args.fStroke = &stroke; 862 args.fStyle = &GrStyle::SimpleFill();
865 args.fAntiAlias = false; 863 args.fAntiAlias = false;
866 args.fGammaCorrect = false; 864 args.fGammaCorrect = false;
867 pr->drawPath(args); 865 pr->drawPath(args);
868 } else { 866 } else {
869 GrPathRenderer::StencilPathArgs args; 867 GrPathRenderer::StencilPathArgs args;
870 args.fTarget = fDrawTarget; 868 args.fTarget = fDrawTarget;
871 args.fResourceProvider = this->getContext()->resourc eProvider(); 869 args.fResourceProvider = this->getContext()->resourc eProvider();
872 args.fPipelineBuilder = &pipelineBuilder; 870 args.fPipelineBuilder = &pipelineBuilder;
873 args.fViewMatrix = &viewMatrix; 871 args.fViewMatrix = &viewMatrix;
874 args.fPath = &clipPath; 872 args.fPath = &clipPath;
(...skipping 14 matching lines...) Expand all
889 draw_non_aa_rect(fDrawTarget, pipelineBuilder, GrColor_W HITE, viewMatrix, 887 draw_non_aa_rect(fDrawTarget, pipelineBuilder, GrColor_W HITE, viewMatrix,
890 element->getRect()); 888 element->getRect());
891 } else { 889 } else {
892 GrPathRenderer::DrawPathArgs args; 890 GrPathRenderer::DrawPathArgs args;
893 args.fTarget = fDrawTarget; 891 args.fTarget = fDrawTarget;
894 args.fResourceProvider = this->getContext()->resourcePro vider(); 892 args.fResourceProvider = this->getContext()->resourcePro vider();
895 args.fPipelineBuilder = &pipelineBuilder; 893 args.fPipelineBuilder = &pipelineBuilder;
896 args.fColor = GrColor_WHITE; 894 args.fColor = GrColor_WHITE;
897 args.fViewMatrix = &viewMatrix; 895 args.fViewMatrix = &viewMatrix;
898 args.fPath = &clipPath; 896 args.fPath = &clipPath;
899 args.fStroke = &stroke; 897 args.fStyle = &GrStyle::SimpleFill();
900 args.fAntiAlias = false; 898 args.fAntiAlias = false;
901 args.fGammaCorrect = false; 899 args.fGammaCorrect = false;
902 pr->drawPath(args); 900 pr->drawPath(args);
903 } 901 }
904 } else { 902 } else {
905 // The view matrix is setup to do clip space -> stencil spac e translation, so 903 // The view matrix is setup to do clip space -> stencil spac e translation, so
906 // draw rect in clip space. 904 // draw rect in clip space.
907 draw_non_aa_rect(fDrawTarget, pipelineBuilder, GrColor_WHITE , viewMatrix, 905 draw_non_aa_rect(fDrawTarget, pipelineBuilder, GrColor_WHITE , viewMatrix,
908 SkRect::Make(clipSpaceIBounds)); 906 SkRect::Make(clipSpaceIBounds));
909 } 907 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 1091
1094 GrSWMaskHelper helper(context); 1092 GrSWMaskHelper helper(context);
1095 1093
1096 // Set the matrix so that rendered clip elements are transformed to mask spa ce from clip 1094 // Set the matrix so that rendered clip elements are transformed to mask spa ce from clip
1097 // space. 1095 // space.
1098 SkMatrix translate; 1096 SkMatrix translate;
1099 translate.setTranslate(clipToMaskOffset); 1097 translate.setTranslate(clipToMaskOffset);
1100 1098
1101 helper.init(maskSpaceIBounds, &translate, false); 1099 helper.init(maskSpaceIBounds, &translate, false);
1102 helper.clear(GrReducedClip::kAllIn_InitialState == initialState ? 0xFF : 0x0 0); 1100 helper.clear(GrReducedClip::kAllIn_InitialState == initialState ? 0xFF : 0x0 0);
1103 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
1104 1101
1105 for (GrReducedClip::ElementList::Iter iter(elements.headIter()) ; iter.get() ; iter.next()) { 1102 for (GrReducedClip::ElementList::Iter iter(elements.headIter()) ; iter.get() ; iter.next()) {
1106 const Element* element = iter.get(); 1103 const Element* element = iter.get();
1107 SkRegion::Op op = element->getOp(); 1104 SkRegion::Op op = element->getOp();
1108 1105
1109 if (SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) { 1106 if (SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) {
1110 // Intersect and reverse difference require modifying pixels outside of the geometry 1107 // Intersect and reverse difference require modifying pixels outside of the geometry
1111 // that is being "drawn". In both cases we erase all the pixels outs ide of the geometry 1108 // that is being "drawn". In both cases we erase all the pixels outs ide of the geometry
1112 // but leave the pixels inside the geometry alone. For reverse diffe rence we invert all 1109 // but leave the pixels inside the geometry alone. For reverse diffe rence we invert all
1113 // the pixels before clearing the ones outside the geometry. 1110 // the pixels before clearing the ones outside the geometry.
1114 if (SkRegion::kReverseDifference_Op == op) { 1111 if (SkRegion::kReverseDifference_Op == op) {
1115 SkRect temp = SkRect::Make(clipSpaceIBounds); 1112 SkRect temp = SkRect::Make(clipSpaceIBounds);
1116 // invert the entire scene 1113 // invert the entire scene
1117 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF); 1114 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF);
1118 } 1115 }
1119 SkPath clipPath; 1116 SkPath clipPath;
1120 element->asPath(&clipPath); 1117 element->asPath(&clipPath);
1121 clipPath.toggleInverseFillType(); 1118 clipPath.toggleInverseFillType();
1122 helper.draw(clipPath, stroke, SkRegion::kReplace_Op, element->isAA() , 0x00); 1119 helper.draw(clipPath, GrStyle::SimpleFill(), SkRegion::kReplace_Op, element->isAA(),
1120 0x00);
1123 continue; 1121 continue;
1124 } 1122 }
1125 1123
1126 // The other ops (union, xor, diff) only affect pixels inside 1124 // The other ops (union, xor, diff) only affect pixels inside
1127 // the geometry so they can just be drawn normally 1125 // the geometry so they can just be drawn normally
1128 if (Element::kRect_Type == element->getType()) { 1126 if (Element::kRect_Type == element->getType()) {
1129 helper.draw(element->getRect(), op, element->isAA(), 0xFF); 1127 helper.draw(element->getRect(), op, element->isAA(), 0xFF);
1130 } else { 1128 } else {
1131 SkPath path; 1129 SkPath path;
1132 element->asPath(&path); 1130 element->asPath(&path);
1133 helper.draw(path, stroke, op, element->isAA(), 0xFF); 1131 helper.draw(path, GrStyle::SimpleFill(), op, element->isAA(), 0xFF);
1134 } 1132 }
1135 } 1133 }
1136 1134
1137 // Allocate clip mask texture 1135 // Allocate clip mask texture
1138 GrSurfaceDesc desc; 1136 GrSurfaceDesc desc;
1139 desc.fWidth = clipSpaceIBounds.width(); 1137 desc.fWidth = clipSpaceIBounds.width();
1140 desc.fHeight = clipSpaceIBounds.height(); 1138 desc.fHeight = clipSpaceIBounds.height();
1141 desc.fConfig = kAlpha_8_GrPixelConfig; 1139 desc.fConfig = kAlpha_8_GrPixelConfig;
1142 1140
1143 GrTexture* result = context->resourceProvider()->createApproxTexture(desc, 0 ); 1141 GrTexture* result = context->resourceProvider()->createApproxTexture(desc, 0 );
1144 if (!result) { 1142 if (!result) {
1145 return nullptr; 1143 return nullptr;
1146 } 1144 }
1147 result->resourcePriv().setUniqueKey(key); 1145 result->resourcePriv().setUniqueKey(key);
1148 1146
1149 helper.toTexture(result); 1147 helper.toTexture(result);
1150 1148
1151 return result; 1149 return result;
1152 } 1150 }
1153 1151
1154 //////////////////////////////////////////////////////////////////////////////// 1152 ////////////////////////////////////////////////////////////////////////////////
1155 1153
1156 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment, 1154 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment,
1157 GrStencilSettings* settings) { 1155 GrStencilSettings* settings) {
1158 if (stencilAttachment) { 1156 if (stencilAttachment) {
1159 int stencilBits = stencilAttachment->bits(); 1157 int stencilBits = stencilAttachment->bits();
1160 this->adjustStencilParams(settings, fClipMode, stencilBits); 1158 this->adjustStencilParams(settings, fClipMode, stencilBits);
1161 } 1159 }
1162 } 1160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698