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 "GrCaps.h" | 9 #include "GrCaps.h" |
10 #include "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 // pass must not set values outside of this bounds or stencil values outside
the rect won't be | 582 // pass must not set values outside of this bounds or stencil values outside
the rect won't be |
583 // cleared. | 583 // cleared. |
584 const GrClip clip(maskSpaceIBounds); | 584 const GrClip clip(maskSpaceIBounds); |
585 | 585 |
586 // walk through each clip element and perform its set op | 586 // walk through each clip element and perform its set op |
587 for (GrReducedClip::ElementList::Iter iter = elements.headIter(); iter.get()
; iter.next()) { | 587 for (GrReducedClip::ElementList::Iter iter = elements.headIter(); iter.get()
; iter.next()) { |
588 const Element* element = iter.get(); | 588 const Element* element = iter.get(); |
589 SkRegion::Op op = element->getOp(); | 589 SkRegion::Op op = element->getOp(); |
590 bool invert = element->isInverseFilled(); | 590 bool invert = element->isInverseFilled(); |
591 if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDiffere
nce_Op == op) { | 591 if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDiffere
nce_Op == op) { |
592 GrPipelineBuilder pipelineBuilder; | |
593 | 592 |
594 pipelineBuilder.setClip(clip); | |
595 pipelineBuilder.setRenderTarget(texture->asRenderTarget()); | |
596 | |
597 SkASSERT(pipelineBuilder.getStencil().isDisabled()); | |
598 GrPathRenderer* pr = GetPathRenderer(this->getContext(), | 593 GrPathRenderer* pr = GetPathRenderer(this->getContext(), |
599 texture, translate, element); | 594 texture, translate, element); |
600 if (Element::kRect_Type != element->getType() && !pr) { | 595 if (Element::kRect_Type != element->getType() && !pr) { |
601 // useSWOnlyPath should now filter out all cases where gpu-side
mask merging would | 596 // useSWOnlyPath should now filter out all cases where gpu-side
mask merging would |
602 // be performed (i.e., pr would be NULL for a non-rect path). Se
e skbug.com/4519 | 597 // be performed (i.e., pr would be NULL for a non-rect path). Se
e skbug.com/4519 |
603 // for rationale and details. | 598 // for rationale and details. |
604 SkASSERT(0); | 599 SkASSERT(0); |
605 continue; | 600 continue; |
606 } | 601 } |
607 | 602 |
608 // draw directly into the result with the stencil set to make the pi
xels affected | 603 { |
609 // by the clip shape be non-zero. | 604 GrPipelineBuilder pipelineBuilder; |
610 GR_STATIC_CONST_SAME_STENCIL(kStencilInElement, | |
611 kReplace_StencilOp, | |
612 kReplace_StencilOp, | |
613 kAlways_StencilFunc, | |
614 0xffff, | |
615 0xffff, | |
616 0xffff); | |
617 pipelineBuilder.setStencil(kStencilInElement); | |
618 set_coverage_drawing_xpf(op, invert, &pipelineBuilder); | |
619 | 605 |
620 if (!this->drawElement(&pipelineBuilder, translate, texture, element
, pr)) { | 606 pipelineBuilder.setClip(clip); |
621 texture->resourcePriv().removeUniqueKey(); | 607 pipelineBuilder.setRenderTarget(texture->asRenderTarget()); |
622 return nullptr; | 608 SkASSERT(pipelineBuilder.getStencil().isDisabled()); |
| 609 |
| 610 // draw directly into the result with the stencil set to make th
e pixels affected |
| 611 // by the clip shape be non-zero. |
| 612 GR_STATIC_CONST_SAME_STENCIL(kStencilInElement, |
| 613 kReplace_StencilOp, |
| 614 kReplace_StencilOp, |
| 615 kAlways_StencilFunc, |
| 616 0xffff, |
| 617 0xffff, |
| 618 0xffff); |
| 619 pipelineBuilder.setStencil(kStencilInElement); |
| 620 set_coverage_drawing_xpf(op, invert, &pipelineBuilder); |
| 621 |
| 622 if (!this->drawElement(&pipelineBuilder, translate, texture, ele
ment, pr)) { |
| 623 texture->resourcePriv().removeUniqueKey(); |
| 624 return nullptr; |
| 625 } |
623 } | 626 } |
624 | 627 |
625 { | 628 { |
626 GrPipelineBuilder backgroundPipelineBuilder; | 629 GrPipelineBuilder backgroundPipelineBuilder; |
627 backgroundPipelineBuilder.setRenderTarget(texture->asRenderTarge
t()); | 630 backgroundPipelineBuilder.setRenderTarget(texture->asRenderTarge
t()); |
628 | 631 |
629 set_coverage_drawing_xpf(op, !invert, &backgroundPipelineBuilder
); | 632 set_coverage_drawing_xpf(op, !invert, &backgroundPipelineBuilder
); |
630 // Draw to the exterior pixels (those with a zero stencil value)
. | 633 // Draw to the exterior pixels (those with a zero stencil value)
. |
631 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, | 634 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, |
632 kZero_StencilOp, | 635 kZero_StencilOp, |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 | 1096 |
1094 //////////////////////////////////////////////////////////////////////////////// | 1097 //////////////////////////////////////////////////////////////////////////////// |
1095 | 1098 |
1096 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, | 1099 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, |
1097 GrStencilSettings* settings) { | 1100 GrStencilSettings* settings) { |
1098 if (stencilAttachment) { | 1101 if (stencilAttachment) { |
1099 int stencilBits = stencilAttachment->bits(); | 1102 int stencilBits = stencilAttachment->bits(); |
1100 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1103 this->adjustStencilParams(settings, fClipMode, stencilBits); |
1101 } | 1104 } |
1102 } | 1105 } |
OLD | NEW |