| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrDistanceFieldTextContext.h" |
| 9 | #include "GrAtlas.h" |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 10 | #include "SkColorFilter.h" |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 11 | #include "GrDrawTarget.h" |
| commit-bot@chromium.org | 6c89c34 | 2014-02-14 21:48:29 +0000 | [diff] [blame] | 12 | #include "GrDrawTargetCaps.h" |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 13 | #include "GrFontScaler.h" |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 14 | #include "SkGlyphCache.h" |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 15 | #include "GrGpu.h" |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 16 | #include "GrIndexBuffer.h" |
| egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 17 | #include "GrStrokeInfo.h" |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 18 | #include "GrTextStrike.h" |
| 19 | #include "GrTextStrike_impl.h" |
| commit-bot@chromium.org | 64b08a1 | 2014-04-15 17:53:21 +0000 | [diff] [blame] | 20 | #include "SkDistanceFieldGen.h" |
| commit-bot@chromium.org | 9f94b91 | 2014-01-30 15:22:54 +0000 | [diff] [blame] | 21 | #include "SkDraw.h" |
| commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 22 | #include "SkGpuDevice.h" |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 23 | #include "SkPath.h" |
| 24 | #include "SkRTConf.h" |
| 25 | #include "SkStrokeRec.h" |
| 26 | #include "effects/GrDistanceFieldTextureEffect.h" |
| 27 | |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 28 | SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
| 29 | "Dump the contents of the font cache before every purge."); |
| 30 | |
| 31 | static const int kGlyphCoordsNoColorAttributeIndex = 1; |
| 32 | static const int kGlyphCoordsWithColorAttributeIndex = 2; |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 33 | |
| commit-bot@chromium.org | dc5cd85 | 2014-04-02 19:24:32 +0000 | [diff] [blame] | 34 | static const int kSmallDFFontSize = 32; |
| 35 | static const int kSmallDFFontLimit = 32; |
| 36 | static const int kMediumDFFontSize = 64; |
| 37 | static const int kMediumDFFontLimit = 64; |
| 38 | static const int kLargeDFFontSize = 128; |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 39 | |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 40 | namespace { |
| 41 | // position + texture coord |
| 42 | extern const GrVertexAttrib gTextVertexAttribs[] = { |
| 43 | {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, |
| 44 | {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding} |
| 45 | }; |
| 46 | |
| 47 | // position + color + texture coord |
| 48 | extern const GrVertexAttrib gTextVertexWithColorAttribs[] = { |
| 49 | {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, |
| 50 | {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVertexAttribBinding}, |
| 51 | {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVertexAttribBinding} |
| 52 | }; |
| 53 | |
| 54 | }; |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 55 | |
| skia.committer@gmail.com | e5d7015 | 2014-01-29 07:01:48 +0000 | [diff] [blame] | 56 | GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, |
| commit-bot@chromium.org | 6fcd1ef | 2014-05-02 12:39:41 +0000 | [diff] [blame] | 57 | const SkDeviceProperties& properties, |
| 58 | bool enable) |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 59 | : GrTextContext(context, properties) { |
| commit-bot@chromium.org | 6fcd1ef | 2014-05-02 12:39:41 +0000 | [diff] [blame] | 60 | #if SK_FORCE_DISTANCEFIELD_FONTS |
| 61 | fEnableDFRendering = true; |
| 62 | #else |
| 63 | fEnableDFRendering = enable; |
| 64 | #endif |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 65 | fStrike = NULL; |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 66 | fGammaTexture = NULL; |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 67 | |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 68 | fCurrVertex = 0; |
| jvanverth | 78f0718 | 2014-07-30 06:17:59 -0700 | [diff] [blame] | 69 | fEffectTextureUniqueID = SK_InvalidUniqueID; |
| 70 | fEffectColor = GrColor_ILLEGAL; |
| 71 | fEffectFlags = 0; |
| 72 | |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 73 | fVertices = NULL; |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { |
| 77 | this->flushGlyphs(); |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 78 | SkSafeSetNull(fGammaTexture); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 81 | bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) { |
| commit-bot@chromium.org | 6fcd1ef | 2014-05-02 12:39:41 +0000 | [diff] [blame] | 82 | if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP()) { |
| commit-bot@chromium.org | eefd8a0 | 2014-04-08 20:14:32 +0000 | [diff] [blame] | 83 | return false; |
| 84 | } |
| 85 | |
| skia.committer@gmail.com | e1d9443 | 2014-04-09 03:04:11 +0000 | [diff] [blame] | 86 | // rasterizers and mask filters modify alpha, which doesn't |
| commit-bot@chromium.org | eefd8a0 | 2014-04-08 20:14:32 +0000 | [diff] [blame] | 87 | // translate well to distance |
| 88 | if (paint.getRasterizer() || paint.getMaskFilter() || |
| 89 | !fContext->getTextTarget()->caps()->shaderDerivativeSupport()) { |
| 90 | return false; |
| 91 | } |
| 92 | |
| 93 | // TODO: add some stroking support |
| 94 | if (paint.getStyle() != SkPaint::kFill_Style) { |
| 95 | return false; |
| 96 | } |
| 97 | |
| 98 | // TODO: choose an appropriate maximum scale for distance fields and |
| 99 | // enable perspective |
| 100 | if (SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix())) { |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | // distance fields cannot represent color fonts |
| 105 | SkScalerContext::Rec rec; |
| 106 | SkScalerContext::MakeRec(paint, &fDeviceProperties, NULL, &rec); |
| 107 | return rec.getFormat() != SkMask::kARGB32_Format; |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 108 | } |
| 109 | |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 110 | static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { |
| 111 | unsigned r = SkColorGetR(c); |
| 112 | unsigned g = SkColorGetG(c); |
| 113 | unsigned b = SkColorGetB(c); |
| 114 | return GrColorPackRGBA(r, g, b, 0xff); |
| 115 | } |
| 116 | |
| jvanverth | 78f0718 | 2014-07-30 06:17:59 -0700 | [diff] [blame] | 117 | void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColor) { |
| 118 | GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode); |
| 119 | GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode); |
| 120 | |
| 121 | GrTexture* currTexture = fStrike->getTexture(); |
| 122 | SkASSERT(currTexture); |
| 123 | uint32_t textureUniqueID = currTexture->getUniqueID(); |
| 124 | |
| 125 | // set up any flags |
| 126 | uint32_t flags = 0; |
| 127 | flags |= fContext->getMatrix().isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; |
| 128 | flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; |
| 129 | flags |= fUseLCDText && fContext->getMatrix().rectStaysRect() ? |
| 130 | kRectToRect_DistanceFieldEffectFlag : 0; |
| 131 | bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout == |
| 132 | fDeviceProperties.fGeometry.getLayout(); |
| 133 | flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0; |
| 134 | |
| 135 | // see if we need to create a new effect |
| 136 | if (textureUniqueID != fEffectTextureUniqueID || |
| 137 | filteredColor != fEffectColor || |
| 138 | flags != fEffectFlags) { |
| 139 | if (fUseLCDText) { |
| 140 | GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor); |
| 141 | fCachedEffect.reset(GrDistanceFieldLCDTextureEffect::Create(currTexture, |
| 142 | params, |
| 143 | fGammaTexture, |
| 144 | gammaParams, |
| 145 | colorNoPreMul, |
| 146 | flags)); |
| 147 | } else { |
| 148 | #ifdef SK_GAMMA_APPLY_TO_A8 |
| 149 | U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.fGamma, |
| 150 | filteredColor); |
| 151 | fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(currTexture, |
| 152 | params, |
| 153 | fGammaTexture, |
| 154 | gammaParams, |
| 155 | lum/255.f, |
| 156 | flags)); |
| 157 | #else |
| 158 | fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(currTexture, |
| 159 | params, flags)); |
| 160 | #endif |
| 161 | } |
| 162 | fEffectTextureUniqueID = textureUniqueID; |
| 163 | fEffectColor = filteredColor; |
| 164 | fEffectFlags = flags; |
| 165 | } |
| 166 | |
| 167 | } |
| 168 | |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 169 | void GrDistanceFieldTextContext::flushGlyphs() { |
| 170 | if (NULL == fDrawTarget) { |
| 171 | return; |
| 172 | } |
| 173 | |
| 174 | GrDrawState* drawState = fDrawTarget->drawState(); |
| 175 | GrDrawState::AutoRestoreEffects are(drawState); |
| 176 | drawState->setFromPaint(fPaint, fContext->getMatrix(), fContext->getRenderTarget()); |
| 177 | |
| 178 | if (fCurrVertex > 0) { |
| 179 | // setup our sampler state for our text texture/atlas |
| commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 180 | SkASSERT(SkIsAlign4(fCurrVertex)); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 181 | |
| jvanverth | 78f0718 | 2014-07-30 06:17:59 -0700 | [diff] [blame] | 182 | // get our current color |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 183 | SkColor filteredColor; |
| 184 | SkColorFilter* colorFilter = fSkPaint.getColorFilter(); |
| 185 | if (NULL != colorFilter) { |
| 186 | filteredColor = colorFilter->filterColor(fSkPaint.getColor()); |
| 187 | } else { |
| 188 | filteredColor = fSkPaint.getColor(); |
| 189 | } |
| jvanverth | 78f0718 | 2014-07-30 06:17:59 -0700 | [diff] [blame] | 190 | this->setupCoverageEffect(filteredColor); |
| 191 | |
| 192 | // Effects could be stored with one of the cache objects (atlas?) |
| 193 | int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithColorAttributeIndex : |
| 194 | kGlyphCoordsNoColorAttributeIndex; |
| 195 | drawState->addCoverageEffect(fCachedEffect.get(), coordsIdx); |
| 196 | |
| 197 | // Set draw state |
| commit-bot@chromium.org | 609ced4 | 2014-04-03 18:25:48 +0000 | [diff] [blame] | 198 | if (fUseLCDText) { |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 199 | GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 200 | if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || |
| 201 | kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || |
| 202 | fPaint.numColorStages()) { |
| 203 | GrPrintf("LCD Text will not draw correctly.\n"); |
| 204 | } |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 205 | SkASSERT(!drawState->hasColorVertexAttribute()); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 206 | // We don't use the GrPaint's color in this case because it's been premultiplied by |
| 207 | // alpha. Instead we feed in a non-premultiplied color, and multiply its alpha by |
| 208 | // the mask texture color. The end result is that we get |
| 209 | // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstColor |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 210 | int a = SkColorGetA(fSkPaint.getColor()); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 211 | // paintAlpha |
| 212 | drawState->setColor(SkColorSetARGB(a, a, a, a)); |
| 213 | // paintColor |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 214 | drawState->setBlendConstant(colorNoPreMul); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 215 | drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff); |
| 216 | } else { |
| 217 | // set back to normal in case we took LCD path previously. |
| 218 | drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlendCoeff()); |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 219 | //drawState->setColor(fPaint.getColor()); |
| 220 | // We're using per-vertex color. |
| 221 | SkASSERT(drawState->hasColorVertexAttribute()); |
| 222 | drawState->setColor(0xFFFFFFFF); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 223 | } |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 224 | int nGlyphs = fCurrVertex / 4; |
| 225 | fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
| 226 | fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, |
| 227 | nGlyphs, |
| 228 | 4, 6); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 229 | fCurrVertex = 0; |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 230 | } |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 231 | fDrawTarget->resetVertexSource(); |
| 232 | fVertices = NULL; |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 233 | } |
| 234 | |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 235 | void GrDistanceFieldTextContext::drawPackedGlyph(GrGlyph::PackedID packed, |
| commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 236 | SkFixed vx, SkFixed vy, |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 237 | GrFontScaler* scaler) { |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 238 | GrGlyph* glyph = fStrike->getGlyph(packed, scaler); |
| 239 | if (NULL == glyph || glyph->fBounds.isEmpty()) { |
| 240 | return; |
| 241 | } |
| 242 | |
| 243 | SkScalar sx = SkFixedToScalar(vx); |
| 244 | SkScalar sy = SkFixedToScalar(vy); |
| 245 | /* |
| 246 | // not valid, need to find a different solution for this |
| 247 | vx += SkIntToFixed(glyph->fBounds.fLeft); |
| 248 | vy += SkIntToFixed(glyph->fBounds.fTop); |
| skia.committer@gmail.com | 11a253b | 2013-11-12 07:02:05 +0000 | [diff] [blame] | 249 | |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 250 | // keep them as ints until we've done the clip-test |
| 251 | GrFixed width = glyph->fBounds.width(); |
| 252 | GrFixed height = glyph->fBounds.height(); |
| 253 | |
| 254 | // check if we clipped out |
| 255 | if (true || NULL == glyph->fPlot) { |
| 256 | int x = vx >> 16; |
| 257 | int y = vy >> 16; |
| 258 | if (fClipRect.quickReject(x, y, x + width, y + height)) { |
| 259 | // SkCLZ(3); // so we can set a break-point in the debugger |
| 260 | return; |
| 261 | } |
| 262 | } |
| 263 | */ |
| 264 | if (NULL == glyph->fPlot) { |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 265 | if (fStrike->addGlyphToAtlas(glyph, scaler)) { |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 266 | goto HAS_ATLAS; |
| 267 | } |
| 268 | |
| 269 | // try to clear out an unused plot before we flush |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 270 | if (fContext->getFontCache()->freeUnusedPlot(fStrike) && |
| 271 | fStrike->addGlyphToAtlas(glyph, scaler)) { |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 272 | goto HAS_ATLAS; |
| 273 | } |
| 274 | |
| 275 | if (c_DumpFontCache) { |
| 276 | #ifdef SK_DEVELOPER |
| 277 | fContext->getFontCache()->dump(); |
| 278 | #endif |
| 279 | } |
| 280 | |
| 281 | // before we purge the cache, we must flush any accumulated draws |
| 282 | this->flushGlyphs(); |
| 283 | fContext->flush(); |
| 284 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 285 | // we should have an unused plot now |
| 286 | if (fContext->getFontCache()->freeUnusedPlot(fStrike) && |
| 287 | fStrike->addGlyphToAtlas(glyph, scaler)) { |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 288 | goto HAS_ATLAS; |
| 289 | } |
| 290 | |
| 291 | if (NULL == glyph->fPath) { |
| 292 | SkPath* path = SkNEW(SkPath); |
| 293 | if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
| 294 | // flag the glyph as being dead? |
| 295 | delete path; |
| 296 | return; |
| 297 | } |
| 298 | glyph->fPath = path; |
| 299 | } |
| 300 | |
| 301 | GrContext::AutoMatrix am; |
| commit-bot@chromium.org | 762cd80 | 2014-04-14 22:05:07 +0000 | [diff] [blame] | 302 | SkMatrix ctm; |
| 303 | ctm.setScale(fTextRatio, fTextRatio); |
| 304 | ctm.postTranslate(sx, sy); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 305 | GrPaint tmpPaint(fPaint); |
| commit-bot@chromium.org | 762cd80 | 2014-04-14 22:05:07 +0000 | [diff] [blame] | 306 | am.setPreConcat(fContext, ctm, &tmpPaint); |
| egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 307 | GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); |
| 308 | fContext->drawPath(tmpPaint, *glyph->fPath, strokeInfo); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 309 | return; |
| 310 | } |
| 311 | |
| 312 | HAS_ATLAS: |
| 313 | SkASSERT(glyph->fPlot); |
| 314 | GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); |
| 315 | glyph->fPlot->setDrawToken(drawToken); |
| 316 | |
| 317 | GrTexture* texture = glyph->fPlot->texture(); |
| 318 | SkASSERT(texture); |
| 319 | |
| commit-bot@chromium.org | 64b08a1 | 2014-04-15 17:53:21 +0000 | [diff] [blame] | 320 | SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft + SK_DistanceFieldInset); |
| 321 | SkScalar dy = SkIntToScalar(glyph->fBounds.fTop + SK_DistanceFieldInset); |
| 322 | SkScalar width = SkIntToScalar(glyph->fBounds.width() - 2*SK_DistanceFieldInset); |
| 323 | SkScalar height = SkIntToScalar(glyph->fBounds.height() - 2*SK_DistanceFieldInset); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 324 | |
| 325 | SkScalar scale = fTextRatio; |
| 326 | dx *= scale; |
| 327 | dy *= scale; |
| 328 | sx += dx; |
| 329 | sy += dy; |
| 330 | width *= scale; |
| 331 | height *= scale; |
| skia.committer@gmail.com | a3b5327 | 2014-02-15 03:02:15 +0000 | [diff] [blame] | 332 | |
| commit-bot@chromium.org | 64b08a1 | 2014-04-15 17:53:21 +0000 | [diff] [blame] | 333 | SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX + SK_DistanceFieldInset); |
| 334 | SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY + SK_DistanceFieldInset); |
| 335 | SkFixed tw = SkIntToFixed(glyph->fBounds.width() - 2*SK_DistanceFieldInset); |
| 336 | SkFixed th = SkIntToFixed(glyph->fBounds.height() - 2*SK_DistanceFieldInset); |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 337 | |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 338 | size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint)) |
| 339 | : (2 * sizeof(SkPoint) + sizeof(GrColor)); |
| 340 | |
| 341 | SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexSize()); |
| 342 | |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 343 | SkPoint* positions = reinterpret_cast<SkPoint*>( |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 344 | reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex); |
| 345 | positions->setRectFan(sx, sy, sx + width, sy + height, vertSize); |
| 346 | |
| 347 | // The texture coords are last in both the with and without color vertex layouts. |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 348 | SkPoint* textureCoords = reinterpret_cast<SkPoint*>( |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 349 | reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint)); |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 350 | textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)), |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 351 | SkFixedToFloat(texture->normalizeFixedY(ty)), |
| 352 | SkFixedToFloat(texture->normalizeFixedX(tx + tw)), |
| 353 | SkFixedToFloat(texture->normalizeFixedY(ty + th)), |
| 354 | vertSize); |
| 355 | if (!fUseLCDText) { |
| 356 | // color comes after position. |
| 357 | GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); |
| 358 | for (int i = 0; i < 4; ++i) { |
| 359 | *colors = fPaint.getColor(); |
| 360 | colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors) + vertSize); |
| 361 | } |
| 362 | } |
| 363 | |
| jvanverth@google.com | d830d13 | 2013-11-11 20:54:09 +0000 | [diff] [blame] | 364 | fCurrVertex += 4; |
| 365 | } |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 366 | |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 367 | inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint& skPaint) { |
| 368 | GrTextContext::init(paint, skPaint); |
| 369 | |
| 370 | fStrike = NULL; |
| 371 | |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 372 | fCurrVertex = 0; |
| 373 | |
| 374 | fVertices = NULL; |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 375 | |
| commit-bot@chromium.org | dc5cd85 | 2014-04-02 19:24:32 +0000 | [diff] [blame] | 376 | if (fSkPaint.getTextSize() <= kSmallDFFontLimit) { |
| 377 | fTextRatio = fSkPaint.getTextSize()/kSmallDFFontSize; |
| 378 | fSkPaint.setTextSize(SkIntToScalar(kSmallDFFontSize)); |
| 379 | } else if (fSkPaint.getTextSize() <= kMediumDFFontLimit) { |
| 380 | fTextRatio = fSkPaint.getTextSize()/kMediumDFFontSize; |
| 381 | fSkPaint.setTextSize(SkIntToScalar(kMediumDFFontSize)); |
| 382 | } else { |
| 383 | fTextRatio = fSkPaint.getTextSize()/kLargeDFFontSize; |
| 384 | fSkPaint.setTextSize(SkIntToScalar(kLargeDFFontSize)); |
| 385 | } |
| skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 386 | |
| commit-bot@chromium.org | 609ced4 | 2014-04-03 18:25:48 +0000 | [diff] [blame] | 387 | fUseLCDText = fSkPaint.isLCDRenderText(); |
| skia.committer@gmail.com | 221b911 | 2014-04-04 03:04:32 +0000 | [diff] [blame] | 388 | |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 389 | fSkPaint.setLCDRenderText(false); |
| 390 | fSkPaint.setAutohinted(false); |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 391 | fSkPaint.setHinting(SkPaint::kNormal_Hinting); |
| commit-bot@chromium.org | 0bed43c | 2014-03-14 21:22:38 +0000 | [diff] [blame] | 392 | fSkPaint.setSubpixelText(true); |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 393 | |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | inline void GrDistanceFieldTextContext::finish() { |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 397 | this->flushGlyphs(); |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 398 | |
| 399 | GrTextContext::finish(); |
| 400 | } |
| 401 | |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 402 | static void setup_gamma_texture(GrContext* context, const SkGlyphCache* cache, |
| 403 | const SkDeviceProperties& deviceProperties, |
| 404 | GrTexture** gammaTexture) { |
| 405 | if (NULL == *gammaTexture) { |
| 406 | int width, height; |
| 407 | size_t size; |
| 408 | |
| 409 | #ifdef SK_GAMMA_CONTRAST |
| 410 | SkScalar contrast = SK_GAMMA_CONTRAST; |
| 411 | #else |
| 412 | SkScalar contrast = 0.5f; |
| 413 | #endif |
| 414 | SkScalar paintGamma = deviceProperties.fGamma; |
| 415 | SkScalar deviceGamma = deviceProperties.fGamma; |
| 416 | |
| 417 | size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamma, |
| 418 | &width, &height); |
| 419 | |
| 420 | SkAutoTArray<uint8_t> data((int)size); |
| 421 | SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data.get()); |
| 422 | |
| 423 | // TODO: Update this to use the cache rather than directly creating a texture. |
| 424 | GrTextureDesc desc; |
| 425 | desc.fFlags = kDynamicUpdate_GrTextureFlagBit; |
| 426 | desc.fWidth = width; |
| 427 | desc.fHeight = height; |
| 428 | desc.fConfig = kAlpha_8_GrPixelConfig; |
| 429 | |
| 430 | *gammaTexture = context->getGpu()->createTexture(desc, NULL, 0); |
| 431 | if (NULL == *gammaTexture) { |
| 432 | return; |
| 433 | } |
| 434 | |
| 435 | context->writeTexturePixels(*gammaTexture, |
| 436 | 0, 0, width, height, |
| 437 | (*gammaTexture)->config(), data.get(), 0, |
| 438 | GrContext::kDontFlush_PixelOpsFlag); |
| 439 | } |
| 440 | } |
| 441 | |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 442 | void GrDistanceFieldTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint, |
| 443 | const char text[], size_t byteLength, |
| commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 444 | SkScalar x, SkScalar y) { |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 445 | SkASSERT(byteLength == 0 || text != NULL); |
| 446 | |
| commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 447 | // nothing to draw or can't draw |
| 448 | if (text == NULL || byteLength == 0 /* no raster clip? || fRC->isEmpty()*/ |
| 449 | || fSkPaint.getRasterizer()) { |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 450 | return; |
| 451 | } |
| skia.committer@gmail.com | e5d7015 | 2014-01-29 07:01:48 +0000 | [diff] [blame] | 452 | |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 453 | this->init(paint, skPaint); |
| 454 | |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 455 | if (NULL == fDrawTarget) { |
| 456 | return; |
| 457 | } |
| 458 | |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 459 | SkScalar sizeRatio = fTextRatio; |
| 460 | |
| 461 | SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); |
| 462 | |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 463 | SkAutoGlyphCacheNoGamma autoCache(fSkPaint, &fDeviceProperties, NULL); |
| 464 | SkGlyphCache* cache = autoCache.getCache(); |
| 465 | GrFontScaler* fontScaler = GetGrFontScaler(cache); |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 466 | if (NULL == fStrike) { |
| 467 | fStrike = fContext->getFontCache()->getStrike(fontScaler, true); |
| 468 | } |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 469 | |
| 470 | setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture); |
| skia.committer@gmail.com | e5d7015 | 2014-01-29 07:01:48 +0000 | [diff] [blame] | 471 | |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 472 | // allocate vertices |
| 473 | SkASSERT(NULL == fVertices); |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 474 | if (!fUseLCDText) { |
| 475 | fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>( |
| 476 | SK_ARRAY_COUNT(gTextVertexWithColorAttribs)); |
| 477 | } else { |
| 478 | fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( |
| 479 | SK_ARRAY_COUNT(gTextVertexAttribs)); |
| 480 | } |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 481 | int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
| 482 | bool success = fDrawTarget->reserveVertexAndIndexSpace(4*numGlyphs, |
| 483 | 0, |
| 484 | &fVertices, |
| 485 | NULL); |
| 486 | GrAlwaysAssert(success); |
| 487 | |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 488 | // need to measure first |
| 489 | // TODO - generate positions and pre-load cache as well? |
| 490 | const char* stop = text + byteLength; |
| 491 | if (fSkPaint.getTextAlign() != SkPaint::kLeft_Align) { |
| 492 | SkFixed stopX = 0; |
| 493 | SkFixed stopY = 0; |
| 494 | |
| 495 | const char* textPtr = text; |
| 496 | while (textPtr < stop) { |
| 497 | // don't need x, y here, since all subpixel variants will have the |
| 498 | // same advance |
| 499 | const SkGlyph& glyph = glyphCacheProc(cache, &textPtr, 0, 0); |
| 500 | |
| 501 | stopX += glyph.fAdvanceX; |
| 502 | stopY += glyph.fAdvanceY; |
| 503 | } |
| 504 | SkASSERT(textPtr == stop); |
| 505 | |
| 506 | SkScalar alignX = SkFixedToScalar(stopX)*sizeRatio; |
| 507 | SkScalar alignY = SkFixedToScalar(stopY)*sizeRatio; |
| 508 | |
| 509 | if (fSkPaint.getTextAlign() == SkPaint::kCenter_Align) { |
| 510 | alignX = SkScalarHalf(alignX); |
| 511 | alignY = SkScalarHalf(alignY); |
| 512 | } |
| 513 | |
| 514 | x -= alignX; |
| 515 | y -= alignY; |
| 516 | } |
| 517 | |
| commit-bot@chromium.org | 5408f8f | 2014-05-21 19:44:24 +0000 | [diff] [blame] | 518 | SkFixed fx = SkScalarToFixed(x); |
| 519 | SkFixed fy = SkScalarToFixed(y); |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 520 | SkFixed fixedScale = SkScalarToFixed(sizeRatio); |
| 521 | while (text < stop) { |
| commit-bot@chromium.org | a9dae71 | 2014-03-24 18:34:04 +0000 | [diff] [blame] | 522 | const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 523 | |
| 524 | if (glyph.fWidth) { |
| 525 | this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 526 | glyph.getSubXFixed(), |
| 527 | glyph.getSubYFixed()), |
| commit-bot@chromium.org | 5408f8f | 2014-05-21 19:44:24 +0000 | [diff] [blame] | 528 | fx, |
| 529 | fy, |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 530 | fontScaler); |
| 531 | } |
| 532 | |
| 533 | fx += SkFixedMul_portable(glyph.fAdvanceX, fixedScale); |
| 534 | fy += SkFixedMul_portable(glyph.fAdvanceY, fixedScale); |
| 535 | } |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 536 | |
| 537 | this->finish(); |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 538 | } |
| 539 | |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 540 | void GrDistanceFieldTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPaint, |
| 541 | const char text[], size_t byteLength, |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 542 | const SkScalar pos[], SkScalar constY, |
| commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 543 | int scalarsPerPosition) { |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 544 | |
| 545 | SkASSERT(byteLength == 0 || text != NULL); |
| 546 | SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); |
| 547 | |
| 548 | // nothing to draw |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 549 | if (text == NULL || byteLength == 0 /* no raster clip? || fRC->isEmpty()*/) { |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 550 | return; |
| 551 | } |
| 552 | |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 553 | this->init(paint, skPaint); |
| 554 | |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 555 | if (NULL == fDrawTarget) { |
| 556 | return; |
| 557 | } |
| 558 | |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 559 | SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); |
| 560 | |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 561 | SkAutoGlyphCacheNoGamma autoCache(fSkPaint, &fDeviceProperties, NULL); |
| 562 | SkGlyphCache* cache = autoCache.getCache(); |
| 563 | GrFontScaler* fontScaler = GetGrFontScaler(cache); |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 564 | if (NULL == fStrike) { |
| 565 | fStrike = fContext->getFontCache()->getStrike(fontScaler, true); |
| 566 | } |
| 567 | |
| 568 | // allocate vertices |
| 569 | SkASSERT(NULL == fVertices); |
| jvanverth | feceba5 | 2014-07-25 19:03:34 -0700 | [diff] [blame] | 570 | if (!fUseLCDText) { |
| 571 | fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>( |
| 572 | SK_ARRAY_COUNT(gTextVertexWithColorAttribs)); |
| 573 | } else { |
| 574 | fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( |
| 575 | SK_ARRAY_COUNT(gTextVertexAttribs)); |
| 576 | } |
| jvanverth | f17bc6c | 2014-07-25 16:46:53 -0700 | [diff] [blame] | 577 | int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
| 578 | bool success = fDrawTarget->reserveVertexAndIndexSpace(4*numGlyphs, |
| 579 | 0, |
| 580 | &fVertices, |
| 581 | NULL); |
| 582 | GrAlwaysAssert(success); |
| jvanverth | 2d2a68c | 2014-06-10 06:42:56 -0700 | [diff] [blame] | 583 | |
| 584 | setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture); |
| skia.committer@gmail.com | e5d7015 | 2014-01-29 07:01:48 +0000 | [diff] [blame] | 585 | |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 586 | const char* stop = text + byteLength; |
| 587 | |
| 588 | if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { |
| 589 | while (text < stop) { |
| 590 | // the last 2 parameters are ignored |
| 591 | const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 592 | |
| 593 | if (glyph.fWidth) { |
| 594 | SkScalar x = pos[0]; |
| 595 | SkScalar y = scalarsPerPosition == 1 ? constY : pos[1]; |
| 596 | |
| 597 | this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 598 | glyph.getSubXFixed(), |
| 599 | glyph.getSubYFixed()), |
| commit-bot@chromium.org | 5408f8f | 2014-05-21 19:44:24 +0000 | [diff] [blame] | 600 | SkScalarToFixed(x), |
| 601 | SkScalarToFixed(y), |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 602 | fontScaler); |
| 603 | } |
| 604 | pos += scalarsPerPosition; |
| 605 | } |
| 606 | } else { |
| 607 | int alignShift = SkPaint::kCenter_Align == fSkPaint.getTextAlign() ? 1 : 0; |
| 608 | while (text < stop) { |
| 609 | // the last 2 parameters are ignored |
| 610 | const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 611 | |
| 612 | if (glyph.fWidth) { |
| 613 | SkScalar x = pos[0]; |
| 614 | SkScalar y = scalarsPerPosition == 1 ? constY : pos[1]; |
| skia.committer@gmail.com | 22e9672 | 2013-12-20 07:01:36 +0000 | [diff] [blame] | 615 | |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 616 | this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 617 | glyph.getSubXFixed(), |
| 618 | glyph.getSubYFixed()), |
| commit-bot@chromium.org | 5408f8f | 2014-05-21 19:44:24 +0000 | [diff] [blame] | 619 | SkScalarToFixed(x) - (glyph.fAdvanceX >> alignShift), |
| 620 | SkScalarToFixed(y) - (glyph.fAdvanceY >> alignShift), |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 621 | fontScaler); |
| 622 | } |
| 623 | pos += scalarsPerPosition; |
| 624 | } |
| 625 | } |
| commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 626 | |
| 627 | this->finish(); |
| commit-bot@chromium.org | 8128d8c | 2013-12-19 16:12:25 +0000 | [diff] [blame] | 628 | } |