OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrDistanceFieldTextContext.h" | 8 #include "GrDistanceFieldTextContext.h" |
9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
11 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
12 #include "GrDrawTargetCaps.h" | 12 #include "GrDrawTargetCaps.h" |
13 #include "GrFontScaler.h" | 13 #include "GrFontScaler.h" |
14 #include "SkGlyphCache.h" | 14 #include "SkGlyphCache.h" |
15 #include "GrGpu.h" | 15 #include "GrGpu.h" |
16 #include "GrIndexBuffer.h" | 16 #include "GrIndexBuffer.h" |
17 #include "GrStrokeInfo.h" | 17 #include "GrStrokeInfo.h" |
18 #include "GrTextStrike.h" | 18 #include "GrTextStrike.h" |
19 #include "GrTextStrike_impl.h" | 19 #include "GrTextStrike_impl.h" |
20 #include "SkDistanceFieldGen.h" | 20 #include "SkDistanceFieldGen.h" |
21 #include "SkDraw.h" | 21 #include "SkDraw.h" |
22 #include "SkGpuDevice.h" | 22 #include "SkGpuDevice.h" |
23 #include "SkPath.h" | 23 #include "SkPath.h" |
24 #include "SkRTConf.h" | 24 #include "SkRTConf.h" |
25 #include "SkStrokeRec.h" | 25 #include "SkStrokeRec.h" |
26 #include "effects/GrDistanceFieldTextureEffect.h" | 26 #include "effects/GrDistanceFieldTextureEffect.h" |
27 | 27 |
28 static const int kGlyphCoordsAttributeIndex = 1; | 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; |
29 | 33 |
30 static const int kSmallDFFontSize = 32; | 34 static const int kSmallDFFontSize = 32; |
31 static const int kSmallDFFontLimit = 32; | 35 static const int kSmallDFFontLimit = 32; |
32 static const int kMediumDFFontSize = 64; | 36 static const int kMediumDFFontSize = 64; |
33 static const int kMediumDFFontLimit = 64; | 37 static const int kMediumDFFontLimit = 64; |
34 static const int kLargeDFFontSize = 128; | 38 static const int kLargeDFFontSize = 128; |
35 | 39 |
36 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 40 namespace { |
37 "Dump the contents of the font cache before every purge."); | 41 // position + texture coord |
| 42 extern const GrVertexAttrib gTextVertexAttribs[] = { |
| 43 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin
g}, |
| 44 {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding} |
| 45 }; |
| 46 |
| 47 // position + color + texture coord |
| 48 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = { |
| 49 {kVec2f_GrVertexAttribType, 0, kPosition_Gr
VertexAttribBinding}, |
| 50 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer
texAttribBinding}, |
| 51 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVe
rtexAttribBinding} |
| 52 }; |
| 53 |
| 54 }; |
38 | 55 |
39 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, | 56 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, |
40 const SkDeviceProperties&
properties, | 57 const SkDeviceProperties&
properties, |
41 bool enable) | 58 bool enable) |
42 : GrTextContext(context, pro
perties) { | 59 : GrTextContext(context, pro
perties) { |
43 #if SK_FORCE_DISTANCEFIELD_FONTS | 60 #if SK_FORCE_DISTANCEFIELD_FONTS |
44 fEnableDFRendering = true; | 61 fEnableDFRendering = true; |
45 #else | 62 #else |
46 fEnableDFRendering = enable; | 63 fEnableDFRendering = enable; |
47 #endif | 64 #endif |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 122 |
106 if (fCurrVertex > 0) { | 123 if (fCurrVertex > 0) { |
107 // setup our sampler state for our text texture/atlas | 124 // setup our sampler state for our text texture/atlas |
108 SkASSERT(SkIsAlign4(fCurrVertex)); | 125 SkASSERT(SkIsAlign4(fCurrVertex)); |
109 GrTexture* currTexture = fStrike->getTexture(); | 126 GrTexture* currTexture = fStrike->getTexture(); |
110 SkASSERT(currTexture); | 127 SkASSERT(currTexture); |
111 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBil
erp_FilterMode); | 128 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBil
erp_FilterMode); |
112 GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::
kNone_FilterMode); | 129 GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::
kNone_FilterMode); |
113 | 130 |
114 // Effects could be stored with one of the cache objects (atlas?) | 131 // Effects could be stored with one of the cache objects (atlas?) |
| 132 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC
olorAttributeIndex : |
| 133 kGlyphCoordsNoCol
orAttributeIndex; |
115 SkColor filteredColor; | 134 SkColor filteredColor; |
116 SkColorFilter* colorFilter = fSkPaint.getColorFilter(); | 135 SkColorFilter* colorFilter = fSkPaint.getColorFilter(); |
117 if (NULL != colorFilter) { | 136 if (NULL != colorFilter) { |
118 filteredColor = colorFilter->filterColor(fSkPaint.getColor()); | 137 filteredColor = colorFilter->filterColor(fSkPaint.getColor()); |
119 } else { | 138 } else { |
120 filteredColor = fSkPaint.getColor(); | 139 filteredColor = fSkPaint.getColor(); |
121 } | 140 } |
122 if (fUseLCDText) { | 141 if (fUseLCDText) { |
123 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); | 142 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol
or); |
124 bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout == | 143 bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout == |
125 fDeviceProperties.fG
eometry.getLayout(); | 144 fDeviceProperties.fG
eometry.getLayout(); |
126 drawState->addCoverageEffect(GrDistanceFieldLCDTextureEffect::Create
( | 145 drawState->addCoverageEffect(GrDistanceFieldLCDTextureEffect::Create
( |
127 currTexture, | 146 currTexture, |
128 params, | 147 params, |
129 fGammaTexture, | 148 fGammaTexture, |
130 gammaParams, | 149 gammaParams, |
131 colorNoPreMul, | 150 colorNoPreMul, |
132 fContext->getMatrix(
).rectStaysRect() && | 151 fContext->getMatrix(
).rectStaysRect() && |
133 fContext->getMatrix(
).isSimilarity(), | 152 fContext->getMatrix(
).isSimilarity(), |
134 useBGR), | 153 useBGR), |
135 kGlyphCoordsAttributeIndex)->unref(); | 154 coordsIdx)->unref(); |
136 | 155 |
137 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || | 156 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || |
138 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || | 157 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || |
139 fPaint.numColorStages()) { | 158 fPaint.numColorStages()) { |
140 GrPrintf("LCD Text will not draw correctly.\n"); | 159 GrPrintf("LCD Text will not draw correctly.\n"); |
141 } | 160 } |
| 161 SkASSERT(!drawState->hasColorVertexAttribute()); |
142 // We don't use the GrPaint's color in this case because it's been p
remultiplied by | 162 // We don't use the GrPaint's color in this case because it's been p
remultiplied by |
143 // alpha. Instead we feed in a non-premultiplied color, and multiply
its alpha by | 163 // alpha. Instead we feed in a non-premultiplied color, and multiply
its alpha by |
144 // the mask texture color. The end result is that we get | 164 // the mask texture color. The end result is that we get |
145 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstCo
lor | 165 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstCo
lor |
146 int a = SkColorGetA(fSkPaint.getColor()); | 166 int a = SkColorGetA(fSkPaint.getColor()); |
147 // paintAlpha | 167 // paintAlpha |
148 drawState->setColor(SkColorSetARGB(a, a, a, a)); | 168 drawState->setColor(SkColorSetARGB(a, a, a, a)); |
149 // paintColor | 169 // paintColor |
150 drawState->setBlendConstant(colorNoPreMul); | 170 drawState->setBlendConstant(colorNoPreMul); |
151 drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff); | 171 drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff); |
152 } else { | 172 } else { |
153 #ifdef SK_GAMMA_APPLY_TO_A8 | 173 #ifdef SK_GAMMA_APPLY_TO_A8 |
154 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie
s.fGamma, | 174 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie
s.fGamma, |
155 filteredColor); | 175 filteredColor); |
156 drawState->addCoverageEffect(GrDistanceFieldTextureEffect::Create( | 176 drawState->addCoverageEffect(GrDistanceFieldTextureEffect::Create( |
157 currTexture, param
s, | 177 currTexture, param
s, |
158 fGammaTexture, gam
maParams, | 178 fGammaTexture, gam
maParams, |
159 lum/255.f, | 179 lum/255.f, |
160 fContext->getMatri
x().isSimilarity()), | 180 fContext->getMatri
x().isSimilarity()), |
161 kGlyphCoordsAttributeIndex)->unref(); | 181 coordsIdx)->unref(); |
162 #else | 182 #else |
163 drawState->addCoverageEffect(GrDistanceFieldTextureEffect::Create( | 183 drawState->addCoverageEffect(GrDistanceFieldTextureEffect::Create( |
164 currTexture, param
s, | 184 currTexture, param
s, |
165 fContext->getMatri
x().isSimilarity()), | 185 fContext->getMatri
x().isSimilarity()), |
166 kGlyphCoordsAttributeIndex)->unref(); | 186 coordsIdx)->unref(); |
167 #endif | 187 #endif |
168 // set back to normal in case we took LCD path previously. | 188 // set back to normal in case we took LCD path previously. |
169 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlen
dCoeff()); | 189 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlen
dCoeff()); |
170 drawState->setColor(fPaint.getColor()); | 190 //drawState->setColor(fPaint.getColor()); |
| 191 // We're using per-vertex color. |
| 192 SkASSERT(drawState->hasColorVertexAttribute()); |
| 193 drawState->setColor(0xFFFFFFFF); |
171 } | 194 } |
172 | |
173 int nGlyphs = fCurrVertex / 4; | 195 int nGlyphs = fCurrVertex / 4; |
174 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 196 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
175 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, | 197 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, |
176 nGlyphs, | 198 nGlyphs, |
177 4, 6); | 199 4, 6); |
178 fCurrVertex = 0; | 200 fCurrVertex = 0; |
179 } | 201 } |
180 fDrawTarget->resetVertexSource(); | 202 fDrawTarget->resetVertexSource(); |
181 fVertices = NULL; | 203 fVertices = NULL; |
182 } | 204 } |
183 | 205 |
184 namespace { | |
185 | |
186 // position + texture coord | |
187 extern const GrVertexAttrib gTextVertexAttribs[] = { | |
188 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, | |
189 {kVec2f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding} | |
190 }; | |
191 | |
192 }; | |
193 | |
194 void GrDistanceFieldTextContext::drawPackedGlyph(GrGlyph::PackedID packed, | 206 void GrDistanceFieldTextContext::drawPackedGlyph(GrGlyph::PackedID packed, |
195 SkFixed vx, SkFixed vy, | 207 SkFixed vx, SkFixed vy, |
196 GrFontScaler* scaler) { | 208 GrFontScaler* scaler) { |
197 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); | 209 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); |
198 if (NULL == glyph || glyph->fBounds.isEmpty()) { | 210 if (NULL == glyph || glyph->fBounds.isEmpty()) { |
199 return; | 211 return; |
200 } | 212 } |
201 | 213 |
202 SkScalar sx = SkFixedToScalar(vx); | 214 SkScalar sx = SkFixedToScalar(vx); |
203 SkScalar sy = SkFixedToScalar(vy); | 215 SkScalar sy = SkFixedToScalar(vy); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 sx += dx; | 299 sx += dx; |
288 sy += dy; | 300 sy += dy; |
289 width *= scale; | 301 width *= scale; |
290 height *= scale; | 302 height *= scale; |
291 | 303 |
292 SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX + SK_DistanceFieldInset); | 304 SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX + SK_DistanceFieldInset); |
293 SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY + SK_DistanceFieldInset); | 305 SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY + SK_DistanceFieldInset); |
294 SkFixed tw = SkIntToFixed(glyph->fBounds.width() - 2*SK_DistanceFieldInset); | 306 SkFixed tw = SkIntToFixed(glyph->fBounds.width() - 2*SK_DistanceFieldInset); |
295 SkFixed th = SkIntToFixed(glyph->fBounds.height() - 2*SK_DistanceFieldInset)
; | 307 SkFixed th = SkIntToFixed(glyph->fBounds.height() - 2*SK_DistanceFieldInset)
; |
296 | 308 |
297 static const size_t kVertexSize = 2 * sizeof(SkPoint); | 309 size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint)) |
| 310 : (2 * sizeof(SkPoint) + sizeof(GrColor)); |
| 311 |
| 312 SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexSize()); |
| 313 |
298 SkPoint* positions = reinterpret_cast<SkPoint*>( | 314 SkPoint* positions = reinterpret_cast<SkPoint*>( |
299 reinterpret_cast<intptr_t>(fVertices) + kVertexS
ize * fCurrVertex); | 315 reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex); |
300 positions->setRectFan(sx, | 316 positions->setRectFan(sx, sy, sx + width, sy + height, vertSize); |
301 sy, | 317 |
302 sx + width, | 318 // The texture coords are last in both the with and without color vertex lay
outs. |
303 sy + height, | |
304 kVertexSize); | |
305 SkPoint* textureCoords = reinterpret_cast<SkPoint*>( | 319 SkPoint* textureCoords = reinterpret_cast<SkPoint*>( |
306 reinterpret_cast<intptr_t>(positions) + kVertexSize
- sizeof(SkPoint)); | 320 reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint))
; |
307 textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)), | 321 textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)), |
308 SkFixedToFloat(texture->normalizeFixed
Y(ty)), | 322 SkFixedToFloat(texture->normalizeFixedY(ty)), |
309 SkFixedToFloat(texture->normalizeFixed
X(tx + tw)), | 323 SkFixedToFloat(texture->normalizeFixedX(tx + tw)), |
310 SkFixedToFloat(texture->normalizeFixed
Y(ty + th)), | 324 SkFixedToFloat(texture->normalizeFixedY(ty + th)), |
311 kVertexSize); | 325 vertSize); |
| 326 if (!fUseLCDText) { |
| 327 // color comes after position. |
| 328 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); |
| 329 for (int i = 0; i < 4; ++i) { |
| 330 *colors = fPaint.getColor(); |
| 331 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(color
s) + vertSize); |
| 332 } |
| 333 } |
| 334 |
312 fCurrVertex += 4; | 335 fCurrVertex += 4; |
313 } | 336 } |
314 | 337 |
315 inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint
& skPaint) { | 338 inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint
& skPaint) { |
316 GrTextContext::init(paint, skPaint); | 339 GrTextContext::init(paint, skPaint); |
317 | 340 |
318 fStrike = NULL; | 341 fStrike = NULL; |
319 | 342 |
320 fCurrVertex = 0; | 343 fCurrVertex = 0; |
321 | 344 |
(...skipping 13 matching lines...) Expand all Loading... |
335 fUseLCDText = fSkPaint.isLCDRenderText(); | 358 fUseLCDText = fSkPaint.isLCDRenderText(); |
336 | 359 |
337 fSkPaint.setLCDRenderText(false); | 360 fSkPaint.setLCDRenderText(false); |
338 fSkPaint.setAutohinted(false); | 361 fSkPaint.setAutohinted(false); |
339 fSkPaint.setHinting(SkPaint::kNormal_Hinting); | 362 fSkPaint.setHinting(SkPaint::kNormal_Hinting); |
340 fSkPaint.setSubpixelText(true); | 363 fSkPaint.setSubpixelText(true); |
341 | 364 |
342 } | 365 } |
343 | 366 |
344 inline void GrDistanceFieldTextContext::finish() { | 367 inline void GrDistanceFieldTextContext::finish() { |
345 flushGlyphs(); | 368 this->flushGlyphs(); |
346 | 369 |
347 GrTextContext::finish(); | 370 GrTextContext::finish(); |
348 } | 371 } |
349 | 372 |
350 static void setup_gamma_texture(GrContext* context, const SkGlyphCache* cache, | 373 static void setup_gamma_texture(GrContext* context, const SkGlyphCache* cache, |
351 const SkDeviceProperties& deviceProperties, | 374 const SkDeviceProperties& deviceProperties, |
352 GrTexture** gammaTexture) { | 375 GrTexture** gammaTexture) { |
353 if (NULL == *gammaTexture) { | 376 if (NULL == *gammaTexture) { |
354 int width, height; | 377 int width, height; |
355 size_t size; | 378 size_t size; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 SkGlyphCache* cache = autoCache.getCache(); | 435 SkGlyphCache* cache = autoCache.getCache(); |
413 GrFontScaler* fontScaler = GetGrFontScaler(cache); | 436 GrFontScaler* fontScaler = GetGrFontScaler(cache); |
414 if (NULL == fStrike) { | 437 if (NULL == fStrike) { |
415 fStrike = fContext->getFontCache()->getStrike(fontScaler, true); | 438 fStrike = fContext->getFontCache()->getStrike(fontScaler, true); |
416 } | 439 } |
417 | 440 |
418 setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture); | 441 setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture); |
419 | 442 |
420 // allocate vertices | 443 // allocate vertices |
421 SkASSERT(NULL == fVertices); | 444 SkASSERT(NULL == fVertices); |
422 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( | 445 if (!fUseLCDText) { |
423 SK_ARRAY_COUNT(g
TextVertexAttribs)); | 446 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>( |
| 447 SK_ARRAY_COUNT(gTextVerte
xWithColorAttribs)); |
| 448 } else { |
| 449 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( |
| 450 SK_ARRAY_COUNT(gTextVerte
xAttribs)); |
| 451 } |
424 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); | 452 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
425 bool success = fDrawTarget->reserveVertexAndIndexSpace(4*numGlyphs, | 453 bool success = fDrawTarget->reserveVertexAndIndexSpace(4*numGlyphs, |
426 0, | 454 0, |
427 &fVertices, | 455 &fVertices, |
428 NULL); | 456 NULL); |
429 GrAlwaysAssert(success); | 457 GrAlwaysAssert(success); |
430 | 458 |
431 // need to measure first | 459 // need to measure first |
432 // TODO - generate positions and pre-load cache as well? | 460 // TODO - generate positions and pre-load cache as well? |
433 const char* stop = text + byteLength; | 461 const char* stop = text + byteLength; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 531 |
504 SkAutoGlyphCacheNoGamma autoCache(fSkPaint, &fDeviceProperties, NULL); | 532 SkAutoGlyphCacheNoGamma autoCache(fSkPaint, &fDeviceProperties, NULL); |
505 SkGlyphCache* cache = autoCache.getCache(); | 533 SkGlyphCache* cache = autoCache.getCache(); |
506 GrFontScaler* fontScaler = GetGrFontScaler(cache); | 534 GrFontScaler* fontScaler = GetGrFontScaler(cache); |
507 if (NULL == fStrike) { | 535 if (NULL == fStrike) { |
508 fStrike = fContext->getFontCache()->getStrike(fontScaler, true); | 536 fStrike = fContext->getFontCache()->getStrike(fontScaler, true); |
509 } | 537 } |
510 | 538 |
511 // allocate vertices | 539 // allocate vertices |
512 SkASSERT(NULL == fVertices); | 540 SkASSERT(NULL == fVertices); |
513 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( | 541 if (!fUseLCDText) { |
514 SK_ARRAY_COUNT(g
TextVertexAttribs)); | 542 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>( |
| 543 SK_ARRAY_COUNT(gTextVerte
xWithColorAttribs)); |
| 544 } else { |
| 545 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( |
| 546 SK_ARRAY_COUNT(gTextVerte
xAttribs)); |
| 547 } |
515 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); | 548 int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
516 bool success = fDrawTarget->reserveVertexAndIndexSpace(4*numGlyphs, | 549 bool success = fDrawTarget->reserveVertexAndIndexSpace(4*numGlyphs, |
517 0, | 550 0, |
518 &fVertices, | 551 &fVertices, |
519 NULL); | 552 NULL); |
520 GrAlwaysAssert(success); | 553 GrAlwaysAssert(success); |
521 | 554 |
522 setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture); | 555 setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture); |
523 | 556 |
524 const char* stop = text + byteLength; | 557 const char* stop = text + byteLength; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift), | 590 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift), |
558 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift), | 591 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift), |
559 fontScaler); | 592 fontScaler); |
560 } | 593 } |
561 pos += scalarsPerPosition; | 594 pos += scalarsPerPosition; |
562 } | 595 } |
563 } | 596 } |
564 | 597 |
565 this->finish(); | 598 this->finish(); |
566 } | 599 } |
OLD | NEW |