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 "effects/GrTextureDomainEffect.h" | 10 #include "effects/GrTextureDomainEffect.h" |
(...skipping 22 matching lines...) Expand all Loading... |
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 GrIRect &devBound) { |
37 GrDrawState* drawState = gpu->drawState(); | 37 GrDrawState* drawState = gpu->drawState(); |
38 GrAssert(drawState); | 38 GrAssert(drawState); |
39 | 39 |
40 static const int kMaskStage = GrPaint::kTotalStages+1; | 40 static const int kMaskStage = GrPaint::kTotalStages+1; |
41 | 41 |
42 SkMatrix mat; | 42 SkMatrix mat; |
| 43 // We want to use device coords to compute the texture coordinates. We set o
ur matrix to be |
| 44 // equal to the view matrix followed by an offset to the devBound, and then
a scaling matrix to |
| 45 // normalized coords. We apply this matrix to the vertex positions rather th
an local coords. |
43 mat.setIDiv(result->width(), result->height()); | 46 mat.setIDiv(result->width(), result->height()); |
44 mat.preTranslate(SkIntToScalar(-devBound.fLeft), | 47 mat.preTranslate(SkIntToScalar(-devBound.fLeft), |
45 SkIntToScalar(-devBound.fTop)); | 48 SkIntToScalar(-devBound.fTop)); |
46 mat.preConcat(drawState->getViewMatrix()); | 49 mat.preConcat(drawState->getViewMatrix()); |
47 | 50 |
48 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); | 51 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); |
49 // This could be a long-lived effect that is cached with the alpha-mask. | 52 // This could be a long-lived effect that is cached with the alpha-mask. |
50 drawState->setEffect(kMaskStage, | 53 drawState->setEffect(kMaskStage, |
51 GrTextureDomainEffect::Create(result, | 54 GrTextureDomainEffect::Create(result, |
52 mat, | 55 mat, |
53 GrTextureDomainEffect::MakeTexelDomain(res
ult, domainTexels), | 56 GrTextureDomainEffect::MakeTexelDomain(res
ult, domainTexels), |
54 GrTextureDomainEffect::kDecal_WrapMode))->
unref(); | 57 GrTextureDomainEffect::kDecal_WrapMode, |
| 58 false, |
| 59 GrEffect::kPosition_CoordsType))->unref(); |
55 } | 60 } |
56 | 61 |
57 bool path_needs_SW_renderer(GrContext* context, | 62 bool path_needs_SW_renderer(GrContext* context, |
58 GrGpu* gpu, | 63 GrGpu* gpu, |
59 const SkPath& origPath, | 64 const SkPath& origPath, |
60 const SkStrokeRec& stroke, | 65 const SkStrokeRec& stroke, |
61 bool doAA) { | 66 bool doAA) { |
62 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b
uffer | 67 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b
uffer |
63 SkTCopyOnFirstWrite<SkPath> path(origPath); | 68 SkTCopyOnFirstWrite<SkPath> path(origPath); |
64 if (path->isInverseFillType()) { | 69 if (path->isInverseFillType()) { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 drawState->setRenderTarget(dstMask->asRenderTarget()); | 352 drawState->setRenderTarget(dstMask->asRenderTarget()); |
348 | 353 |
349 setup_boolean_blendcoeffs(drawState, op); | 354 setup_boolean_blendcoeffs(drawState, op); |
350 | 355 |
351 SkMatrix sampleM; | 356 SkMatrix sampleM; |
352 sampleM.setIDiv(srcMask->width(), srcMask->height()); | 357 sampleM.setIDiv(srcMask->width(), srcMask->height()); |
353 drawState->setEffect(0, | 358 drawState->setEffect(0, |
354 GrTextureDomainEffect::Create(srcMask, | 359 GrTextureDomainEffect::Create(srcMask, |
355 sampleM, | 360 sampleM, |
356 GrTextureDomainEffect::MakeTexelDomain(src
Mask, srcBound), | 361 GrTextureDomainEffect::MakeTexelDomain(src
Mask, srcBound), |
357 GrTextureDomainEffect::kDecal_WrapMode))->
unref(); | 362 GrTextureDomainEffect::kDecal_WrapMode, |
| 363 false))->unref(); |
358 fGpu->drawSimpleRect(SkRect::MakeFromIRect(dstBound), NULL); | 364 fGpu->drawSimpleRect(SkRect::MakeFromIRect(dstBound), NULL); |
359 | 365 |
360 drawState->disableStage(0); | 366 drawState->disableStage(0); |
361 drawState->setViewMatrix(oldMatrix); | 367 drawState->setViewMatrix(oldMatrix); |
362 } | 368 } |
363 | 369 |
364 // get a texture to act as a temporary buffer for AA clip boolean operations | 370 // get a texture to act as a temporary buffer for AA clip boolean operations |
365 // TODO: given the expense of createTexture we may want to just cache this too | 371 // TODO: given the expense of createTexture we may want to just cache this too |
366 void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* tem
p) { | 372 void GrClipMaskManager::getTemp(int width, int height, GrAutoScratchTexture* tem
p) { |
367 if (NULL != temp->texture()) { | 373 if (NULL != temp->texture()) { |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 | 999 |
994 //////////////////////////////////////////////////////////////////////////////// | 1000 //////////////////////////////////////////////////////////////////////////////// |
995 void GrClipMaskManager::releaseResources() { | 1001 void GrClipMaskManager::releaseResources() { |
996 fAACache.releaseResources(); | 1002 fAACache.releaseResources(); |
997 } | 1003 } |
998 | 1004 |
999 void GrClipMaskManager::setGpu(GrGpu* gpu) { | 1005 void GrClipMaskManager::setGpu(GrGpu* gpu) { |
1000 fGpu = gpu; | 1006 fGpu = gpu; |
1001 fAACache.setContext(gpu->getContext()); | 1007 fAACache.setContext(gpu->getContext()); |
1002 } | 1008 } |
OLD | NEW |