| 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 "SkAdvancedTypefaceMetrics.h" | 8 #include "SkAdvancedTypefaceMetrics.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 glyph->fAdvanceX = fTestFont->fWidths[glyph->getGlyphID()]; | 130 glyph->fAdvanceX = fTestFont->fWidths[glyph->getGlyphID()]; |
| 131 glyph->fAdvanceY = 0; | 131 glyph->fAdvanceY = 0; |
| 132 } | 132 } |
| 133 | 133 |
| 134 void SkTestTypeface::getPath(const SkGlyph& glyph, SkPath* path) { | 134 void SkTestTypeface::getPath(const SkGlyph& glyph, SkPath* path) { |
| 135 *path = *fTestFont->fPaths[glyph.getGlyphID()]; | 135 *path = *fTestFont->fPaths[glyph.getGlyphID()]; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void SkTestTypeface::onFilterRec(SkScalerContextRec* rec) const { | 138 void SkTestTypeface::onFilterRec(SkScalerContextRec* rec) const { |
| 139 rec->setHinting(SkPaint::kNo_Hinting); | 139 rec->setHinting(SkPaint::kNo_Hinting); |
| 140 rec->fMaskFormat = SkMask::kA8_Format; | |
| 141 } | 140 } |
| 142 | 141 |
| 143 SkAdvancedTypefaceMetrics* SkTestTypeface::onGetAdvancedTypefaceMetrics( | 142 SkAdvancedTypefaceMetrics* SkTestTypeface::onGetAdvancedTypefaceMetrics( |
| 144 PerGlyphInfo , | 143 PerGlyphInfo , |
| 145 const uint32_t* glyphIDs, | 144 const uint32_t* glyphIDs, |
| 146 uint32_t glyphIDsCount) const { | 145 uint32_t glyphIDsCount) const { |
| 147 // pdf only | 146 // pdf only |
| 148 SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; | 147 SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; |
| 149 info->fEmSize = 0; | 148 info->fEmSize = 0; |
| 150 info->fLastGlyphID = SkToU16(onCountGlyphs() - 1); | 149 info->fLastGlyphID = SkToU16(onCountGlyphs() - 1); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 const SkPaint paint; | 235 const SkPaint paint; |
| 237 const SkRect& newBounds = paint.doComputeFastBounds(path.getBounds(), | 236 const SkRect& newBounds = paint.doComputeFastBounds(path.getBounds(), |
| 238 &storage, | 237 &storage, |
| 239 SkPaint::kFill_Style
); | 238 SkPaint::kFill_Style
); |
| 240 SkIRect ibounds; | 239 SkIRect ibounds; |
| 241 newBounds.roundOut(&ibounds); | 240 newBounds.roundOut(&ibounds); |
| 242 glyph->fLeft = ibounds.fLeft; | 241 glyph->fLeft = ibounds.fLeft; |
| 243 glyph->fTop = ibounds.fTop; | 242 glyph->fTop = ibounds.fTop; |
| 244 glyph->fWidth = ibounds.width(); | 243 glyph->fWidth = ibounds.width(); |
| 245 glyph->fHeight = ibounds.height(); | 244 glyph->fHeight = ibounds.height(); |
| 246 glyph->fMaskFormat = SkMask::kARGB32_Format; | |
| 247 } | 245 } |
| 248 | 246 |
| 249 void generateImage(const SkGlyph& glyph) override { | 247 void generateImage(const SkGlyph& glyph) override { |
| 250 SkPath path; | 248 SkPath path; |
| 251 fFace->getPath(glyph, &path); | 249 fFace->getPath(glyph, &path); |
| 252 | 250 |
| 253 SkBitmap bm; | 251 SkBitmap bm; |
| 254 bm.installPixels(SkImageInfo::MakeN32Premul(glyph.fWidth, glyph.fHeight)
, | 252 bm.installPixels(SkImageInfo::MakeN32Premul(glyph.fWidth, glyph.fHeight)
, |
| 255 glyph.fImage, glyph.rowBytes()); | 253 glyph.fImage, glyph.rowBytes()); |
| 256 bm.eraseColor(0); | 254 bm.eraseColor(0); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 286 } | 284 } |
| 287 | 285 |
| 288 private: | 286 private: |
| 289 SkTestTypeface* fFace; | 287 SkTestTypeface* fFace; |
| 290 SkMatrix fMatrix; | 288 SkMatrix fMatrix; |
| 291 }; | 289 }; |
| 292 | 290 |
| 293 SkScalerContext* SkTestTypeface::onCreateScalerContext(const SkDescriptor* desc)
const { | 291 SkScalerContext* SkTestTypeface::onCreateScalerContext(const SkDescriptor* desc)
const { |
| 294 return SkNEW_ARGS(SkTestScalerContext, (const_cast<SkTestTypeface*>(this), d
esc)); | 292 return SkNEW_ARGS(SkTestScalerContext, (const_cast<SkTestTypeface*>(this), d
esc)); |
| 295 } | 293 } |
| OLD | NEW |