Chromium Code Reviews| Index: src/gpu/GrDistanceFieldTextContext.cpp |
| diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp |
| index 0aafc544d7831df982c28c21d0ccb4c8fd0c0ad9..c62978462af18ac7a1d452bcebaacd080e59d430 100755 |
| --- a/src/gpu/GrDistanceFieldTextContext.cpp |
| +++ b/src/gpu/GrDistanceFieldTextContext.cpp |
| @@ -130,9 +130,9 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo |
| // set up any flags |
| uint32_t flags = 0; |
| - flags |= fContext->getMatrix().isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; |
| + flags |= fTextMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; |
| flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; |
| - flags |= fUseLCDText && fContext->getMatrix().rectStaysRect() ? |
| + flags |= fUseLCDText && fTextMatrix.rectStaysRect() ? |
| kRectToRect_DistanceFieldEffectFlag : 0; |
| bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout == |
| fDeviceProperties.fGeometry.getLayout(); |
| @@ -179,7 +179,8 @@ void GrDistanceFieldTextContext::flushGlyphs() { |
| GrDrawState* drawState = fDrawTarget->drawState(); |
| GrDrawState::AutoRestoreEffects are(drawState); |
| - drawState->setFromPaint(fPaint, fContext->getMatrix(), fContext->getRenderTarget()); |
| + |
| + drawState->setFromPaint(fPaint, fTextMatrix, fContext->getRenderTarget()); |
| if (fCurrVertex > 0) { |
| // setup our sampler state for our text texture/atlas |
| @@ -198,8 +199,8 @@ void GrDistanceFieldTextContext::flushGlyphs() { |
| // Effects could be stored with one of the cache objects (atlas?) |
| int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithColorAttributeIndex : |
| kGlyphCoordsNoColorAttributeIndex; |
| - drawState->addCoverageEffect(fCachedEffect.get(), coordsIdx); |
| - |
| + drawState->setGeometryProcessor(fCachedEffect.get(), coordsIdx); |
| + |
| // Set draw state |
| if (fUseLCDText) { |
| GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor); |
| @@ -448,18 +449,32 @@ inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint |
| fStrike = NULL; |
| + fTextMatrix = fContext->getMatrix(); |
| + |
| + // getMaxScale doesn't support perspective, so neither do we at the moment |
| + SkASSERT(!fTextMatrix.hasPerspective()); |
| + SkScalar maxScale = fTextMatrix.getMaxScale(); |
| + SkScalar textSize = fSkPaint.getTextSize(); |
| + // if we have non-unity scale, we need to adjust our text size accordingly |
| + // to avoid aliasing, and prescale the matrix by the inverse to end up with the same size |
| + // TODO: do we need to do this if we're scaling down (i.e. maxScale < 1)? |
|
bsalomon
2014/09/15 13:33:19
Should your GM test this?
jvanverth1
2014/09/15 13:43:53
Yes, probably :)
|
| + if (maxScale > 0 && !SkScalarNearlyEqual(maxScale, SK_Scalar1)) { |
| + textSize *= maxScale; |
| + fTextMatrix.preScale(SK_Scalar1 / maxScale, SK_Scalar1 / maxScale); |
| + } |
| + |
| fCurrVertex = 0; |
| fVertices = NULL; |
| - if (fSkPaint.getTextSize() <= kSmallDFFontLimit) { |
| - fTextRatio = fSkPaint.getTextSize()/kSmallDFFontSize; |
| + if (textSize <= kSmallDFFontLimit) { |
| + fTextRatio = textSize / kSmallDFFontSize; |
| fSkPaint.setTextSize(SkIntToScalar(kSmallDFFontSize)); |
| - } else if (fSkPaint.getTextSize() <= kMediumDFFontLimit) { |
| - fTextRatio = fSkPaint.getTextSize()/kMediumDFFontSize; |
| + } else if (textSize <= kMediumDFFontLimit) { |
| + fTextRatio = textSize / kMediumDFFontSize; |
| fSkPaint.setTextSize(SkIntToScalar(kMediumDFFontSize)); |
| } else { |
| - fTextRatio = fSkPaint.getTextSize()/kLargeDFFontSize; |
| + fTextRatio = textSize / kLargeDFFontSize; |
| fSkPaint.setTextSize(SkIntToScalar(kLargeDFFontSize)); |
| } |