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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 return !failed; | 202 return !failed; |
203 } | 203 } |
204 | 204 |
205 //////////////////////////////////////////////////////////////////////////////// | 205 //////////////////////////////////////////////////////////////////////////////// |
206 // sort out what kind of clip mask needs to be created: alpha, stencil, | 206 // sort out what kind of clip mask needs to be created: alpha, stencil, |
207 // scissor, or entirely software | 207 // scissor, or entirely software |
208 bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder, | 208 bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder, |
209 GrPipelineBuilder::AutoRestoreEffects* are
, | 209 GrPipelineBuilder::AutoRestoreEffects* are
, |
210 GrPipelineBuilder::AutoRestoreStencil* ars
, | 210 GrPipelineBuilder::AutoRestoreStencil* ars
, |
211 GrScissorState* scissorState, | 211 GrScissorState* scissorState, |
212 const GrClipData* clipDataIn, | |
213 const SkRect* devBounds) { | 212 const SkRect* devBounds) { |
214 fCurrClipMaskType = kNone_ClipMaskType; | 213 fCurrClipMaskType = kNone_ClipMaskType; |
215 if (kRespectClip_StencilClipMode == fClipMode) { | 214 if (kRespectClip_StencilClipMode == fClipMode) { |
216 fClipMode = kIgnoreClip_StencilClipMode; | 215 fClipMode = kIgnoreClip_StencilClipMode; |
217 } | 216 } |
218 | 217 |
219 GrReducedClip::ElementList elements(16); | 218 GrReducedClip::ElementList elements(16); |
220 int32_t genID; | 219 int32_t genID; |
221 GrReducedClip::InitialState initialState; | 220 GrReducedClip::InitialState initialState; |
222 SkIRect clipSpaceIBounds; | 221 SkIRect clipSpaceIBounds; |
223 bool requiresAA; | 222 bool requiresAA; |
224 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | 223 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); |
225 | 224 |
226 // GrDrawTarget should have filtered this for us | 225 // GrDrawTarget should have filtered this for us |
227 SkASSERT(rt); | 226 SkASSERT(rt); |
228 | 227 |
229 bool ignoreClip = !pipelineBuilder->isClipState() || clipDataIn->fClipStack-
>isWideOpen(); | 228 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); |
| 229 const GrClip& clip = pipelineBuilder->clip(); |
| 230 // TODO we shouldn't be ignoring the clip mask manager's clip. This is temp
orary. |
| 231 bool ignoreClip = clip.isWideOpen(clipSpaceRTIBounds) || |
| 232 GrClip::kIRect_ClipType == clip.clipType(); |
230 if (!ignoreClip) { | 233 if (!ignoreClip) { |
231 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); | 234 // The clip mask manager always draws with a single IRect so we special
case that logic here |
232 clipSpaceRTIBounds.offset(clipDataIn->fOrigin); | 235 if (GrClip::kIRect_ClipType == clip.clipType()) { |
233 GrReducedClip::ReduceClipStack(*clipDataIn->fClipStack, | 236 initialState = GrReducedClip::kAllIn_InitialState; |
234 clipSpaceRTIBounds, | 237 clipSpaceIBounds = clip.irect(); |
235 &elements, | 238 SkNEW_INSERT_AT_LLIST_HEAD(&elements, |
236 &genID, | 239 Element, |
237 &initialState, | 240 (SkRect::Make(clipSpaceIBounds), |
238 &clipSpaceIBounds, | 241 SkRegion::kIntersect_Op, false)); |
239 &requiresAA); | 242 } else { |
240 if (elements.isEmpty()) { | 243 clipSpaceRTIBounds.offset(clip.origin()); |
241 if (GrReducedClip::kAllIn_InitialState == initialState) { | 244 GrReducedClip::ReduceClipStack(*clip.clipStack(), |
242 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds; | 245 clipSpaceRTIBounds, |
243 } else { | 246 &elements, |
244 return false; | 247 &genID, |
| 248 &initialState, |
| 249 &clipSpaceIBounds, |
| 250 &requiresAA); |
| 251 if (elements.isEmpty()) { |
| 252 if (GrReducedClip::kAllIn_InitialState == initialState) { |
| 253 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds; |
| 254 } else { |
| 255 return false; |
| 256 } |
245 } | 257 } |
246 } | 258 } |
247 } | 259 } |
248 | 260 |
249 if (ignoreClip) { | 261 if (ignoreClip) { |
250 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 262 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
251 return true; | 263 return true; |
252 } | 264 } |
253 | 265 |
254 // An element count of 4 was chosen because of the common pattern in Blink o
f: | 266 // An element count of 4 was chosen because of the common pattern in Blink o
f: |
255 // isect RR | 267 // isect RR |
256 // diff RR | 268 // diff RR |
257 // isect convex_poly | 269 // isect convex_poly |
258 // isect convex_poly | 270 // isect convex_poly |
259 // when drawing rounded div borders. This could probably be tuned based on a | 271 // when drawing rounded div borders. This could probably be tuned based on a |
260 // configuration's relative costs of switching RTs to generate a mask vs | 272 // configuration's relative costs of switching RTs to generate a mask vs |
261 // longer shaders. | 273 // longer shaders. |
262 if (elements.count() <= 4) { | 274 if (elements.count() <= 4) { |
263 SkVector clipToRTOffset = { SkIntToScalar(-clipDataIn->fOrigin.fX), | 275 SkVector clipToRTOffset = { SkIntToScalar(-clip.origin().fX), |
264 SkIntToScalar(-clipDataIn->fOrigin.fY) }; | 276 SkIntToScalar(-clip.origin().fY) }; |
265 if (elements.isEmpty() || | 277 if (elements.isEmpty() || |
266 this->installClipEffects(pipelineBuilder, are, elements, clipToRTOff
set, devBounds)) { | 278 this->installClipEffects(pipelineBuilder, are, elements, clipToRTOff
set, devBounds)) { |
267 SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 279 SkIRect scissorSpaceIBounds(clipSpaceIBounds); |
268 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); | 280 scissorSpaceIBounds.offset(-clip.origin()); |
269 if (NULL == devBounds || | 281 if (NULL == devBounds || |
270 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { | 282 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { |
271 scissorState->set(scissorSpaceIBounds); | 283 scissorState->set(scissorSpaceIBounds); |
272 } | 284 } |
273 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 285 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
274 return true; | 286 return true; |
275 } | 287 } |
276 } | 288 } |
277 | 289 |
278 // If MSAA is enabled we can do everything in the stencil buffer. | 290 // If MSAA is enabled we can do everything in the stencil buffer. |
(...skipping 19 matching lines...) Expand all Loading... |
298 initialState, | 310 initialState, |
299 elements, | 311 elements, |
300 clipToMaskOffset, | 312 clipToMaskOffset, |
301 clipSpaceIBounds); | 313 clipSpaceIBounds); |
302 } | 314 } |
303 | 315 |
304 if (result) { | 316 if (result) { |
305 // The mask's top left coord should be pinned to the rounded-out top
left corner of | 317 // The mask's top left coord should be pinned to the rounded-out top
left corner of |
306 // clipSpace bounds. We determine the mask's position WRT to the ren
der target here. | 318 // clipSpace bounds. We determine the mask's position WRT to the ren
der target here. |
307 SkIRect rtSpaceMaskBounds = clipSpaceIBounds; | 319 SkIRect rtSpaceMaskBounds = clipSpaceIBounds; |
308 rtSpaceMaskBounds.offset(-clipDataIn->fOrigin); | 320 rtSpaceMaskBounds.offset(-clip.origin()); |
309 setup_drawstate_aaclip(rtSpaceMaskBounds, pipelineBuilder, result); | 321 setup_drawstate_aaclip(rtSpaceMaskBounds, pipelineBuilder, result); |
310 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 322 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
311 return true; | 323 return true; |
312 } | 324 } |
313 // if alpha clip mask creation fails fall through to the non-AA code pat
hs | 325 // if alpha clip mask creation fails fall through to the non-AA code pat
hs |
314 } | 326 } |
315 | 327 |
316 // Either a hard (stencil buffer) clip was explicitly requested or an anti-a
liased clip couldn't | 328 // Either a hard (stencil buffer) clip was explicitly requested or an anti-a
liased clip couldn't |
317 // be created. In either case, free up the texture in the anti-aliased mask
cache. | 329 // be created. In either case, free up the texture in the anti-aliased mask
cache. |
318 // TODO: this may require more investigation. Ganesh performs a lot of utili
ty draws (e.g., | 330 // TODO: this may require more investigation. Ganesh performs a lot of utili
ty draws (e.g., |
319 // clears, InOrderDrawBuffer playbacks) that hit the stencil buffer path. Th
ese may be | 331 // clears, InOrderDrawBuffer playbacks) that hit the stencil buffer path. Th
ese may be |
320 // "incorrectly" clearing the AA cache. | 332 // "incorrectly" clearing the AA cache. |
321 fAACache.reset(); | 333 fAACache.reset(); |
322 | 334 |
323 // use the stencil clip if we can't represent the clip as a rectangle. | 335 // use the stencil clip if we can't represent the clip as a rectangle. |
324 SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin; | 336 SkIPoint clipSpaceToStencilSpaceOffset = -clip.origin(); |
325 this->createStencilClipMask(rt, | 337 this->createStencilClipMask(rt, |
326 genID, | 338 genID, |
327 initialState, | 339 initialState, |
328 elements, | 340 elements, |
329 clipSpaceIBounds, | 341 clipSpaceIBounds, |
330 clipSpaceToStencilSpaceOffset); | 342 clipSpaceToStencilSpaceOffset); |
331 | 343 |
332 // This must occur after createStencilClipMask. That function may change the
scissor. Also, it | 344 // This must occur after createStencilClipMask. That function may change the
scissor. Also, it |
333 // only guarantees that the stencil mask is correct within the bounds it was
passed, so we must | 345 // only guarantees that the stencil mask is correct within the bounds it was
passed, so we must |
334 // use both stencil and scissor test to the bounds for the final draw. | 346 // use both stencil and scissor test to the bounds for the final draw. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 SkMatrix sampleM; | 463 SkMatrix sampleM; |
452 sampleM.setIDiv(srcMask->width(), srcMask->height()); | 464 sampleM.setIDiv(srcMask->width(), srcMask->height()); |
453 | 465 |
454 pipelineBuilder->addCoverageProcessor( | 466 pipelineBuilder->addCoverageProcessor( |
455 GrTextureDomainEffect::Create(srcMask, | 467 GrTextureDomainEffect::Create(srcMask, |
456 sampleM, | 468 sampleM, |
457 GrTextureDomain::MakeTexelDomain(srcMask,
srcBound), | 469 GrTextureDomain::MakeTexelDomain(srcMask,
srcBound), |
458 GrTextureDomain::kDecal_Mode, | 470 GrTextureDomain::kDecal_Mode, |
459 GrTextureParams::kNone_FilterMode))->unref
(); | 471 GrTextureParams::kNone_FilterMode))->unref
(); |
460 // The color passed in here does not matter since the coverageSetOpXP won't
read it. | 472 // The color passed in here does not matter since the coverageSetOpXP won't
read it. |
461 fClipTarget->drawSimpleRect(pipelineBuilder, GrColor_WHITE, SkMatrix::I(), | 473 fClipTarget->drawSimpleRect(pipelineBuilder, |
| 474 GrColor_WHITE, |
| 475 SkMatrix::I(), |
462 SkRect::Make(dstBound)); | 476 SkRect::Make(dstBound)); |
463 } | 477 } |
464 | 478 |
465 GrTexture* GrClipMaskManager::createTempMask(int width, int height) { | 479 GrTexture* GrClipMaskManager::createTempMask(int width, int height) { |
466 GrSurfaceDesc desc; | 480 GrSurfaceDesc desc; |
467 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 481 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
468 desc.fWidth = width; | 482 desc.fWidth = width; |
469 desc.fHeight = height; | 483 desc.fHeight = height; |
470 if (this->getContext()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 484 if (this->getContext()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { |
471 desc.fConfig = kAlpha_8_GrPixelConfig; | 485 desc.fConfig = kAlpha_8_GrPixelConfig; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // clear the part that we care about. | 562 // clear the part that we care about. |
549 fClipTarget->clear(&maskSpaceIBounds, | 563 fClipTarget->clear(&maskSpaceIBounds, |
550 GrReducedClip::kAllIn_InitialState == initialState ? 0xff
ffffff : 0x00000000, | 564 GrReducedClip::kAllIn_InitialState == initialState ? 0xff
ffffff : 0x00000000, |
551 true, | 565 true, |
552 result->asRenderTarget()); | 566 result->asRenderTarget()); |
553 | 567 |
554 // When we use the stencil in the below loop it is important to have this cl
ip installed. | 568 // When we use the stencil in the below loop it is important to have this cl
ip installed. |
555 // The second pass that zeros the stencil buffer renders the rect maskSpaceI
Bounds so the first | 569 // The second pass that zeros the stencil buffer renders the rect maskSpaceI
Bounds so the first |
556 // pass must not set values outside of this bounds or stencil values outside
the rect won't be | 570 // pass must not set values outside of this bounds or stencil values outside
the rect won't be |
557 // cleared. | 571 // cleared. |
558 GrDrawTarget::AutoClipRestore acr(fClipTarget, maskSpaceIBounds); | 572 GrClip clip(maskSpaceIBounds); |
559 SkAutoTUnref<GrTexture> temp; | 573 SkAutoTUnref<GrTexture> temp; |
560 | 574 |
561 // walk through each clip element and perform its set op | 575 // walk through each clip element and perform its set op |
562 for (GrReducedClip::ElementList::Iter iter = elements.headIter(); iter.get()
; iter.next()) { | 576 for (GrReducedClip::ElementList::Iter iter = elements.headIter(); iter.get()
; iter.next()) { |
563 const Element* element = iter.get(); | 577 const Element* element = iter.get(); |
564 SkRegion::Op op = element->getOp(); | 578 SkRegion::Op op = element->getOp(); |
565 bool invert = element->isInverseFilled(); | 579 bool invert = element->isInverseFilled(); |
566 if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDiffere
nce_Op == op) { | 580 if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDiffere
nce_Op == op) { |
567 GrPipelineBuilder pipelineBuilder; | 581 GrPipelineBuilder pipelineBuilder; |
568 | 582 |
| 583 pipelineBuilder.setClip(clip); |
569 GrPathRenderer* pr = NULL; | 584 GrPathRenderer* pr = NULL; |
570 bool useTemp = !this->canStencilAndDrawElement(&pipelineBuilder, res
ult, &pr, element); | 585 bool useTemp = !this->canStencilAndDrawElement(&pipelineBuilder, res
ult, &pr, element); |
571 GrTexture* dst; | 586 GrTexture* dst; |
572 // This is the bounds of the clip element in the space of the alpha-
mask. The temporary | 587 // This is the bounds of the clip element in the space of the alpha-
mask. The temporary |
573 // mask buffer can be substantially larger than the actually clip st
ack element. We | 588 // mask buffer can be substantially larger than the actually clip st
ack element. We |
574 // touch the minimum number of pixels necessary and use decal mode t
o combine it with | 589 // touch the minimum number of pixels necessary and use decal mode t
o combine it with |
575 // the accumulator. | 590 // the accumulator. |
576 SkIRect maskSpaceElementIBounds; | 591 SkIRect maskSpaceElementIBounds; |
577 | 592 |
578 if (useTemp) { | 593 if (useTemp) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 SkVector translate = { | 701 SkVector translate = { |
687 SkIntToScalar(clipSpaceToStencilOffset.fX), | 702 SkIntToScalar(clipSpaceToStencilOffset.fX), |
688 SkIntToScalar(clipSpaceToStencilOffset.fY) | 703 SkIntToScalar(clipSpaceToStencilOffset.fY) |
689 }; | 704 }; |
690 SkMatrix viewMatrix; | 705 SkMatrix viewMatrix; |
691 viewMatrix.setTranslate(translate); | 706 viewMatrix.setTranslate(translate); |
692 | 707 |
693 // We set the current clip to the bounds so that our recursive draws are
scissored to them. | 708 // We set the current clip to the bounds so that our recursive draws are
scissored to them. |
694 SkIRect stencilSpaceIBounds(clipSpaceIBounds); | 709 SkIRect stencilSpaceIBounds(clipSpaceIBounds); |
695 stencilSpaceIBounds.offset(clipSpaceToStencilOffset); | 710 stencilSpaceIBounds.offset(clipSpaceToStencilOffset); |
696 GrDrawTarget::AutoClipRestore acr(fClipTarget, stencilSpaceIBounds); | 711 GrClip clip(stencilSpaceIBounds); |
697 | 712 |
698 int clipBit = stencilBuffer->bits(); | 713 int clipBit = stencilBuffer->bits(); |
699 SkASSERT((clipBit <= 16) && "Ganesh only handles 16b or smaller stencil
buffers"); | 714 SkASSERT((clipBit <= 16) && "Ganesh only handles 16b or smaller stencil
buffers"); |
700 clipBit = (1 << (clipBit-1)); | 715 clipBit = (1 << (clipBit-1)); |
701 | 716 |
702 fClipTarget->clearStencilClip(stencilSpaceIBounds, | 717 fClipTarget->clearStencilClip(stencilSpaceIBounds, |
703 GrReducedClip::kAllIn_InitialState == init
ialState, | 718 GrReducedClip::kAllIn_InitialState == init
ialState, |
704 rt); | 719 rt); |
705 | 720 |
706 // walk through each clip element and perform its set op | 721 // walk through each clip element and perform its set op |
707 // with the existing clip. | 722 // with the existing clip. |
708 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.ge
t(); iter.next()) { | 723 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.ge
t(); iter.next()) { |
709 const Element* element = iter.get(); | 724 const Element* element = iter.get(); |
710 | 725 |
711 GrPipelineBuilder pipelineBuilder; | 726 GrPipelineBuilder pipelineBuilder; |
| 727 pipelineBuilder.setClip(clip); |
712 pipelineBuilder.setRenderTarget(rt); | 728 pipelineBuilder.setRenderTarget(rt); |
713 | 729 |
714 pipelineBuilder.setDisableColorXPFactory(); | 730 pipelineBuilder.setDisableColorXPFactory(); |
715 | 731 |
716 // if the target is MSAA then we want MSAA enabled when the clip is
soft | 732 // if the target is MSAA then we want MSAA enabled when the clip is
soft |
717 if (rt->isMultisampled()) { | 733 if (rt->isMultisampled()) { |
718 pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_StateBi
t, element->isAA()); | 734 pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_StateBi
t, element->isAA()); |
719 } | 735 } |
720 | 736 |
721 bool fillInverted = false; | 737 bool fillInverted = false; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 if (!canDrawDirectToClip) { | 789 if (!canDrawDirectToClip) { |
774 GR_STATIC_CONST_SAME_STENCIL(gDrawToStencil, | 790 GR_STATIC_CONST_SAME_STENCIL(gDrawToStencil, |
775 kIncClamp_StencilOp, | 791 kIncClamp_StencilOp, |
776 kIncClamp_StencilOp, | 792 kIncClamp_StencilOp, |
777 kAlways_StencilFunc, | 793 kAlways_StencilFunc, |
778 0xffff, | 794 0xffff, |
779 0x0000, | 795 0x0000, |
780 0xffff); | 796 0xffff); |
781 if (Element::kRect_Type == element->getType()) { | 797 if (Element::kRect_Type == element->getType()) { |
782 *pipelineBuilder.stencil() = gDrawToStencil; | 798 *pipelineBuilder.stencil() = gDrawToStencil; |
783 fClipTarget->drawSimpleRect(&pipelineBuilder, GrColor_WHITE,
viewMatrix, | 799 fClipTarget->drawSimpleRect(&pipelineBuilder, |
| 800 GrColor_WHITE, |
| 801 viewMatrix, |
784 element->getRect()); | 802 element->getRect()); |
785 } else { | 803 } else { |
786 if (!clipPath.isEmpty()) { | 804 if (!clipPath.isEmpty()) { |
787 GrDrawTarget::AutoGeometryPush agp(fClipTarget); | 805 GrDrawTarget::AutoGeometryPush agp(fClipTarget); |
788 if (canRenderDirectToStencil) { | 806 if (canRenderDirectToStencil) { |
789 *pipelineBuilder.stencil() = gDrawToStencil; | 807 *pipelineBuilder.stencil() = gDrawToStencil; |
790 pr->drawPath(fClipTarget, &pipelineBuilder, GrColor_
WHITE, viewMatrix, | 808 pr->drawPath(fClipTarget, &pipelineBuilder, GrColor_
WHITE, |
791 clipPath, stroke, false); | 809 viewMatrix, clipPath, stroke, false); |
792 } else { | 810 } else { |
793 pr->stencilPath(fClipTarget, &pipelineBuilder, viewM
atrix, clipPath, | 811 pr->stencilPath(fClipTarget, &pipelineBuilder, viewM
atrix, |
794 stroke); | 812 clipPath, stroke); |
795 } | 813 } |
796 } | 814 } |
797 } | 815 } |
798 } | 816 } |
799 | 817 |
800 // now we modify the clip bit by rendering either the clip | 818 // now we modify the clip bit by rendering either the clip |
801 // element directly or a bounding rect of the entire clip. | 819 // element directly or a bounding rect of the entire clip. |
802 fClipMode = kModifyClip_StencilClipMode; | 820 fClipMode = kModifyClip_StencilClipMode; |
803 for (int p = 0; p < passes; ++p) { | 821 for (int p = 0; p < passes; ++p) { |
804 GrPipelineBuilder pipelineBuilderCopy(pipelineBuilder); | 822 GrPipelineBuilder pipelineBuilderCopy(pipelineBuilder); |
805 *pipelineBuilderCopy.stencil() = stencilSettings[p]; | 823 *pipelineBuilderCopy.stencil() = stencilSettings[p]; |
806 | 824 |
807 if (canDrawDirectToClip) { | 825 if (canDrawDirectToClip) { |
808 if (Element::kRect_Type == element->getType()) { | 826 if (Element::kRect_Type == element->getType()) { |
809 fClipTarget->drawSimpleRect(&pipelineBuilderCopy, GrColo
r_WHITE, viewMatrix, | 827 fClipTarget->drawSimpleRect(&pipelineBuilderCopy, |
| 828 GrColor_WHITE, |
| 829 viewMatrix, |
810 element->getRect()); | 830 element->getRect()); |
811 } else { | 831 } else { |
812 GrDrawTarget::AutoGeometryPush agp(fClipTarget); | 832 GrDrawTarget::AutoGeometryPush agp(fClipTarget); |
813 pr->drawPath(fClipTarget, &pipelineBuilderCopy, GrColor_
WHITE, viewMatrix, | 833 pr->drawPath(fClipTarget, &pipelineBuilderCopy, GrColor_
WHITE, |
814 clipPath, stroke, false); | 834 viewMatrix, clipPath, stroke, false); |
815 } | 835 } |
816 } else { | 836 } else { |
817 // The view matrix is setup to do clip space -> stencil spac
e translation, so | 837 // The view matrix is setup to do clip space -> stencil spac
e translation, so |
818 // draw rect in clip space. | 838 // draw rect in clip space. |
819 fClipTarget->drawSimpleRect(&pipelineBuilderCopy, GrColor_WH
ITE, viewMatrix, | 839 fClipTarget->drawSimpleRect(&pipelineBuilderCopy, |
| 840 GrColor_WHITE, |
| 841 viewMatrix, |
820 SkRect::Make(clipSpaceIBounds)); | 842 SkRect::Make(clipSpaceIBounds)); |
821 } | 843 } |
822 } | 844 } |
823 } | 845 } |
824 } | 846 } |
825 // set this last because recursive draws may overwrite it back to kNone. | 847 // set this last because recursive draws may overwrite it back to kNone. |
826 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); | 848 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); |
827 fCurrClipMaskType = kStencil_ClipMaskType; | 849 fCurrClipMaskType = kStencil_ClipMaskType; |
828 fClipMode = kRespectClip_StencilClipMode; | 850 fClipMode = kRespectClip_StencilClipMode; |
829 return true; | 851 return true; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 fAACache.setContext(clipTarget->getContext()); | 1103 fAACache.setContext(clipTarget->getContext()); |
1082 } | 1104 } |
1083 | 1105 |
1084 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, | 1106 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, |
1085 GrStencilSettings* settings) { | 1107 GrStencilSettings* settings) { |
1086 if (stencilBuffer) { | 1108 if (stencilBuffer) { |
1087 int stencilBits = stencilBuffer->bits(); | 1109 int stencilBits = stencilBuffer->bits(); |
1088 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1110 this->adjustStencilParams(settings, fClipMode, stencilBits); |
1089 } | 1111 } |
1090 } | 1112 } |
OLD | NEW |