| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 SkIntToScalar(-devBound.fTop)); | 46 SkIntToScalar(-devBound.fTop)); |
| 47 mat.preConcat(drawState->getViewMatrix()); | 47 mat.preConcat(drawState->getViewMatrix()); |
| 48 | 48 |
| 49 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); | 49 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); |
| 50 // This could be a long-lived effect that is cached with the alpha-mask. | 50 // This could be a long-lived effect that is cached with the alpha-mask. |
| 51 drawState->addCoverageEffect( | 51 drawState->addCoverageEffect( |
| 52 GrTextureDomainEffect::Create(result, | 52 GrTextureDomainEffect::Create(result, |
| 53 mat, | 53 mat, |
| 54 GrTextureDomainEffect::MakeTexelDomain(res
ult, domainTexels), | 54 GrTextureDomainEffect::MakeTexelDomain(res
ult, domainTexels), |
| 55 GrTextureDomainEffect::kDecal_WrapMode, | 55 GrTextureDomainEffect::kDecal_WrapMode, |
| 56 false, | 56 GrTextureParams::kNone_FilterMode, |
| 57 GrEffect::kPosition_CoordsType))->unref(); | 57 GrEffect::kPosition_CoordsType))->unref(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool path_needs_SW_renderer(GrContext* context, | 60 bool path_needs_SW_renderer(GrContext* context, |
| 61 GrGpu* gpu, | 61 GrGpu* gpu, |
| 62 const SkPath& origPath, | 62 const SkPath& origPath, |
| 63 const SkStrokeRec& stroke, | 63 const SkStrokeRec& stroke, |
| 64 bool doAA) { | 64 bool doAA) { |
| 65 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b
uffer | 65 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b
uffer |
| 66 SkTCopyOnFirstWrite<SkPath> path(origPath); | 66 SkTCopyOnFirstWrite<SkPath> path(origPath); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 360 sampleM.setIDiv(srcMask->width(), srcMask->height()); | 360 sampleM.setIDiv(srcMask->width(), srcMask->height()); |
| 361 |
| 361 drawState->addColorEffect( | 362 drawState->addColorEffect( |
| 362 GrTextureDomainEffect::Create(srcMask, | 363 GrTextureDomainEffect::Create(srcMask, |
| 363 sampleM, | 364 sampleM, |
| 364 GrTextureDomainEffect::MakeTexelDomain(src
Mask, srcBound), | 365 GrTextureDomainEffect::MakeTexelDomain(src
Mask, srcBound), |
| 365 GrTextureDomainEffect::kDecal_WrapMode, | 366 GrTextureDomainEffect::kDecal_WrapMode, |
| 366 false))->unref(); | 367 GrTextureParams::kNone_FilterMode))->unref
(); |
| 367 fGpu->drawSimpleRect(SkRect::MakeFromIRect(dstBound), NULL); | 368 fGpu->drawSimpleRect(SkRect::MakeFromIRect(dstBound), NULL); |
| 368 } | 369 } |
| 369 | 370 |
| 370 // get a texture to act as a temporary buffer for AA clip boolean operations | 371 // get a texture to act as a temporary buffer for AA clip boolean operations |
| 371 // TODO: given the expense of createTexture we may want to just cache this too | 372 // TODO: given the expense of createTexture we may want to just cache this too |
| 372 void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* tem
p) { | 373 void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* tem
p) { |
| 373 if (NULL != temp->texture()) { | 374 if (NULL != temp->texture()) { |
| 374 // we've already allocated the temp texture | 375 // we've already allocated the temp texture |
| 375 return; | 376 return; |
| 376 } | 377 } |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 | 1002 |
| 1002 //////////////////////////////////////////////////////////////////////////////// | 1003 //////////////////////////////////////////////////////////////////////////////// |
| 1003 void GrClipMaskManager::releaseResources() { | 1004 void GrClipMaskManager::releaseResources() { |
| 1004 fAACache.releaseResources(); | 1005 fAACache.releaseResources(); |
| 1005 } | 1006 } |
| 1006 | 1007 |
| 1007 void GrClipMaskManager::setGpu(GrGpu* gpu) { | 1008 void GrClipMaskManager::setGpu(GrGpu* gpu) { |
| 1008 fGpu = gpu; | 1009 fGpu = gpu; |
| 1009 fAACache.setContext(gpu->getContext()); | 1010 fAACache.setContext(gpu->getContext()); |
| 1010 } | 1011 } |
| OLD | NEW |