Commit 93c625a2 authored by Mike Reed's avatar Mike Reed Committed by Commit Bot

move skia metrics helpers to SkFont prefix

follow-on to CL 1343038

Bug: skia:2664
Change-Id: I5ae5640b6c8b025ba531bec633b71484cf4249d1
Reviewed-on: https://chromium-review.googlesource.com/c/1351371
Commit-Queue: Mike Reed <reed@google.com>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610886}
parent 1060c550
...@@ -304,7 +304,7 @@ void OpenTypeVerticalData::GetVerticalTranslationsForGlyphs( ...@@ -304,7 +304,7 @@ void OpenTypeVerticalData::GetVerticalTranslationsForGlyphs(
float top_side_bearing = top_side_bearing_f_unit * size_per_unit_; float top_side_bearing = top_side_bearing_f_unit * size_per_unit_;
SkRect skiaBounds; SkRect skiaBounds;
GetBoundsForGlyph(font, glyph, &skiaBounds); SkFontGetBoundsForGlyph(font, glyph, &skiaBounds);
FloatRect bounds(skiaBounds); FloatRect bounds(skiaBounds);
out_xy_array[1] = bounds.Y() - top_side_bearing; out_xy_array[1] = bounds.Y() - top_side_bearing;
continue; continue;
......
...@@ -135,7 +135,7 @@ static hb_position_t HarfBuzzGetGlyphHorizontalAdvance(hb_font_t* hb_font, ...@@ -135,7 +135,7 @@ static hb_position_t HarfBuzzGetGlyphHorizontalAdvance(hb_font_t* hb_font,
reinterpret_cast<HarfBuzzFontData*>(font_data); reinterpret_cast<HarfBuzzFontData*>(font_data);
hb_position_t advance = 0; hb_position_t advance = 0;
GetGlyphWidthForHarfBuzz(hb_font_data->font_, glyph, &advance); SkFontGetGlyphWidthForHarfBuzz(hb_font_data->font_, glyph, &advance);
return advance; return advance;
} }
...@@ -150,8 +150,8 @@ static void HarfBuzzGetGlyphHorizontalAdvances( ...@@ -150,8 +150,8 @@ static void HarfBuzzGetGlyphHorizontalAdvances(
void* user_data) { void* user_data) {
HarfBuzzFontData* hb_font_data = HarfBuzzFontData* hb_font_data =
reinterpret_cast<HarfBuzzFontData*>(font_data); reinterpret_cast<HarfBuzzFontData*>(font_data);
GetGlyphWidthForHarfBuzz(hb_font_data->font_, count, first_glyph, SkFontGetGlyphWidthForHarfBuzz(hb_font_data->font_, count, first_glyph,
glyph_stride, first_advance, advance_stride); glyph_stride, first_advance, advance_stride);
} }
static hb_bool_t HarfBuzzGetGlyphVerticalOrigin(hb_font_t* hb_font, static hb_bool_t HarfBuzzGetGlyphVerticalOrigin(hb_font_t* hb_font,
...@@ -201,7 +201,7 @@ static hb_bool_t HarfBuzzGetGlyphExtents(hb_font_t* hb_font, ...@@ -201,7 +201,7 @@ static hb_bool_t HarfBuzzGetGlyphExtents(hb_font_t* hb_font,
HarfBuzzFontData* hb_font_data = HarfBuzzFontData* hb_font_data =
reinterpret_cast<HarfBuzzFontData*>(font_data); reinterpret_cast<HarfBuzzFontData*>(font_data);
GetGlyphExtentsForHarfBuzz(hb_font_data->font_, glyph, extents); SkFontGetGlyphExtentsForHarfBuzz(hb_font_data->font_, glyph, extents);
return true; return true;
} }
......
...@@ -348,7 +348,7 @@ FloatRect SimpleFontData::PlatformBoundsForGlyph(Glyph glyph) const { ...@@ -348,7 +348,7 @@ FloatRect SimpleFontData::PlatformBoundsForGlyph(Glyph glyph) const {
static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated."); static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated.");
SkRect bounds; SkRect bounds;
GetBoundsForGlyph(font_, glyph, &bounds); SkFontGetBoundsForGlyph(font_, glyph, &bounds);
return FloatRect(bounds); return FloatRect(bounds);
} }
...@@ -360,7 +360,7 @@ void SimpleFontData::BoundsForGlyphs(const Vector<Glyph, 256>& glyphs, ...@@ -360,7 +360,7 @@ void SimpleFontData::BoundsForGlyphs(const Vector<Glyph, 256>& glyphs,
return; return;
DCHECK_EQ(bounds->size(), glyphs.size()); DCHECK_EQ(bounds->size(), glyphs.size());
GetBoundsForGlyphs(font_, glyphs, bounds->data()); SkFontGetBoundsForGlyphs(font_, glyphs, bounds->data());
} }
float SimpleFontData::PlatformWidthForGlyph(Glyph glyph) const { float SimpleFontData::PlatformWidthForGlyph(Glyph glyph) const {
...@@ -369,7 +369,7 @@ float SimpleFontData::PlatformWidthForGlyph(Glyph glyph) const { ...@@ -369,7 +369,7 @@ float SimpleFontData::PlatformWidthForGlyph(Glyph glyph) const {
static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated."); static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated.");
return GetWidthForGlyph(font_, glyph); return SkFontGetWidthForGlyph(font_, glyph);
} }
} // namespace blink } // namespace blink
...@@ -27,9 +27,9 @@ const T* advance_by_byte_size(const T* p, unsigned byte_size) { ...@@ -27,9 +27,9 @@ const T* advance_by_byte_size(const T* p, unsigned byte_size) {
} // namespace } // namespace
void GetGlyphWidthForHarfBuzz(const SkFont& font, void SkFontGetGlyphWidthForHarfBuzz(const SkFont& font,
hb_codepoint_t codepoint, hb_codepoint_t codepoint,
hb_position_t* width) { hb_position_t* width) {
DCHECK_LE(codepoint, 0xFFFFu); DCHECK_LE(codepoint, 0xFFFFu);
CHECK(width); CHECK(width);
...@@ -42,12 +42,12 @@ void GetGlyphWidthForHarfBuzz(const SkFont& font, ...@@ -42,12 +42,12 @@ void GetGlyphWidthForHarfBuzz(const SkFont& font,
*width = SkiaScalarToHarfBuzzPosition(sk_width); *width = SkiaScalarToHarfBuzzPosition(sk_width);
} }
void GetGlyphWidthForHarfBuzz(const SkFont& font, void SkFontGetGlyphWidthForHarfBuzz(const SkFont& font,
unsigned count, unsigned count,
const hb_codepoint_t* glyphs, const hb_codepoint_t* glyphs,
const unsigned glyph_stride, const unsigned glyph_stride,
hb_position_t* advances, hb_position_t* advances,
unsigned advance_stride) { unsigned advance_stride) {
// Batch the call to getWidths because its function entry cost is not // Batch the call to getWidths because its function entry cost is not
// cheap. getWidths accepts multiple glyphd ID, but not from a sparse // cheap. getWidths accepts multiple glyphd ID, but not from a sparse
// array that copy them to a regular array. // array that copy them to a regular array.
...@@ -77,9 +77,9 @@ void GetGlyphWidthForHarfBuzz(const SkFont& font, ...@@ -77,9 +77,9 @@ void GetGlyphWidthForHarfBuzz(const SkFont& font,
// supposed to heuristically place combining marks around base glyphs. HarfBuzz // supposed to heuristically place combining marks around base glyphs. HarfBuzz
// does this by measuring "ink boxes" of glyphs, and placing them according to // does this by measuring "ink boxes" of glyphs, and placing them according to
// Unicode mark classes. Above, below, centered or left or right, etc. // Unicode mark classes. Above, below, centered or left or right, etc.
void GetGlyphExtentsForHarfBuzz(const SkFont& font, void SkFontGetGlyphExtentsForHarfBuzz(const SkFont& font,
hb_codepoint_t codepoint, hb_codepoint_t codepoint,
hb_glyph_extents_t* extents) { hb_glyph_extents_t* extents) {
DCHECK_LE(codepoint, 0xFFFFu); DCHECK_LE(codepoint, 0xFFFFu);
CHECK(extents); CHECK(extents);
...@@ -109,7 +109,7 @@ void GetGlyphExtentsForHarfBuzz(const SkFont& font, ...@@ -109,7 +109,7 @@ void GetGlyphExtentsForHarfBuzz(const SkFont& font,
extents->height = SkiaScalarToHarfBuzzPosition(-sk_bounds.height()); extents->height = SkiaScalarToHarfBuzzPosition(-sk_bounds.height());
} }
void GetBoundsForGlyph(const SkFont& font, Glyph glyph, SkRect* bounds) { void SkFontGetBoundsForGlyph(const SkFont& font, Glyph glyph, SkRect* bounds) {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// TODO(drott): Remove this once we have better metrics bounds // TODO(drott): Remove this once we have better metrics bounds
// on Mac, https://bugs.chromium.org/p/skia/issues/detail?id=5328 // on Mac, https://bugs.chromium.org/p/skia/issues/detail?id=5328
...@@ -127,12 +127,12 @@ void GetBoundsForGlyph(const SkFont& font, Glyph glyph, SkRect* bounds) { ...@@ -127,12 +127,12 @@ void GetBoundsForGlyph(const SkFont& font, Glyph glyph, SkRect* bounds) {
} }
} }
void GetBoundsForGlyphs(const SkFont& font, void SkFontGetBoundsForGlyphs(const SkFont& font,
const Vector<Glyph, 256>& glyphs, const Vector<Glyph, 256>& glyphs,
SkRect* bounds) { SkRect* bounds) {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
for (unsigned i = 0; i < glyphs.size(); i++) { for (unsigned i = 0; i < glyphs.size(); i++) {
GetBoundsForGlyph(font, glyphs[i], &bounds[i]); SkFontGetBoundsForGlyph(font, glyphs[i], &bounds[i]);
} }
#else #else
static_assert(sizeof(Glyph) == 2, "Skia expects 2 bytes glyph id."); static_assert(sizeof(Glyph) == 2, "Skia expects 2 bytes glyph id.");
...@@ -148,7 +148,7 @@ void GetBoundsForGlyphs(const SkFont& font, ...@@ -148,7 +148,7 @@ void GetBoundsForGlyphs(const SkFont& font,
#endif #endif
} }
float GetWidthForGlyph(const SkFont& font, Glyph glyph) { float SkFontGetWidthForGlyph(const SkFont& font, Glyph glyph) {
SkScalar sk_width; SkScalar sk_width;
font.getWidths(&glyph, 1, &sk_width, nullptr); font.getWidths(&glyph, 1, &sk_width, nullptr);
......
...@@ -15,22 +15,24 @@ class SkFont; ...@@ -15,22 +15,24 @@ class SkFont;
namespace blink { namespace blink {
void GetGlyphWidthForHarfBuzz(const SkFont&, void SkFontGetGlyphWidthForHarfBuzz(const SkFont&,
hb_codepoint_t, hb_codepoint_t,
hb_position_t* width); hb_position_t* width);
void GetGlyphWidthForHarfBuzz(const SkFont&, void SkFontGetGlyphWidthForHarfBuzz(const SkFont&,
unsigned count, unsigned count,
const hb_codepoint_t* first_glyph, const hb_codepoint_t* first_glyph,
unsigned glyph_stride, unsigned glyph_stride,
hb_position_t* first_advance, hb_position_t* first_advance,
unsigned advance_stride); unsigned advance_stride);
void GetGlyphExtentsForHarfBuzz(const SkFont&, void SkFontGetGlyphExtentsForHarfBuzz(const SkFont&,
hb_codepoint_t, hb_codepoint_t,
hb_glyph_extents_t*); hb_glyph_extents_t*);
void GetBoundsForGlyph(const SkFont&, Glyph, SkRect* bounds); void SkFontGetBoundsForGlyph(const SkFont&, Glyph, SkRect* bounds);
void GetBoundsForGlyphs(const SkFont&, const Vector<Glyph, 256>&, SkRect*); void SkFontGetBoundsForGlyphs(const SkFont&,
float GetWidthForGlyph(const SkFont&, Glyph); const Vector<Glyph, 256>&,
SkRect*);
float SkFontGetWidthForGlyph(const SkFont&, Glyph);
hb_position_t SkiaScalarToHarfBuzzPosition(SkScalar value); hb_position_t SkiaScalarToHarfBuzzPosition(SkScalar value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment