| 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 15 matching lines...) Expand all Loading... |
| 26 typedef SkClipStack::Element Element; | 26 typedef SkClipStack::Element Element; |
| 27 | 27 |
| 28 using namespace GrReducedClip; | 28 using namespace GrReducedClip; |
| 29 | 29 |
| 30 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
| 31 namespace { | 31 namespace { |
| 32 // set up the draw state to enable the aa clipping mask. Besides setting up the | 32 // set up the draw state to enable the aa clipping mask. Besides setting up the |
| 33 // stage matrix this also alters the vertex layout | 33 // stage matrix this also alters the vertex layout |
| 34 void setup_drawstate_aaclip(GrGpu* gpu, | 34 void setup_drawstate_aaclip(GrGpu* gpu, |
| 35 GrTexture* result, | 35 GrTexture* result, |
| 36 const GrIRect &devBound) { | 36 const SkIRect &devBound) { |
| 37 GrDrawState* drawState = gpu->drawState(); | 37 GrDrawState* drawState = gpu->drawState(); |
| 38 GrAssert(drawState); | 38 GrAssert(drawState); |
| 39 | 39 |
| 40 SkMatrix mat; | 40 SkMatrix mat; |
| 41 // We want to use device coords to compute the texture coordinates. We set o
ur matrix to be | 41 // We want to use device coords to compute the texture coordinates. We set o
ur matrix to be |
| 42 // equal to the view matrix followed by an offset to the devBound, and then
a scaling matrix to | 42 // equal to the view matrix followed by an offset to the devBound, and then
a scaling matrix to |
| 43 // normalized coords. We apply this matrix to the vertex positions rather th
an local coords. | 43 // normalized coords. We apply this matrix to the vertex positions rather th
an local coords. |
| 44 mat.setIDiv(result->width(), result->height()); | 44 mat.setIDiv(result->width(), result->height()); |
| 45 mat.preTranslate(SkIntToScalar(-devBound.fLeft), | 45 mat.preTranslate(SkIntToScalar(-devBound.fLeft), |
| 46 SkIntToScalar(-devBound.fTop)); | 46 SkIntToScalar(-devBound.fTop)); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 default: | 338 default: |
| 339 // something is wrong if we're trying to draw an empty element. | 339 // something is wrong if we're trying to draw an empty element. |
| 340 GrCrash("Unexpected element type"); | 340 GrCrash("Unexpected element type"); |
| 341 return false; | 341 return false; |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 void GrClipMaskManager::mergeMask(GrTexture* dstMask, | 345 void GrClipMaskManager::mergeMask(GrTexture* dstMask, |
| 346 GrTexture* srcMask, | 346 GrTexture* srcMask, |
| 347 SkRegion::Op op, | 347 SkRegion::Op op, |
| 348 const GrIRect& dstBound, | 348 const SkIRect& dstBound, |
| 349 const GrIRect& srcBound) { | 349 const SkIRect& srcBound) { |
| 350 GrDrawState::AutoViewMatrixRestore avmr; | 350 GrDrawState::AutoViewMatrixRestore avmr; |
| 351 GrDrawState* drawState = fGpu->drawState(); | 351 GrDrawState* drawState = fGpu->drawState(); |
| 352 SkAssertResult(avmr.setIdentity(drawState)); | 352 SkAssertResult(avmr.setIdentity(drawState)); |
| 353 GrDrawState::AutoRestoreEffects are(drawState); | 353 GrDrawState::AutoRestoreEffects are(drawState); |
| 354 | 354 |
| 355 drawState->setRenderTarget(dstMask->asRenderTarget()); | 355 drawState->setRenderTarget(dstMask->asRenderTarget()); |
| 356 | 356 |
| 357 setup_boolean_blendcoeffs(drawState, op); | 357 setup_boolean_blendcoeffs(drawState, op); |
| 358 | 358 |
| 359 SkMatrix sampleM; | 359 SkMatrix sampleM; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 bool invert = element->isInverseFilled(); | 475 bool invert = element->isInverseFilled(); |
| 476 | 476 |
| 477 if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDiffere
nce_Op == op) { | 477 if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDiffere
nce_Op == op) { |
| 478 GrPathRenderer* pr = NULL; | 478 GrPathRenderer* pr = NULL; |
| 479 bool useTemp = !this->canStencilAndDrawElement(result, element, &pr)
; | 479 bool useTemp = !this->canStencilAndDrawElement(result, element, &pr)
; |
| 480 GrTexture* dst; | 480 GrTexture* dst; |
| 481 // This is the bounds of the clip element in the space of the alpha-
mask. The temporary | 481 // This is the bounds of the clip element in the space of the alpha-
mask. The temporary |
| 482 // mask buffer can be substantially larger than the actually clip st
ack element. We | 482 // mask buffer can be substantially larger than the actually clip st
ack element. We |
| 483 // touch the minimum number of pixels necessary and use decal mode t
o combine it with | 483 // touch the minimum number of pixels necessary and use decal mode t
o combine it with |
| 484 // the accumulator. | 484 // the accumulator. |
| 485 GrIRect maskSpaceElementIBounds; | 485 SkIRect maskSpaceElementIBounds; |
| 486 | 486 |
| 487 if (useTemp) { | 487 if (useTemp) { |
| 488 if (invert) { | 488 if (invert) { |
| 489 maskSpaceElementIBounds = maskSpaceIBounds; | 489 maskSpaceElementIBounds = maskSpaceIBounds; |
| 490 } else { | 490 } else { |
| 491 GrRect elementBounds = element->getBounds(); | 491 SkRect elementBounds = element->getBounds(); |
| 492 elementBounds.offset(clipToMaskOffset); | 492 elementBounds.offset(clipToMaskOffset); |
| 493 elementBounds.roundOut(&maskSpaceElementIBounds); | 493 elementBounds.roundOut(&maskSpaceElementIBounds); |
| 494 } | 494 } |
| 495 | 495 |
| 496 this->getTemp(maskSpaceIBounds.fRight, maskSpaceIBounds.fBottom,
&temp); | 496 this->getTemp(maskSpaceIBounds.fRight, maskSpaceIBounds.fBottom,
&temp); |
| 497 if (NULL == temp.texture()) { | 497 if (NULL == temp.texture()) { |
| 498 fAACache.reset(); | 498 fAACache.reset(); |
| 499 return NULL; | 499 return NULL; |
| 500 } | 500 } |
| 501 dst = temp.texture(); | 501 dst = temp.texture(); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 | 1001 |
| 1002 //////////////////////////////////////////////////////////////////////////////// | 1002 //////////////////////////////////////////////////////////////////////////////// |
| 1003 void GrClipMaskManager::releaseResources() { | 1003 void GrClipMaskManager::releaseResources() { |
| 1004 fAACache.releaseResources(); | 1004 fAACache.releaseResources(); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 void GrClipMaskManager::setGpu(GrGpu* gpu) { | 1007 void GrClipMaskManager::setGpu(GrGpu* gpu) { |
| 1008 fGpu = gpu; | 1008 fGpu = gpu; |
| 1009 fAACache.setContext(gpu->getContext()); | 1009 fAACache.setContext(gpu->getContext()); |
| 1010 } | 1010 } |
| OLD | NEW |