| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 const SkAutoTDelete<SkScalerContext> fScalerContext; | 50 const SkAutoTDelete<SkScalerContext> fScalerContext; |
| 51 SkMatrix fFlipMatrix; | 51 SkMatrix fFlipMatrix; |
| 52 #ifdef SK_DEBUG | 52 #ifdef SK_DEBUG |
| 53 SkDescriptor* const fDesc; | 53 SkDescriptor* const fDesc; |
| 54 #endif | 54 #endif |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 GrPathRange* GrPathRendering::createGlyphs(const SkTypeface* typeface, | 57 GrPathRange* GrPathRendering::createGlyphs(const SkTypeface* typeface, |
| 58 const SkDescriptor* desc, | 58 const SkDescriptor* desc, |
| 59 const GrStrokeInfo& stroke) { | 59 const GrStrokeInfo& stroke) { |
| 60 if (NULL == typeface) { | 60 if (nullptr == typeface) { |
| 61 typeface = SkTypeface::GetDefaultTypeface(); | 61 typeface = SkTypeface::GetDefaultTypeface(); |
| 62 SkASSERT(NULL != typeface); | 62 SkASSERT(nullptr != typeface); |
| 63 } | 63 } |
| 64 | 64 |
| 65 if (desc) { | 65 if (desc) { |
| 66 SkAutoTUnref<GlyphGenerator> generator(new GlyphGenerator(*typeface, *de
sc)); | 66 SkAutoTUnref<GlyphGenerator> generator(new GlyphGenerator(*typeface, *de
sc)); |
| 67 return this->createPathRange(generator, stroke); | 67 return this->createPathRange(generator, stroke); |
| 68 } | 68 } |
| 69 | 69 |
| 70 SkScalerContextRec rec; | 70 SkScalerContextRec rec; |
| 71 memset(&rec, 0, sizeof(rec)); | 71 memset(&rec, 0, sizeof(rec)); |
| 72 rec.fFontID = typeface->uniqueID(); | 72 rec.fFontID = typeface->uniqueID(); |
| 73 rec.fTextSize = SkPaint::kCanonicalTextSizeForPaths; | 73 rec.fTextSize = SkPaint::kCanonicalTextSizeForPaths; |
| 74 rec.fPreScaleX = rec.fPost2x2[0][0] = rec.fPost2x2[1][1] = SK_Scalar1; | 74 rec.fPreScaleX = rec.fPost2x2[0][0] = rec.fPost2x2[1][1] = SK_Scalar1; |
| 75 // Don't bake stroke information into the glyphs, we'll let the GPU do the s
troking. | 75 // Don't bake stroke information into the glyphs, we'll let the GPU do the s
troking. |
| 76 | 76 |
| 77 SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1)); | 77 SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1)); |
| 78 SkDescriptor* genericDesc = ad.getDesc(); | 78 SkDescriptor* genericDesc = ad.getDesc(); |
| 79 | 79 |
| 80 genericDesc->init(); | 80 genericDesc->init(); |
| 81 genericDesc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec); | 81 genericDesc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec); |
| 82 genericDesc->computeChecksum(); | 82 genericDesc->computeChecksum(); |
| 83 | 83 |
| 84 SkAutoTUnref<GlyphGenerator> generator(new GlyphGenerator(*typeface, *generi
cDesc)); | 84 SkAutoTUnref<GlyphGenerator> generator(new GlyphGenerator(*typeface, *generi
cDesc)); |
| 85 return this->createPathRange(generator, stroke); | 85 return this->createPathRange(generator, stroke); |
| 86 } | 86 } |
| OLD | NEW |