| 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 18 matching lines...) Expand all Loading... |
| 29 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
| 30 namespace { | 30 namespace { |
| 31 // set up the draw state to enable the aa clipping mask. Besides setting up the | 31 // set up the draw state to enable the aa clipping mask. Besides setting up the |
| 32 // stage matrix this also alters the vertex layout | 32 // stage matrix this also alters the vertex layout |
| 33 void setup_drawstate_aaclip(const SkIRect &devBound, | 33 void setup_drawstate_aaclip(const SkIRect &devBound, |
| 34 GrDrawState* drawState, | 34 GrDrawState* drawState, |
| 35 GrTexture* result) { | 35 GrTexture* result) { |
| 36 SkASSERT(drawState); | 36 SkASSERT(drawState); |
| 37 | 37 |
| 38 SkMatrix mat; | 38 SkMatrix mat; |
| 39 // We want to use device coords to compute the texture coordinates. We set o
ur matrix to be | 39 // We use device coords to compute the texture coordinates. We set our matri
x to be a |
| 40 // equal to the view matrix followed by an offset to the devBound, and then
a scaling matrix to | 40 // translation to the devBound, and then a scaling matrix to normalized coor
ds. |
| 41 // normalized coords. We apply this matrix to the vertex positions rather th
an local coords. | |
| 42 mat.setIDiv(result->width(), result->height()); | 41 mat.setIDiv(result->width(), result->height()); |
| 43 mat.preTranslate(SkIntToScalar(-devBound.fLeft), | 42 mat.preTranslate(SkIntToScalar(-devBound.fLeft), |
| 44 SkIntToScalar(-devBound.fTop)); | 43 SkIntToScalar(-devBound.fTop)); |
| 45 mat.preConcat(drawState->getViewMatrix()); | |
| 46 | 44 |
| 47 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); | 45 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); |
| 48 // This could be a long-lived effect that is cached with the alpha-mask. | 46 // This could be a long-lived effect that is cached with the alpha-mask. |
| 49 drawState->addCoverageProcessor( | 47 drawState->addCoverageProcessor( |
| 50 GrTextureDomainEffect::Create(result, | 48 GrTextureDomainEffect::Create(result, |
| 51 mat, | 49 mat, |
| 52 GrTextureDomain::MakeTexelDomain(result, d
omainTexels), | 50 GrTextureDomain::MakeTexelDomain(result, d
omainTexels), |
| 53 GrTextureDomain::kDecal_Mode, | 51 GrTextureDomain::kDecal_Mode, |
| 54 GrTextureParams::kNone_FilterMode, | 52 GrTextureParams::kNone_FilterMode, |
| 55 kPosition_GrCoordSet))->unref(); | 53 kDevice_GrCoordSet))->unref(); |
| 56 } | 54 } |
| 57 | 55 |
| 58 bool path_needs_SW_renderer(GrContext* context, | 56 bool path_needs_SW_renderer(GrContext* context, |
| 59 const GrDrawTarget* gpu, | 57 const GrDrawTarget* gpu, |
| 60 const GrDrawState* drawState, | 58 const GrDrawState* drawState, |
| 61 const SkPath& origPath, | 59 const SkPath& origPath, |
| 62 const SkStrokeRec& stroke, | 60 const SkStrokeRec& stroke, |
| 63 bool doAA) { | 61 bool doAA) { |
| 64 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b
uffer | 62 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b
uffer |
| 65 SkTCopyOnFirstWrite<SkPath> path(origPath); | 63 SkTCopyOnFirstWrite<SkPath> path(origPath); |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 } | 1058 } |
| 1061 | 1059 |
| 1062 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, | 1060 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, |
| 1063 GrStencilSettings* settings) { | 1061 GrStencilSettings* settings) { |
| 1064 // TODO: dynamically attach a stencil buffer | 1062 // TODO: dynamically attach a stencil buffer |
| 1065 if (stencilBuffer) { | 1063 if (stencilBuffer) { |
| 1066 int stencilBits = stencilBuffer->bits(); | 1064 int stencilBits = stencilBuffer->bits(); |
| 1067 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1065 this->adjustStencilParams(settings, fClipMode, stencilBits); |
| 1068 } | 1066 } |
| 1069 } | 1067 } |
| OLD | NEW |