| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 static const int kSmallDFFontSize = 32; | 27 static const int kSmallDFFontSize = 32; |
| 28 static const int kSmallDFFontLimit = 32; | 28 static const int kSmallDFFontLimit = 32; |
| 29 static const int kMediumDFFontSize = 64; | 29 static const int kMediumDFFontSize = 64; |
| 30 static const int kMediumDFFontLimit = 64; | 30 static const int kMediumDFFontLimit = 64; |
| 31 static const int kLargeDFFontSize = 128; | 31 static const int kLargeDFFontSize = 128; |
| 32 | 32 |
| 33 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 33 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
| 34 "Dump the contents of the font cache before every purge."); | 34 "Dump the contents of the font cache before every purge."); |
| 35 | 35 |
| 36 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, |
| 37 const SkDeviceProperties&
properties, |
| 38 bool enable) |
| 39 : GrTextContext(context, pro
perties) { |
| 36 #if SK_FORCE_DISTANCEFIELD_FONTS | 40 #if SK_FORCE_DISTANCEFIELD_FONTS |
| 37 static const bool kForceDistanceFieldFonts = true; | 41 fEnableDFRendering = true; |
| 38 #else | 42 #else |
| 39 static const bool kForceDistanceFieldFonts = false; | 43 fEnableDFRendering = enable; |
| 40 #endif | 44 #endif |
| 41 | |
| 42 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, | |
| 43 const SkDeviceProperties&
properties) | |
| 44 : GrTextContext(context, pro
perties) { | |
| 45 fStrike = NULL; | 45 fStrike = NULL; |
| 46 | 46 |
| 47 fCurrTexture = NULL; | 47 fCurrTexture = NULL; |
| 48 fCurrVertex = 0; | 48 fCurrVertex = 0; |
| 49 | 49 |
| 50 fVertices = NULL; | 50 fVertices = NULL; |
| 51 fMaxVertices = 0; | 51 fMaxVertices = 0; |
| 52 } | 52 } |
| 53 | 53 |
| 54 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { | 54 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { |
| 55 this->flushGlyphs(); | 55 this->flushGlyphs(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) { | 58 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) { |
| 59 if (!kForceDistanceFieldFonts && !paint.isDistanceFieldTextTEMP()) { | 59 if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP()) { |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // rasterizers and mask filters modify alpha, which doesn't | 63 // rasterizers and mask filters modify alpha, which doesn't |
| 64 // translate well to distance | 64 // translate well to distance |
| 65 if (paint.getRasterizer() || paint.getMaskFilter() || | 65 if (paint.getRasterizer() || paint.getMaskFilter() || |
| 66 !fContext->getTextTarget()->caps()->shaderDerivativeSupport()) { | 66 !fContext->getTextTarget()->caps()->shaderDerivativeSupport()) { |
| 67 return false; | 67 return false; |
| 68 } | 68 } |
| 69 | 69 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift) | 495 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift) |
| 496 + SK_FixedHalf, //d1g.fHalfSampleY, | 496 + SK_FixedHalf, //d1g.fHalfSampleY, |
| 497 fontScaler); | 497 fontScaler); |
| 498 } | 498 } |
| 499 pos += scalarsPerPosition; | 499 pos += scalarsPerPosition; |
| 500 } | 500 } |
| 501 } | 501 } |
| 502 | 502 |
| 503 this->finish(); | 503 this->finish(); |
| 504 } | 504 } |
| OLD | NEW |