| 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 // TODO: Do rects directly to the accumulator using a aa-rect GrEffe
ct that covers the | 400 // TODO: Do rects directly to the accumulator using a aa-rect GrEffe
ct that covers the |
| 401 // entire mask bounds and writes 0 outside the rect. | 401 // entire mask bounds and writes 0 outside the rect. |
| 402 if (element->isAA()) { | 402 if (element->isAA()) { |
| 403 getContext()->getAARectRenderer()->fillAARect(fGpu, | 403 getContext()->getAARectRenderer()->fillAARect(fGpu, |
| 404 fGpu, | 404 fGpu, |
| 405 element->getRect()
, | 405 element->getRect()
, |
| 406 SkMatrix::I(), | 406 SkMatrix::I(), |
| 407 element->getRect()
, | 407 element->getRect()
, |
| 408 false); | 408 false); |
| 409 } else { | 409 } else { |
| 410 fGpu->drawSimpleRect(element->getRect(), NULL); | 410 fGpu->drawSimpleRect(element->getRect()); |
| 411 } | 411 } |
| 412 return true; | 412 return true; |
| 413 default: { | 413 default: { |
| 414 SkPath path; | 414 SkPath path; |
| 415 element->asPath(&path); | 415 element->asPath(&path); |
| 416 if (path.isInverseFillType()) { | 416 if (path.isInverseFillType()) { |
| 417 path.toggleInverseFillType(); | 417 path.toggleInverseFillType(); |
| 418 } | 418 } |
| 419 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); | 419 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); |
| 420 if (NULL == pr) { | 420 if (NULL == pr) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 474 |
| 475 SkMatrix sampleM; | 475 SkMatrix sampleM; |
| 476 sampleM.setIDiv(srcMask->width(), srcMask->height()); | 476 sampleM.setIDiv(srcMask->width(), srcMask->height()); |
| 477 | 477 |
| 478 drawState->addColorEffect( | 478 drawState->addColorEffect( |
| 479 GrTextureDomainEffect::Create(srcMask, | 479 GrTextureDomainEffect::Create(srcMask, |
| 480 sampleM, | 480 sampleM, |
| 481 GrTextureDomain::MakeTexelDomain(srcMask,
srcBound), | 481 GrTextureDomain::MakeTexelDomain(srcMask,
srcBound), |
| 482 GrTextureDomain::kDecal_Mode, | 482 GrTextureDomain::kDecal_Mode, |
| 483 GrTextureParams::kNone_FilterMode))->unref
(); | 483 GrTextureParams::kNone_FilterMode))->unref
(); |
| 484 fGpu->drawSimpleRect(SkRect::Make(dstBound), NULL); | 484 fGpu->drawSimpleRect(SkRect::Make(dstBound)); |
| 485 } | 485 } |
| 486 | 486 |
| 487 // get a texture to act as a temporary buffer for AA clip boolean operations | 487 // get a texture to act as a temporary buffer for AA clip boolean operations |
| 488 // TODO: given the expense of createTexture we may want to just cache this too | 488 // TODO: given the expense of createTexture we may want to just cache this too |
| 489 void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* tem
p) { | 489 void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* tem
p) { |
| 490 if (NULL != temp->texture()) { | 490 if (NULL != temp->texture()) { |
| 491 // we've already allocated the temp texture | 491 // we've already allocated the temp texture |
| 492 return; | 492 return; |
| 493 } | 493 } |
| 494 | 494 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 GR_STATIC_CONST_SAME_STENCIL(gDrawToStencil, | 805 GR_STATIC_CONST_SAME_STENCIL(gDrawToStencil, |
| 806 kIncClamp_StencilOp, | 806 kIncClamp_StencilOp, |
| 807 kIncClamp_StencilOp, | 807 kIncClamp_StencilOp, |
| 808 kAlways_StencilFunc, | 808 kAlways_StencilFunc, |
| 809 0xffff, | 809 0xffff, |
| 810 0x0000, | 810 0x0000, |
| 811 0xffff); | 811 0xffff); |
| 812 SET_RANDOM_COLOR | 812 SET_RANDOM_COLOR |
| 813 if (Element::kRect_Type == element->getType()) { | 813 if (Element::kRect_Type == element->getType()) { |
| 814 *drawState->stencil() = gDrawToStencil; | 814 *drawState->stencil() = gDrawToStencil; |
| 815 fGpu->drawSimpleRect(element->getRect(), NULL); | 815 fGpu->drawSimpleRect(element->getRect()); |
| 816 } else { | 816 } else { |
| 817 if (!clipPath.isEmpty()) { | 817 if (!clipPath.isEmpty()) { |
| 818 if (canRenderDirectToStencil) { | 818 if (canRenderDirectToStencil) { |
| 819 *drawState->stencil() = gDrawToStencil; | 819 *drawState->stencil() = gDrawToStencil; |
| 820 pr->drawPath(clipPath, stroke, fGpu, false); | 820 pr->drawPath(clipPath, stroke, fGpu, false); |
| 821 } else { | 821 } else { |
| 822 pr->stencilPath(clipPath, stroke, fGpu); | 822 pr->stencilPath(clipPath, stroke, fGpu); |
| 823 } | 823 } |
| 824 } | 824 } |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 | 827 |
| 828 // now we modify the clip bit by rendering either the clip | 828 // now we modify the clip bit by rendering either the clip |
| 829 // element directly or a bounding rect of the entire clip. | 829 // element directly or a bounding rect of the entire clip. |
| 830 drawState->enableState(GrGpu::kModifyStencilClip_StateBit); | 830 drawState->enableState(GrGpu::kModifyStencilClip_StateBit); |
| 831 for (int p = 0; p < passes; ++p) { | 831 for (int p = 0; p < passes; ++p) { |
| 832 *drawState->stencil() = stencilSettings[p]; | 832 *drawState->stencil() = stencilSettings[p]; |
| 833 if (canDrawDirectToClip) { | 833 if (canDrawDirectToClip) { |
| 834 if (Element::kRect_Type == element->getType()) { | 834 if (Element::kRect_Type == element->getType()) { |
| 835 SET_RANDOM_COLOR | 835 SET_RANDOM_COLOR |
| 836 fGpu->drawSimpleRect(element->getRect(), NULL); | 836 fGpu->drawSimpleRect(element->getRect()); |
| 837 } else { | 837 } else { |
| 838 SET_RANDOM_COLOR | 838 SET_RANDOM_COLOR |
| 839 pr->drawPath(clipPath, stroke, fGpu, false); | 839 pr->drawPath(clipPath, stroke, fGpu, false); |
| 840 } | 840 } |
| 841 } else { | 841 } else { |
| 842 SET_RANDOM_COLOR | 842 SET_RANDOM_COLOR |
| 843 // The view matrix is setup to do clip space -> stencil spac
e translation, so | 843 // The view matrix is setup to do clip space -> stencil spac
e translation, so |
| 844 // draw rect in clip space. | 844 // draw rect in clip space. |
| 845 fGpu->drawSimpleRect(SkRect::Make(clipSpaceIBounds), NULL); | 845 fGpu->drawSimpleRect(SkRect::Make(clipSpaceIBounds)); |
| 846 } | 846 } |
| 847 } | 847 } |
| 848 } | 848 } |
| 849 } | 849 } |
| 850 // set this last because recursive draws may overwrite it back to kNone. | 850 // set this last because recursive draws may overwrite it back to kNone. |
| 851 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); | 851 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); |
| 852 fCurrClipMaskType = kStencil_ClipMaskType; | 852 fCurrClipMaskType = kStencil_ClipMaskType; |
| 853 return true; | 853 return true; |
| 854 } | 854 } |
| 855 | 855 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 | 1139 |
| 1140 // TODO: dynamically attach a stencil buffer | 1140 // TODO: dynamically attach a stencil buffer |
| 1141 int stencilBits = 0; | 1141 int stencilBits = 0; |
| 1142 GrStencilBuffer* stencilBuffer = | 1142 GrStencilBuffer* stencilBuffer = |
| 1143 drawState.getRenderTarget()->getStencilBuffer(); | 1143 drawState.getRenderTarget()->getStencilBuffer(); |
| 1144 if (NULL != stencilBuffer) { | 1144 if (NULL != stencilBuffer) { |
| 1145 stencilBits = stencilBuffer->bits(); | 1145 stencilBits = stencilBuffer->bits(); |
| 1146 this->adjustStencilParams(settings, clipMode, stencilBits); | 1146 this->adjustStencilParams(settings, clipMode, stencilBits); |
| 1147 } | 1147 } |
| 1148 } | 1148 } |
| OLD | NEW |