| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrPathRendering.h" | 8 #include "GrPathRendering.h" |
| 9 #include "SkDescriptor.h" | 9 #include "SkDescriptor.h" |
| 10 #include "SkGlyph.h" | 10 #include "SkGlyph.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 SkDescriptor* const fDesc; | 45 SkDescriptor* const fDesc; |
| 46 const SkAutoTDelete<SkScalerContext> fScalerContext; | 46 const SkAutoTDelete<SkScalerContext> fScalerContext; |
| 47 SkMatrix fFlipMatrix; | 47 SkMatrix fFlipMatrix; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 GrPathRange* GrPathRendering::createGlyphs(const SkTypeface* typeface, | 50 GrPathRange* GrPathRendering::createGlyphs(const SkTypeface* typeface, |
| 51 const SkDescriptor* desc, | 51 const SkDescriptor* desc, |
| 52 const SkStrokeRec& stroke) { | 52 const GrStrokeInfo& stroke) { |
| 53 if (NULL == typeface) { | 53 if (NULL == typeface) { |
| 54 typeface = SkTypeface::GetDefaultTypeface(); | 54 typeface = SkTypeface::GetDefaultTypeface(); |
| 55 SkASSERT(NULL != typeface); | 55 SkASSERT(NULL != typeface); |
| 56 } | 56 } |
| 57 | 57 |
| 58 if (desc) { | 58 if (desc) { |
| 59 SkAutoTUnref<GlyphGenerator> generator(SkNEW_ARGS(GlyphGenerator, (*type
face, *desc))); | 59 SkAutoTUnref<GlyphGenerator> generator(SkNEW_ARGS(GlyphGenerator, (*type
face, *desc))); |
| 60 return this->createPathRange(generator, stroke); | 60 return this->createPathRange(generator, stroke); |
| 61 } | 61 } |
| 62 | 62 |
| 63 SkScalerContextRec rec; | 63 SkScalerContextRec rec; |
| 64 memset(&rec, 0, sizeof(rec)); | 64 memset(&rec, 0, sizeof(rec)); |
| 65 rec.fFontID = typeface->uniqueID(); | 65 rec.fFontID = typeface->uniqueID(); |
| 66 rec.fTextSize = SkPaint::kCanonicalTextSizeForPaths; | 66 rec.fTextSize = SkPaint::kCanonicalTextSizeForPaths; |
| 67 rec.fPreScaleX = rec.fPost2x2[0][0] = rec.fPost2x2[1][1] = SK_Scalar1; | 67 rec.fPreScaleX = rec.fPost2x2[0][0] = rec.fPost2x2[1][1] = SK_Scalar1; |
| 68 // Don't bake stroke information into the glyphs, we'll let the GPU do the s
troking. | 68 // Don't bake stroke information into the glyphs, we'll let the GPU do the s
troking. |
| 69 | 69 |
| 70 SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1)); | 70 SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1)); |
| 71 SkDescriptor* genericDesc = ad.getDesc(); | 71 SkDescriptor* genericDesc = ad.getDesc(); |
| 72 | 72 |
| 73 genericDesc->init(); | 73 genericDesc->init(); |
| 74 genericDesc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec); | 74 genericDesc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec); |
| 75 genericDesc->computeChecksum(); | 75 genericDesc->computeChecksum(); |
| 76 | 76 |
| 77 SkAutoTUnref<GlyphGenerator> generator(SkNEW_ARGS(GlyphGenerator, (*typeface
, *genericDesc))); | 77 SkAutoTUnref<GlyphGenerator> generator(SkNEW_ARGS(GlyphGenerator, (*typeface
, *genericDesc))); |
| 78 return this->createPathRange(generator, stroke); | 78 return this->createPathRange(generator, stroke); |
| 79 } | 79 } |
| OLD | NEW |