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 "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.h" |
12 #include "GrFontScaler.h" | 12 #include "GrFontScaler.h" |
13 #include "SkGlyphCache.h" | 13 #include "SkGlyphCache.h" |
14 #include "GrIndexBuffer.h" | 14 #include "GrIndexBuffer.h" |
15 #include "GrTextStrike.h" | 15 #include "GrTextStrike.h" |
16 #include "GrTextStrike_impl.h" | 16 #include "GrTextStrike_impl.h" |
17 #include "SkDraw.h" | 17 #include "SkDraw.h" |
18 #include "SkGpuDevice.h" | 18 #include "SkGpuDevice.h" |
19 #include "SkPath.h" | 19 #include "SkPath.h" |
20 #include "SkRTConf.h" | 20 #include "SkRTConf.h" |
21 #include "SkStrokeRec.h" | 21 #include "SkStrokeRec.h" |
22 #include "effects/GrDistanceFieldTextureEffect.h" | 22 #include "effects/GrDistanceFieldTextureEffect.h" |
23 | 23 |
24 static const int kGlyphCoordsAttributeIndex = 1; | 24 static const int kGlyphCoordsAttributeIndex = 1; |
25 | 25 |
26 static const int kBaseDFFontSize = 32; | 26 static const int kSmallDFFontSize = 32; |
| 27 static const int kSmallDFFontLimit = 32; |
| 28 static const int kMediumDFFontSize = 64; |
| 29 static const int kMediumDFFontLimit = 64; |
| 30 static const int kLargeDFFontSize = 128; |
27 | 31 |
28 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 32 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
29 "Dump the contents of the font cache before every purge."); | 33 "Dump the contents of the font cache before every purge."); |
30 | 34 |
31 #if SK_FORCE_DISTANCEFIELD_FONTS | 35 #if SK_FORCE_DISTANCEFIELD_FONTS |
32 static const bool kForceDistanceFieldFonts = true; | 36 static const bool kForceDistanceFieldFonts = true; |
33 #else | 37 #else |
34 static const bool kForceDistanceFieldFonts = false; | 38 static const bool kForceDistanceFieldFonts = false; |
35 #endif | 39 #endif |
36 | 40 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 GrTextContext::init(paint, skPaint); | 300 GrTextContext::init(paint, skPaint); |
297 | 301 |
298 fStrike = NULL; | 302 fStrike = NULL; |
299 | 303 |
300 fCurrTexture = NULL; | 304 fCurrTexture = NULL; |
301 fCurrVertex = 0; | 305 fCurrVertex = 0; |
302 | 306 |
303 fVertices = NULL; | 307 fVertices = NULL; |
304 fMaxVertices = 0; | 308 fMaxVertices = 0; |
305 | 309 |
306 fTextRatio = fSkPaint.getTextSize()/kBaseDFFontSize; | 310 if (fSkPaint.getTextSize() <= kSmallDFFontLimit) { |
| 311 fTextRatio = fSkPaint.getTextSize()/kSmallDFFontSize; |
| 312 fSkPaint.setTextSize(SkIntToScalar(kSmallDFFontSize)); |
| 313 } else if (fSkPaint.getTextSize() <= kMediumDFFontLimit) { |
| 314 fTextRatio = fSkPaint.getTextSize()/kMediumDFFontSize; |
| 315 fSkPaint.setTextSize(SkIntToScalar(kMediumDFFontSize)); |
| 316 } else { |
| 317 fTextRatio = fSkPaint.getTextSize()/kLargeDFFontSize; |
| 318 fSkPaint.setTextSize(SkIntToScalar(kLargeDFFontSize)); |
| 319 } |
307 | 320 |
308 fSkPaint.setTextSize(SkIntToScalar(kBaseDFFontSize)); | |
309 fSkPaint.setLCDRenderText(false); | 321 fSkPaint.setLCDRenderText(false); |
310 fSkPaint.setAutohinted(false); | 322 fSkPaint.setAutohinted(false); |
311 fSkPaint.setSubpixelText(true); | 323 fSkPaint.setSubpixelText(true); |
312 } | 324 } |
313 | 325 |
314 inline void GrDistanceFieldTextContext::finish() { | 326 inline void GrDistanceFieldTextContext::finish() { |
315 flushGlyphs(); | 327 flushGlyphs(); |
316 | 328 |
317 GrTextContext::finish(); | 329 GrTextContext::finish(); |
318 } | 330 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift) | 461 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift) |
450 + SK_FixedHalf, //d1g.fHalfSampleY, | 462 + SK_FixedHalf, //d1g.fHalfSampleY, |
451 fontScaler); | 463 fontScaler); |
452 } | 464 } |
453 pos += scalarsPerPosition; | 465 pos += scalarsPerPosition; |
454 } | 466 } |
455 } | 467 } |
456 | 468 |
457 this->finish(); | 469 this->finish(); |
458 } | 470 } |
OLD | NEW |