| 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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 desc.fConfig = kRGBA_8888_GrPixelConfig; | 625 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 626 } | 626 } |
| 627 | 627 |
| 628 SkAutoTUnref<GrTexture> texture(resourceProvider->createApproxTexture(desc,
0)); | 628 SkAutoTUnref<GrTexture> texture(resourceProvider->createApproxTexture(desc,
0)); |
| 629 if (!texture) { | 629 if (!texture) { |
| 630 return nullptr; | 630 return nullptr; |
| 631 } | 631 } |
| 632 | 632 |
| 633 texture->resourcePriv().setUniqueKey(key); | 633 texture->resourcePriv().setUniqueKey(key); |
| 634 | 634 |
| 635 SkAutoTUnref<GrDrawContext> dc(context->drawContext(texture->asRenderTarget(
))); | 635 sk_sp<GrDrawContext> dc(context->drawContext(sk_ref_sp(texture->asRenderTarg
et()))); |
| 636 if (!dc) { | 636 if (!dc) { |
| 637 return nullptr; | 637 return nullptr; |
| 638 } | 638 } |
| 639 | 639 |
| 640 // The texture may be larger than necessary, this rect represents the part o
f the texture | 640 // The texture may be larger than necessary, this rect represents the part o
f the texture |
| 641 // we populate with a rasterization of the clip. | 641 // we populate with a rasterization of the clip. |
| 642 SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpa
ceIBounds.height()); | 642 SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpa
ceIBounds.height()); |
| 643 | 643 |
| 644 // The scratch texture that we are drawing into can be substantially larger
than the mask. Only | 644 // The scratch texture that we are drawing into can be substantially larger
than the mask. Only |
| 645 // clear the part that we care about. | 645 // clear the part that we care about. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 675 | 675 |
| 676 // draw directly into the result with the stencil set to make the pi
xels affected | 676 // draw directly into the result with the stencil set to make the pi
xels affected |
| 677 // by the clip shape be non-zero. | 677 // by the clip shape be non-zero. |
| 678 GR_STATIC_CONST_SAME_STENCIL(kStencilInElement, | 678 GR_STATIC_CONST_SAME_STENCIL(kStencilInElement, |
| 679 kReplace_StencilOp, | 679 kReplace_StencilOp, |
| 680 kReplace_StencilOp, | 680 kReplace_StencilOp, |
| 681 kAlways_StencilFunc, | 681 kAlways_StencilFunc, |
| 682 0xffff, | 682 0xffff, |
| 683 0xffff, | 683 0xffff, |
| 684 0xffff) | 684 0xffff) |
| 685 if (!stencil_element(dc, &maskSpaceIBounds, kStencilInElement, | 685 if (!stencil_element(dc.get(), &maskSpaceIBounds, kStencilInElement, |
| 686 translate, element)) { | 686 translate, element)) { |
| 687 texture->resourcePriv().removeUniqueKey(); | 687 texture->resourcePriv().removeUniqueKey(); |
| 688 return nullptr; | 688 return nullptr; |
| 689 } | 689 } |
| 690 | 690 |
| 691 // Draw to the exterior pixels (those with a zero stencil value). | 691 // Draw to the exterior pixels (those with a zero stencil value). |
| 692 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, | 692 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, |
| 693 kZero_StencilOp, | 693 kZero_StencilOp, |
| 694 kZero_StencilOp, | 694 kZero_StencilOp, |
| 695 kEqual_StencilFunc, | 695 kEqual_StencilFunc, |
| 696 0xffff, | 696 0xffff, |
| 697 0x0000, | 697 0x0000, |
| 698 0xffff); | 698 0xffff); |
| 699 if (!dc->drawContextPriv().drawAndStencilRect(&maskSpaceIBounds, kDr
awOutsideElement, | 699 if (!dc->drawContextPriv().drawAndStencilRect(&maskSpaceIBounds, kDr
awOutsideElement, |
| 700 op, !invert, false, | 700 op, !invert, false, |
| 701 translate, | 701 translate, |
| 702 SkRect::Make(clipSpace
IBounds))) { | 702 SkRect::Make(clipSpace
IBounds))) { |
| 703 texture->resourcePriv().removeUniqueKey(); | 703 texture->resourcePriv().removeUniqueKey(); |
| 704 return nullptr; | 704 return nullptr; |
| 705 } | 705 } |
| 706 } else { | 706 } else { |
| 707 // all the remaining ops can just be directly draw into the accumula
tion buffer | 707 // all the remaining ops can just be directly draw into the accumula
tion buffer |
| 708 GrPaint paint; | 708 GrPaint paint; |
| 709 paint.setAntiAlias(element->isAA()); | 709 paint.setAntiAlias(element->isAA()); |
| 710 paint.setCoverageSetOpXPFactory(op, false); | 710 paint.setCoverageSetOpXPFactory(op, false); |
| 711 | 711 |
| 712 draw_element(dc, GrClip::WideOpen(), paint, translate, element); | 712 draw_element(dc.get(), GrClip::WideOpen(), paint, translate, element
); |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 | 715 |
| 716 return texture.release(); | 716 return texture.release(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 //////////////////////////////////////////////////////////////////////////////// | 719 //////////////////////////////////////////////////////////////////////////////// |
| 720 // Create a 1-bit clip mask in the stencil buffer. 'devClipBounds' are in device | 720 // Create a 1-bit clip mask in the stencil buffer. 'devClipBounds' are in device |
| 721 // (as opposed to canvas) coordinates | 721 // (as opposed to canvas) coordinates |
| 722 bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt, | 722 bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt, |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 | 1156 |
| 1157 //////////////////////////////////////////////////////////////////////////////// | 1157 //////////////////////////////////////////////////////////////////////////////// |
| 1158 | 1158 |
| 1159 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, | 1159 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, |
| 1160 GrStencilSettings* settings) { | 1160 GrStencilSettings* settings) { |
| 1161 if (stencilAttachment) { | 1161 if (stencilAttachment) { |
| 1162 int stencilBits = stencilAttachment->bits(); | 1162 int stencilBits = stencilAttachment->bits(); |
| 1163 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1163 this->adjustStencilParams(settings, fClipMode, stencilBits); |
| 1164 } | 1164 } |
| 1165 } | 1165 } |
| OLD | NEW |