| 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 10 matching lines...) Expand all Loading... |
| 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 kBaseDFFontSize = 32; |
| 27 | 27 |
| 28 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 28 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
| 29 "Dump the contents of the font cache before every purge."); | 29 "Dump the contents of the font cache before every purge."); |
| 30 | 30 |
| 31 #if SK_FORCE_DISTANCEFIELD_FONTS |
| 32 static const bool kForceDistanceFieldFonts = true; |
| 33 #else |
| 34 static const bool kForceDistanceFieldFonts = false; |
| 35 #endif |
| 36 |
| 31 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, | 37 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, |
| 32 const SkDeviceProperties&
properties) | 38 const SkDeviceProperties&
properties) |
| 33 : GrTextContext(context, pro
perties) { | 39 : GrTextContext(context, pro
perties) { |
| 34 fStrike = NULL; | 40 fStrike = NULL; |
| 35 | 41 |
| 36 fCurrTexture = NULL; | 42 fCurrTexture = NULL; |
| 37 fCurrVertex = 0; | 43 fCurrVertex = 0; |
| 38 | 44 |
| 39 fVertices = NULL; | 45 fVertices = NULL; |
| 40 fMaxVertices = 0; | 46 fMaxVertices = 0; |
| 41 } | 47 } |
| 42 | 48 |
| 43 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { | 49 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { |
| 44 this->flushGlyphs(); | 50 this->flushGlyphs(); |
| 45 } | 51 } |
| 46 | 52 |
| 47 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) { | 53 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) { |
| 48 return paint.isDistanceFieldTextTEMP() && | 54 return (kForceDistanceFieldFonts || paint.isDistanceFieldTextTEMP()) && |
| 49 !paint.getRasterizer() && !paint.getMaskFilter() && | 55 !paint.getRasterizer() && !paint.getMaskFilter() && |
| 50 paint.getStyle() == SkPaint::kFill_Style && | 56 paint.getStyle() == SkPaint::kFill_Style && |
| 51 fContext->getTextTarget()->caps()->shaderDerivativeSupport() && | 57 fContext->getTextTarget()->caps()->shaderDerivativeSupport() && |
| 52 !SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix()); | 58 !SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix()); |
| 53 } | 59 } |
| 54 | 60 |
| 55 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { | 61 static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { |
| 56 unsigned r = SkColorGetR(c); | 62 unsigned r = SkColorGetR(c); |
| 57 unsigned g = SkColorGetG(c); | 63 unsigned g = SkColorGetG(c); |
| 58 unsigned b = SkColorGetB(c); | 64 unsigned b = SkColorGetB(c); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift) | 449 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift) |
| 444 + SK_FixedHalf, //d1g.fHalfSampleY, | 450 + SK_FixedHalf, //d1g.fHalfSampleY, |
| 445 fontScaler); | 451 fontScaler); |
| 446 } | 452 } |
| 447 pos += scalarsPerPosition; | 453 pos += scalarsPerPosition; |
| 448 } | 454 } |
| 449 } | 455 } |
| 450 | 456 |
| 451 this->finish(); | 457 this->finish(); |
| 452 } | 458 } |
| OLD | NEW |