diff options
author | 2015-04-21 13:24:37 -0700 | |
---|---|---|
committer | 2015-04-21 13:24:37 -0700 | |
commit | a7c6389ebf19cf58926f7a1616f0e5554c56aa84 (patch) | |
tree | c3cfea44e9125a837fe1e6a72abff4a4dce189ee /src/gpu/GrAtlasTextContext.cpp | |
parent | 8e578859f80b46a63144add215955221017d3609 (diff) |
fix some small bugs with GrAtlasTextContext
BUG=skia:
Review URL: https://codereview.chromium.org/1098093003
Diffstat (limited to 'src/gpu/GrAtlasTextContext.cpp')
-rw-r--r-- | src/gpu/GrAtlasTextContext.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp index c1a46fea9c..5f4f916adc 100644 --- a/src/gpu/GrAtlasTextContext.cpp +++ b/src/gpu/GrAtlasTextContext.cpp @@ -51,6 +51,7 @@ static const int kSmallDFFontLimit = 32; static const int kMediumDFFontSize = 72; static const int kMediumDFFontLimit = 72; static const int kLargeDFFontSize = 162; +static const int kLargeDFFontLimit = 2 * kLargeDFFontSize; SkDEBUGCODE(static const int kExpectedDistanceAdjustTableSize = 8;) static const int kDistanceAdjustLumShift = 5; @@ -326,8 +327,7 @@ bool GrAtlasTextContext::MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTr #endif (*outTransX) = transX; (*outTransY) = transY; - } else { - SkASSERT(blob.hasDistanceField()); + } else if (blob.hasDistanceField()) { // A scale outside of [blob.fMaxMinScale, blob.fMinMaxScale] would result in a different // distance field being generated, so we have to regenerate in those cases SkScalar newMaxScale = viewMatrix.getMaxScale(); @@ -340,6 +340,9 @@ bool GrAtlasTextContext::MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTr (*outTransX) = x - blob.fX; (*outTransY) = y - blob.fY; } + // It is possible that a blob has neither distanceField nor bitmaptext. This is in the case + // when all of the runs inside the blob are drawn as paths. In this case, we always regenerate + // the blob anyways at flush time, so no need to regenerate explicitly return false; } @@ -441,7 +444,7 @@ inline bool GrAtlasTextContext::canDrawAsDistanceFields(const SkPaint& skPaint, SkScalar scaledTextSize = maxScale*skPaint.getTextSize(); // Hinted text looks far better at small resolutions // Scaling up beyond 2x yields undesireable artifacts - if (scaledTextSize < kMinDFFontSize || scaledTextSize > 2 * kLargeDFFontSize) { + if (scaledTextSize < kMinDFFontSize || scaledTextSize > kLargeDFFontLimit) { return false; } @@ -611,17 +614,17 @@ inline void GrAtlasTextContext::initDistanceFieldPaint(BitmapTextBlob* blob, SkScalar dfMaskScaleCeil; if (scaledTextSize <= kSmallDFFontLimit) { dfMaskScaleFloor = kMinDFFontSize; - dfMaskScaleCeil = kMediumDFFontLimit; + dfMaskScaleCeil = kSmallDFFontLimit; *textRatio = textSize / kSmallDFFontSize; skPaint->setTextSize(SkIntToScalar(kSmallDFFontSize)); } else if (scaledTextSize <= kMediumDFFontLimit) { - dfMaskScaleFloor = kMediumDFFontLimit; - dfMaskScaleCeil = kLargeDFFontSize; + dfMaskScaleFloor = kSmallDFFontLimit; + dfMaskScaleCeil = kMediumDFFontLimit; *textRatio = textSize / kMediumDFFontSize; skPaint->setTextSize(SkIntToScalar(kMediumDFFontSize)); } else { - dfMaskScaleFloor = kLargeDFFontSize; - dfMaskScaleCeil = 2 * kLargeDFFontSize; + dfMaskScaleFloor = kMediumDFFontLimit; + dfMaskScaleCeil = kLargeDFFontLimit; *textRatio = textSize / kLargeDFFontSize; skPaint->setTextSize(SkIntToScalar(kLargeDFFontSize)); } @@ -633,6 +636,7 @@ inline void GrAtlasTextContext::initDistanceFieldPaint(BitmapTextBlob* blob, // we look at the delta in scale between the new viewmatrix and the old viewmatrix, and test // against these values to decide if we can reuse or not(ie, will a given scale change our mip // level) + SkASSERT(dfMaskScaleFloor <= scaledTextSize && scaledTextSize <= dfMaskScaleCeil); blob->fMaxMinScale = SkMaxScalar(dfMaskScaleFloor / scaledTextSize, blob->fMaxMinScale); blob->fMinMaxScale = SkMinScalar(dfMaskScaleCeil / scaledTextSize, blob->fMinMaxScale); |