| 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" |
| 11 #include "GrAARectRenderer.h" | 11 #include "GrAARectRenderer.h" |
| 12 #include "GrDrawTargetCaps.h" | 12 #include "GrDrawTargetCaps.h" |
| 13 #include "GrPaint.h" | 13 #include "GrPaint.h" |
| 14 #include "GrPathRenderer.h" | 14 #include "GrPathRenderer.h" |
| 15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
| 16 #include "GrStencilBuffer.h" | 16 #include "GrStencilBuffer.h" |
| 17 #include "GrSWMaskHelper.h" | 17 #include "GrSWMaskHelper.h" |
| 18 #include "SkRasterClip.h" | 18 #include "SkRasterClip.h" |
| 19 #include "SkStrokeRec.h" | 19 #include "SkStrokeRec.h" |
| 20 #include "SkTLazy.h" | 20 #include "SkTLazy.h" |
| 21 #include "effects/GrTextureDomain.h" |
| 21 #include "effects/GrConvexPolyEffect.h" | 22 #include "effects/GrConvexPolyEffect.h" |
| 22 #include "effects/GrPorterDuffXferProcessor.h" | |
| 23 #include "effects/GrRRectEffect.h" | 23 #include "effects/GrRRectEffect.h" |
| 24 #include "effects/GrTextureDomain.h" | |
| 25 | 24 |
| 26 #define GR_AA_CLIP 1 | 25 #define GR_AA_CLIP 1 |
| 27 typedef SkClipStack::Element Element; | 26 typedef SkClipStack::Element Element; |
| 28 | 27 |
| 29 //////////////////////////////////////////////////////////////////////////////// | 28 //////////////////////////////////////////////////////////////////////////////// |
| 30 namespace { | 29 namespace { |
| 31 // set up the draw state to enable the aa clipping mask. Besides setting up the | 30 // set up the draw state to enable the aa clipping mask. Besides setting up the |
| 32 // stage matrix this also alters the vertex layout | 31 // stage matrix this also alters the vertex layout |
| 33 void setup_drawstate_aaclip(const SkIRect &devBound, | 32 void setup_drawstate_aaclip(const SkIRect &devBound, |
| 34 GrDrawState* drawState, | 33 GrDrawState* drawState, |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 scissorState->set(scissorSpaceIBounds); | 325 scissorState->set(scissorSpaceIBounds); |
| 327 this->setDrawStateStencil(drawState, ars); | 326 this->setDrawStateStencil(drawState, ars); |
| 328 return true; | 327 return true; |
| 329 } | 328 } |
| 330 | 329 |
| 331 namespace { | 330 namespace { |
| 332 //////////////////////////////////////////////////////////////////////////////// | 331 //////////////////////////////////////////////////////////////////////////////// |
| 333 // set up the OpenGL blend function to perform the specified | 332 // set up the OpenGL blend function to perform the specified |
| 334 // boolean operation for alpha clip mask creation | 333 // boolean operation for alpha clip mask creation |
| 335 void setup_boolean_blendcoeffs(SkRegion::Op op, GrDrawState* drawState) { | 334 void setup_boolean_blendcoeffs(SkRegion::Op op, GrDrawState* drawState) { |
| 336 // TODO: once we have a coverageDrawing XP this will all use that instead of
PD | |
| 337 switch (op) { | 335 switch (op) { |
| 338 case SkRegion::kReplace_Op: | 336 case SkRegion::kReplace_Op: |
| 339 drawState->setPorterDuffXPFactory(kOne_GrBlendCoeff, kZero_GrBlendCo
eff); | 337 drawState->setBlendFunc(kOne_GrBlendCoeff, kZero_GrBlendCoeff); |
| 340 break; | 338 break; |
| 341 case SkRegion::kIntersect_Op: | 339 case SkRegion::kIntersect_Op: |
| 342 drawState->setPorterDuffXPFactory(kDC_GrBlendCoeff, kZero_GrBlendCoe
ff); | 340 drawState->setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff); |
| 343 break; | 341 break; |
| 344 case SkRegion::kUnion_Op: | 342 case SkRegion::kUnion_Op: |
| 345 drawState->setPorterDuffXPFactory(kOne_GrBlendCoeff, kISC_GrBlendCoe
ff); | 343 drawState->setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff); |
| 346 break; | 344 break; |
| 347 case SkRegion::kXOR_Op: | 345 case SkRegion::kXOR_Op: |
| 348 drawState->setPorterDuffXPFactory(kIDC_GrBlendCoeff, kISC_GrBlendCoe
ff); | 346 drawState->setBlendFunc(kIDC_GrBlendCoeff, kISC_GrBlendCoeff); |
| 349 break; | 347 break; |
| 350 case SkRegion::kDifference_Op: | 348 case SkRegion::kDifference_Op: |
| 351 drawState->setPorterDuffXPFactory(kZero_GrBlendCoeff, kISC_GrBlendCo
eff); | 349 drawState->setBlendFunc(kZero_GrBlendCoeff, kISC_GrBlendCoeff); |
| 352 break; | 350 break; |
| 353 case SkRegion::kReverseDifference_Op: | 351 case SkRegion::kReverseDifference_Op: |
| 354 drawState->setPorterDuffXPFactory(kIDC_GrBlendCoeff, kZero_GrBlendCo
eff); | 352 drawState->setBlendFunc(kIDC_GrBlendCoeff, kZero_GrBlendCoeff); |
| 355 break; | 353 break; |
| 356 default: | 354 default: |
| 357 SkASSERT(false); | 355 SkASSERT(false); |
| 358 break; | 356 break; |
| 359 } | 357 } |
| 360 } | 358 } |
| 361 } | 359 } |
| 362 | 360 |
| 363 //////////////////////////////////////////////////////////////////////////////// | 361 //////////////////////////////////////////////////////////////////////////////// |
| 364 bool GrClipMaskManager::drawElement(GrDrawState* drawState, | 362 bool GrClipMaskManager::drawElement(GrDrawState* drawState, |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 } | 1075 } |
| 1078 | 1076 |
| 1079 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, | 1077 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, |
| 1080 GrStencilSettings* settings) { | 1078 GrStencilSettings* settings) { |
| 1081 // TODO: dynamically attach a stencil buffer | 1079 // TODO: dynamically attach a stencil buffer |
| 1082 if (stencilBuffer) { | 1080 if (stencilBuffer) { |
| 1083 int stencilBits = stencilBuffer->bits(); | 1081 int stencilBits = stencilBuffer->bits(); |
| 1084 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1082 this->adjustStencilParams(settings, fClipMode, stencilBits); |
| 1085 } | 1083 } |
| 1086 } | 1084 } |
| OLD | NEW |