| 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 return SkToBool(*pr); | 418 return SkToBool(*pr); |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 | 421 |
| 422 void GrClipMaskManager::mergeMask(GrDrawState* drawState, | 422 void GrClipMaskManager::mergeMask(GrDrawState* drawState, |
| 423 GrTexture* dstMask, | 423 GrTexture* dstMask, |
| 424 GrTexture* srcMask, | 424 GrTexture* srcMask, |
| 425 SkRegion::Op op, | 425 SkRegion::Op op, |
| 426 const SkIRect& dstBound, | 426 const SkIRect& dstBound, |
| 427 const SkIRect& srcBound) { | 427 const SkIRect& srcBound) { |
| 428 SkAssertResult(drawState->setIdentityViewMatrix()); | |
| 429 | |
| 430 drawState->setRenderTarget(dstMask->asRenderTarget()); | 428 drawState->setRenderTarget(dstMask->asRenderTarget()); |
| 431 | 429 |
| 432 // We want to invert the coverage here | 430 // We want to invert the coverage here |
| 433 set_coverage_drawing_xpf(op, false, drawState); | 431 set_coverage_drawing_xpf(op, false, drawState); |
| 434 | 432 |
| 435 SkMatrix sampleM; | 433 SkMatrix sampleM; |
| 436 sampleM.setIDiv(srcMask->width(), srcMask->height()); | 434 sampleM.setIDiv(srcMask->width(), srcMask->height()); |
| 437 | 435 |
| 438 drawState->addCoverageProcessor( | 436 drawState->addCoverageProcessor( |
| 439 GrTextureDomainEffect::Create(srcMask, | 437 GrTextureDomainEffect::Create(srcMask, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 0xffff); | 597 0xffff); |
| 600 drawState.setStencil(kStencilInElement); | 598 drawState.setStencil(kStencilInElement); |
| 601 set_coverage_drawing_xpf(op, invert, &drawState); | 599 set_coverage_drawing_xpf(op, invert, &drawState); |
| 602 } | 600 } |
| 603 | 601 |
| 604 if (!this->drawElement(&drawState, dst, element, pr)) { | 602 if (!this->drawElement(&drawState, dst, element, pr)) { |
| 605 fAACache.reset(); | 603 fAACache.reset(); |
| 606 return NULL; | 604 return NULL; |
| 607 } | 605 } |
| 608 | 606 |
| 609 GrDrawState backgroundDrawState(translate); | 607 if (useTemp) { |
| 610 backgroundDrawState.enableState(GrDrawState::kClip_StateBit); | 608 GrDrawState backgroundDrawState; |
| 611 backgroundDrawState.setRenderTarget(result->asRenderTarget()); | 609 backgroundDrawState.enableState(GrDrawState::kClip_StateBit); |
| 610 backgroundDrawState.setRenderTarget(result->asRenderTarget()); |
| 612 | 611 |
| 613 if (useTemp) { | |
| 614 // Now draw into the accumulator using the real operation and th
e temp buffer as a | 612 // Now draw into the accumulator using the real operation and th
e temp buffer as a |
| 615 // texture | 613 // texture |
| 616 this->mergeMask(&backgroundDrawState, | 614 this->mergeMask(&backgroundDrawState, |
| 617 result, | 615 result, |
| 618 temp, | 616 temp, |
| 619 op, | 617 op, |
| 620 maskSpaceIBounds, | 618 maskSpaceIBounds, |
| 621 maskSpaceElementIBounds); | 619 maskSpaceElementIBounds); |
| 622 } else { | 620 } else { |
| 621 GrDrawState backgroundDrawState(translate); |
| 622 backgroundDrawState.enableState(GrDrawState::kClip_StateBit); |
| 623 backgroundDrawState.setRenderTarget(result->asRenderTarget()); |
| 624 |
| 623 set_coverage_drawing_xpf(op, !invert, &backgroundDrawState); | 625 set_coverage_drawing_xpf(op, !invert, &backgroundDrawState); |
| 624 // Draw to the exterior pixels (those with a zero stencil value)
. | 626 // Draw to the exterior pixels (those with a zero stencil value)
. |
| 625 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, | 627 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, |
| 626 kZero_StencilOp, | 628 kZero_StencilOp, |
| 627 kZero_StencilOp, | 629 kZero_StencilOp, |
| 628 kEqual_StencilFunc, | 630 kEqual_StencilFunc, |
| 629 0xffff, | 631 0xffff, |
| 630 0x0000, | 632 0x0000, |
| 631 0xffff); | 633 0xffff); |
| 632 backgroundDrawState.setStencil(kDrawOutsideElement); | 634 backgroundDrawState.setStencil(kDrawOutsideElement); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 } | 1065 } |
| 1064 | 1066 |
| 1065 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, | 1067 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, |
| 1066 GrStencilSettings* settings) { | 1068 GrStencilSettings* settings) { |
| 1067 // TODO: dynamically attach a stencil buffer | 1069 // TODO: dynamically attach a stencil buffer |
| 1068 if (stencilBuffer) { | 1070 if (stencilBuffer) { |
| 1069 int stencilBits = stencilBuffer->bits(); | 1071 int stencilBits = stencilBuffer->bits(); |
| 1070 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1072 this->adjustStencilParams(settings, fClipMode, stencilBits); |
| 1071 } | 1073 } |
| 1072 } | 1074 } |
| OLD | NEW |