Chromium Code Reviews| Index: ui/gfx/harfbuzz_font_skia.cc |
| diff --git a/ui/gfx/harfbuzz_font_skia.cc b/ui/gfx/harfbuzz_font_skia.cc |
| index 12d7bb19b2e99e3e5460730ceee564611c8c9625..4e64c90143f616f96a4bd7738a41da2a4eb4bbb6 100644 |
| --- a/ui/gfx/harfbuzz_font_skia.cc |
| +++ b/ui/gfx/harfbuzz_font_skia.cc |
| @@ -33,7 +33,7 @@ typedef std::pair<HarfBuzzFace, GlyphCache> FaceCache; |
| struct FontData { |
| FontData(GlyphCache* glyph_cache) : glyph_cache_(glyph_cache) {} |
| - SkPaint paint_; |
| + cc::PaintFlags flags_; |
| GlyphCache* glyph_cache_; |
| }; |
| @@ -52,18 +52,20 @@ void DeleteArrayByType(void* data) { |
| // Outputs the |width| and |extents| of the glyph with index |codepoint| in |
| // |paint|'s font. |
| -void GetGlyphWidthAndExtents(SkPaint* paint, |
| +void GetGlyphWidthAndExtents(cc::PaintFlags* flags, |
| hb_codepoint_t codepoint, |
| hb_position_t* width, |
| hb_glyph_extents_t* extents) { |
| + SkPaint paint(cc::ToSkPaint(*flags)); |
| + |
| DCHECK_LE(codepoint, std::numeric_limits<uint16_t>::max()); |
| - paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| + paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| SkScalar sk_width; |
| SkRect sk_bounds; |
| uint16_t glyph = static_cast<uint16_t>(codepoint); |
| - paint->getTextWidths(&glyph, sizeof(glyph), &sk_width, &sk_bounds); |
| + paint.getTextWidths(&glyph, sizeof(glyph), &sk_width, &sk_bounds); |
| if (width) |
| *width = SkiaScalarToHarfBuzzUnits(sk_width); |
| if (extents) { |
| @@ -89,9 +91,9 @@ hb_bool_t GetGlyph(hb_font_t* font, |
| bool exists = cache->count(unicode) != 0; |
| if (!exists) { |
| - SkPaint* paint = &font_data->paint_; |
| - paint->setTextEncoding(SkPaint::kUTF32_TextEncoding); |
| - paint->textToGlyphs(&unicode, sizeof(hb_codepoint_t), &(*cache)[unicode]); |
| + font_data->flags_.setTextEncoding(cc::PaintFlags::kUTF32_TextEncoding); |
| + SkPaint paint(cc::ToSkPaint(font_data->flags_)); |
|
enne (OOO)
2017/02/27 01:56:21
Similar to my comments on https://codereview.chrom
|
| + paint.textToGlyphs(&unicode, sizeof(hb_codepoint_t), &(*cache)[unicode]); |
| } |
| *glyph = (*cache)[unicode]; |
| return !!*glyph; |
| @@ -105,7 +107,7 @@ hb_position_t GetGlyphHorizontalAdvance(hb_font_t* font, |
| FontData* font_data = reinterpret_cast<FontData*>(data); |
| hb_position_t advance = 0; |
| - GetGlyphWidthAndExtents(&font_data->paint_, glyph, &advance, 0); |
| + GetGlyphWidthAndExtents(&font_data->flags_, glyph, &advance, 0); |
| return advance; |
| } |
| @@ -122,7 +124,7 @@ hb_bool_t GetGlyphHorizontalOrigin(hb_font_t* font, |
| hb_position_t GetGlyphKerning(FontData* font_data, |
| hb_codepoint_t first_glyph, |
| hb_codepoint_t second_glyph) { |
| - SkTypeface* typeface = font_data->paint_.getTypeface(); |
| + SkTypeface* typeface = font_data->flags_.getTypeface(); |
| const uint16_t glyphs[2] = { static_cast<uint16_t>(first_glyph), |
| static_cast<uint16_t>(second_glyph) }; |
| int32_t kerning_adjustments[1] = { 0 }; |
| @@ -131,7 +133,7 @@ hb_position_t GetGlyphKerning(FontData* font_data, |
| return 0; |
| SkScalar upm = SkIntToScalar(typeface->getUnitsPerEm()); |
| - SkScalar size = font_data->paint_.getTextSize(); |
| + SkScalar size = font_data->flags_.getTextSize(); |
| return SkiaScalarToHarfBuzzUnits(SkIntToScalar(kerning_adjustments[0]) * |
| size / upm); |
| } |
| @@ -142,7 +144,7 @@ hb_position_t GetGlyphHorizontalKerning(hb_font_t* font, |
| hb_codepoint_t right_glyph, |
| void* user_data) { |
| FontData* font_data = reinterpret_cast<FontData*>(data); |
| - if (font_data->paint_.isVerticalText()) { |
| + if (font_data->flags_.isVerticalText()) { |
| // We don't support cross-stream kerning. |
| return 0; |
| } |
| @@ -156,7 +158,7 @@ hb_position_t GetGlyphVerticalKerning(hb_font_t* font, |
| hb_codepoint_t bottom_glyph, |
| void* user_data) { |
| FontData* font_data = reinterpret_cast<FontData*>(data); |
| - if (!font_data->paint_.isVerticalText()) { |
| + if (!font_data->flags_.isVerticalText()) { |
| // We don't support cross-stream kerning. |
| return 0; |
| } |
| @@ -172,7 +174,7 @@ hb_bool_t GetGlyphExtents(hb_font_t* font, |
| void* user_data) { |
| FontData* font_data = reinterpret_cast<FontData*>(data); |
| - GetGlyphWidthAndExtents(&font_data->paint_, glyph, 0, extents); |
| + GetGlyphWidthAndExtents(&font_data->flags_, glyph, 0, extents); |
| return true; |
| } |
| @@ -274,11 +276,11 @@ hb_font_t* CreateHarfBuzzFont(sk_sp<SkTypeface> skia_face, |
| const int scale = SkiaScalarToHarfBuzzUnits(text_size); |
| hb_font_set_scale(harfbuzz_font, scale, scale); |
| FontData* hb_font_data = new FontData(&face_cache->second); |
| - hb_font_data->paint_.setTypeface(std::move(skia_face)); |
| - hb_font_data->paint_.setTextSize(text_size); |
| + hb_font_data->flags_.setTypeface(std::move(skia_face)); |
| + hb_font_data->flags_.setTextSize(text_size); |
| // TODO(ckocagil): Do we need to update these params later? |
| internal::ApplyRenderParams(params, subpixel_rendering_suppressed, |
| - &hb_font_data->paint_); |
| + &hb_font_data->flags_); |
| hb_font_set_funcs(harfbuzz_font, g_font_funcs.Get().get(), hb_font_data, |
| DeleteByType<FontData>); |
| hb_font_make_immutable(harfbuzz_font); |