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 "GrBitmapTextContext.h" | 10 #include "GrBitmapTextContext.h" |
11 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
12 #include "GrDrawTargetCaps.h" | 12 #include "GrDrawTargetCaps.h" |
| 13 #include "GrFontAtlasSizes.h" |
13 #include "GrFontCache.h" | 14 #include "GrFontCache.h" |
14 #include "GrFontScaler.h" | 15 #include "GrFontScaler.h" |
15 #include "GrGpu.h" | 16 #include "GrGpu.h" |
16 #include "GrIndexBuffer.h" | 17 #include "GrIndexBuffer.h" |
17 #include "GrStrokeInfo.h" | 18 #include "GrStrokeInfo.h" |
18 #include "GrTexturePriv.h" | 19 #include "GrTexturePriv.h" |
19 | 20 |
20 #include "SkAutoKern.h" | 21 #include "SkAutoKern.h" |
21 #include "SkColorFilter.h" | 22 #include "SkColorFilter.h" |
22 #include "SkDistanceFieldGen.h" | 23 #include "SkDistanceFieldGen.h" |
23 #include "SkDraw.h" | 24 #include "SkDraw.h" |
24 #include "SkGlyphCache.h" | 25 #include "SkGlyphCache.h" |
25 #include "SkGpuDevice.h" | 26 #include "SkGpuDevice.h" |
26 #include "SkPath.h" | 27 #include "SkPath.h" |
27 #include "SkRTConf.h" | 28 #include "SkRTConf.h" |
28 #include "SkStrokeRec.h" | 29 #include "SkStrokeRec.h" |
29 #include "effects/GrDistanceFieldTextureEffect.h" | 30 #include "effects/GrDistanceFieldTextureEffect.h" |
30 | 31 |
31 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 32 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
32 "Dump the contents of the font cache before every purge."); | 33 "Dump the contents of the font cache before every purge."); |
33 | 34 |
34 static const int kSmallDFFontSize = 32; | 35 static const int kSmallDFFontSize = 32; |
35 static const int kSmallDFFontLimit = 32; | 36 static const int kSmallDFFontLimit = 32; |
36 static const int kMediumDFFontSize = 78; | 37 static const int kMediumDFFontSize = 70; |
37 static const int kMediumDFFontLimit = 78; | 38 static const int kMediumDFFontLimit = 70; |
38 static const int kLargeDFFontSize = 192; | 39 static const int kLargeDFFontSize = 156; |
| 40 SK_COMPILE_ASSERT(GR_SDF_MAX_SIZE >= kLargeDFFontSize, sdf_too_big); |
39 | 41 |
40 static const int kVerticesPerGlyph = 4; | 42 static const int kVerticesPerGlyph = 4; |
41 static const int kIndicesPerGlyph = 6; | 43 static const int kIndicesPerGlyph = 6; |
42 | 44 |
43 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, | 45 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, |
44 const SkDeviceProperties&
properties, | 46 const SkDeviceProperties&
properties, |
45 bool enable) | 47 bool enable) |
46 : GrTextContext(context, pro
perties) { | 48 : GrTextContext(context, pro
perties) { |
47 #if SK_FORCE_DISTANCE_FIELD_TEXT | 49 #if SK_FORCE_DISTANCE_FIELD_TEXT |
48 fEnableDFRendering = true; | 50 fEnableDFRendering = true; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 bool success = drawTarget->reserveVertexAndIndexSpace(numVertices, | 395 bool success = drawTarget->reserveVertexAndIndexSpace(numVertices, |
394 get_vertex_stride(useC
olorVerts), | 396 get_vertex_stride(useC
olorVerts), |
395 0, | 397 0, |
396 &vertices, | 398 &vertices, |
397 NULL); | 399 NULL); |
398 GrAlwaysAssert(success); | 400 GrAlwaysAssert(success); |
399 return vertices; | 401 return vertices; |
400 } | 402 } |
401 | 403 |
402 void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo
r) { | 404 void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo
r) { |
403 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_
FilterMode); | 405 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_F
ilterMode); |
404 GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::kNon
e_FilterMode); | 406 GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::kNon
e_FilterMode); |
405 | 407 |
406 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 408 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
407 const SkMatrix& ctm = fViewMatrix; | 409 const SkMatrix& ctm = fViewMatrix; |
408 | 410 |
409 // set up any flags | 411 // set up any flags |
410 uint32_t flags = 0; | 412 uint32_t flags = 0; |
411 flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; | 413 flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; |
412 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; | 414 flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; |
413 flags |= fUseLCDText && ctm.rectStaysRect() ? | 415 flags |= fUseLCDText && ctm.rectStaysRect() ? |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 } | 719 } |
718 } | 720 } |
719 | 721 |
720 inline void GrDistanceFieldTextContext::finish() { | 722 inline void GrDistanceFieldTextContext::finish() { |
721 this->flush(); | 723 this->flush(); |
722 fTotalVertexCount = 0; | 724 fTotalVertexCount = 0; |
723 | 725 |
724 GrTextContext::finish(); | 726 GrTextContext::finish(); |
725 } | 727 } |
726 | 728 |
OLD | NEW |