OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 #include "GrClipMaskManager.h" | 9 #include "GrClipMaskManager.h" |
10 #include "GrAAConvexPathRenderer.h" | 10 #include "GrAAConvexPathRenderer.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 // of whether it would invoke the GrSoftwarePathRenderer. | 90 // of whether it would invoke the GrSoftwarePathRenderer. |
91 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); | 91 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); |
92 | 92 |
93 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) { | 93 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) { |
94 const Element* element = iter.get(); | 94 const Element* element = iter.get(); |
95 // rects can always be drawn directly w/o using the software path | 95 // rects can always be drawn directly w/o using the software path |
96 // Skip rrects once we're drawing them directly. | 96 // Skip rrects once we're drawing them directly. |
97 if (Element::kRect_Type != element->getType()) { | 97 if (Element::kRect_Type != element->getType()) { |
98 SkPath path; | 98 SkPath path; |
99 element->asPath(&path); | 99 element->asPath(&path); |
100 path.setIsVolatile(true); | |
bsalomon
2014/10/24 17:29:18
Is it not already volatile since it comes from the
jvanverth1
2014/10/24 17:36:30
I'm not sure when it would get set as volatile in
| |
100 if (path_needs_SW_renderer(this->getContext(), fGpu, path, stroke, e lement->isAA())) { | 101 if (path_needs_SW_renderer(this->getContext(), fGpu, path, stroke, e lement->isAA())) { |
101 return true; | 102 return true; |
102 } | 103 } |
103 } | 104 } |
104 } | 105 } |
105 return false; | 106 return false; |
106 } | 107 } |
107 | 108 |
108 bool GrClipMaskManager::installClipEffects(const GrReducedClip::ElementList& ele ments, | 109 bool GrClipMaskManager::installClipEffects(const GrReducedClip::ElementList& ele ments, |
109 GrDrawState::AutoRestoreEffects* are, | 110 GrDrawState::AutoRestoreEffects* are, |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 GrDrawState* drawState = fGpu->drawState(); | 440 GrDrawState* drawState = fGpu->drawState(); |
440 drawState->setRenderTarget(target->asRenderTarget()); | 441 drawState->setRenderTarget(target->asRenderTarget()); |
441 | 442 |
442 if (Element::kRect_Type == element->getType()) { | 443 if (Element::kRect_Type == element->getType()) { |
443 return true; | 444 return true; |
444 } else { | 445 } else { |
445 // We shouldn't get here with an empty clip element. | 446 // We shouldn't get here with an empty clip element. |
446 SkASSERT(Element::kEmpty_Type != element->getType()); | 447 SkASSERT(Element::kEmpty_Type != element->getType()); |
447 SkPath path; | 448 SkPath path; |
448 element->asPath(&path); | 449 element->asPath(&path); |
450 path.setIsVolatile(true); | |
449 if (path.isInverseFillType()) { | 451 if (path.isInverseFillType()) { |
450 path.toggleInverseFillType(); | 452 path.toggleInverseFillType(); |
451 } | 453 } |
452 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); | 454 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); |
453 GrPathRendererChain::DrawType type = element->isAA() ? | 455 GrPathRendererChain::DrawType type = element->isAA() ? |
454 GrPathRendererChain::kStencilAndColorAntiAlias_DrawType : | 456 GrPathRendererChain::kStencilAndColorAntiAlias_DrawType : |
455 GrPathRendererChain::kStencilAndColor_DrawType; | 457 GrPathRendererChain::kStencilAndColor_DrawType; |
456 *pr = this->getContext()->getPathRenderer(path, stroke, fGpu, false, typ e); | 458 *pr = this->getContext()->getPathRenderer(path, stroke, fGpu, false, typ e); |
457 return SkToBool(*pr); | 459 return SkToBool(*pr); |
458 } | 460 } |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 | 761 |
760 SkRegion::Op op = element->getOp(); | 762 SkRegion::Op op = element->getOp(); |
761 | 763 |
762 GrPathRenderer* pr = NULL; | 764 GrPathRenderer* pr = NULL; |
763 SkPath clipPath; | 765 SkPath clipPath; |
764 if (Element::kRect_Type == element->getType()) { | 766 if (Element::kRect_Type == element->getType()) { |
765 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; | 767 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; |
766 fillInverted = false; | 768 fillInverted = false; |
767 } else { | 769 } else { |
768 element->asPath(&clipPath); | 770 element->asPath(&clipPath); |
771 clipPath.setIsVolatile(true); | |
769 fillInverted = clipPath.isInverseFillType(); | 772 fillInverted = clipPath.isInverseFillType(); |
770 if (fillInverted) { | 773 if (fillInverted) { |
771 clipPath.toggleInverseFillType(); | 774 clipPath.toggleInverseFillType(); |
772 } | 775 } |
773 pr = this->getContext()->getPathRenderer(clipPath, | 776 pr = this->getContext()->getPathRenderer(clipPath, |
774 stroke, | 777 stroke, |
775 fGpu, | 778 fGpu, |
776 false, | 779 false, |
777 GrPathRendererChain::kS tencilOnly_DrawType, | 780 GrPathRendererChain::kS tencilOnly_DrawType, |
778 &stencilSupport); | 781 &stencilSupport); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 // but leave the pixels inside the geometry alone. For reverse diffe rence we invert all | 1076 // but leave the pixels inside the geometry alone. For reverse diffe rence we invert all |
1074 // the pixels before clearing the ones outside the geometry. | 1077 // the pixels before clearing the ones outside the geometry. |
1075 if (SkRegion::kReverseDifference_Op == op) { | 1078 if (SkRegion::kReverseDifference_Op == op) { |
1076 SkRect temp = SkRect::Make(clipSpaceIBounds); | 1079 SkRect temp = SkRect::Make(clipSpaceIBounds); |
1077 // invert the entire scene | 1080 // invert the entire scene |
1078 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF); | 1081 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF); |
1079 } | 1082 } |
1080 | 1083 |
1081 SkPath clipPath; | 1084 SkPath clipPath; |
1082 element->asPath(&clipPath); | 1085 element->asPath(&clipPath); |
1086 clipPath.setIsVolatile(true); | |
1083 clipPath.toggleInverseFillType(); | 1087 clipPath.toggleInverseFillType(); |
1084 helper.draw(clipPath, stroke, SkRegion::kReplace_Op, element->isAA() , 0x00); | 1088 helper.draw(clipPath, stroke, SkRegion::kReplace_Op, element->isAA() , 0x00); |
1085 | 1089 |
1086 continue; | 1090 continue; |
1087 } | 1091 } |
1088 | 1092 |
1089 // The other ops (union, xor, diff) only affect pixels inside | 1093 // The other ops (union, xor, diff) only affect pixels inside |
1090 // the geometry so they can just be drawn normally | 1094 // the geometry so they can just be drawn normally |
1091 if (Element::kRect_Type == element->getType()) { | 1095 if (Element::kRect_Type == element->getType()) { |
1092 helper.draw(element->getRect(), op, element->isAA(), 0xFF); | 1096 helper.draw(element->getRect(), op, element->isAA(), 0xFF); |
1093 } else { | 1097 } else { |
1094 SkPath path; | 1098 SkPath path; |
1095 element->asPath(&path); | 1099 element->asPath(&path); |
1100 path.setIsVolatile(true); | |
1096 helper.draw(path, stroke, op, element->isAA(), 0xFF); | 1101 helper.draw(path, stroke, op, element->isAA(), 0xFF); |
1097 } | 1102 } |
1098 } | 1103 } |
1099 | 1104 |
1100 // Allocate clip mask texture | 1105 // Allocate clip mask texture |
1101 result = this->allocMaskTexture(elementsGenID, clipSpaceIBounds, true); | 1106 result = this->allocMaskTexture(elementsGenID, clipSpaceIBounds, true); |
1102 if (NULL == result) { | 1107 if (NULL == result) { |
1103 fAACache.reset(); | 1108 fAACache.reset(); |
1104 return NULL; | 1109 return NULL; |
1105 } | 1110 } |
(...skipping 30 matching lines...) Expand all Loading... | |
1136 | 1141 |
1137 // TODO: dynamically attach a stencil buffer | 1142 // TODO: dynamically attach a stencil buffer |
1138 int stencilBits = 0; | 1143 int stencilBits = 0; |
1139 GrStencilBuffer* stencilBuffer = | 1144 GrStencilBuffer* stencilBuffer = |
1140 drawState.getRenderTarget()->getStencilBuffer(); | 1145 drawState.getRenderTarget()->getStencilBuffer(); |
1141 if (stencilBuffer) { | 1146 if (stencilBuffer) { |
1142 stencilBits = stencilBuffer->bits(); | 1147 stencilBits = stencilBuffer->bits(); |
1143 this->adjustStencilParams(settings, clipMode, stencilBits); | 1148 this->adjustStencilParams(settings, clipMode, stencilBits); |
1144 } | 1149 } |
1145 } | 1150 } |
OLD | NEW |