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(
float top_side_bearing = top_side_bearing_f_unit * size_per_unit_;
SkRect skiaBounds;
GetBoundsForGlyph(font, glyph, &skiaBounds);
SkFontGetBoundsForGlyph(font, glyph, &skiaBounds);
FloatRect bounds(skiaBounds);
out_xy_array[1] = bounds.Y() - top_side_bearing;
continue;
......
......@@ -135,7 +135,7 @@ static hb_position_t HarfBuzzGetGlyphHorizontalAdvance(hb_font_t* hb_font,
reinterpret_cast<HarfBuzzFontData*>(font_data);
hb_position_t advance = 0;
GetGlyphWidthForHarfBuzz(hb_font_data->font_, glyph, &advance);
SkFontGetGlyphWidthForHarfBuzz(hb_font_data->font_, glyph, &advance);
return advance;
}
......@@ -150,8 +150,8 @@ static void HarfBuzzGetGlyphHorizontalAdvances(
void* user_data) {
HarfBuzzFontData* hb_font_data =
reinterpret_cast<HarfBuzzFontData*>(font_data);
GetGlyphWidthForHarfBuzz(hb_font_data->font_, count, first_glyph,
glyph_stride, first_advance, advance_stride);
SkFontGetGlyphWidthForHarfBuzz(hb_font_data->font_, count, first_glyph,
glyph_stride, first_advance, advance_stride);
}
static hb_bool_t HarfBuzzGetGlyphVerticalOrigin(hb_font_t* hb_font,
......@@ -201,7 +201,7 @@ static hb_bool_t HarfBuzzGetGlyphExtents(hb_font_t* hb_font,
HarfBuzzFontData* hb_font_data =
reinterpret_cast<HarfBuzzFontData*>(font_data);
GetGlyphExtentsForHarfBuzz(hb_font_data->font_, glyph, extents);
SkFontGetGlyphExtentsForHarfBuzz(hb_font_data->font_, glyph, extents);
return true;
}
......
......@@ -348,7 +348,7 @@ FloatRect SimpleFontData::PlatformBoundsForGlyph(Glyph glyph) const {
static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated.");
SkRect bounds;
GetBoundsForGlyph(font_, glyph, &bounds);
SkFontGetBoundsForGlyph(font_, glyph, &bounds);
return FloatRect(bounds);
}
......@@ -360,7 +360,7 @@ void SimpleFontData::BoundsForGlyphs(const Vector<Glyph, 256>& glyphs,
return;
DCHECK_EQ(bounds->size(), glyphs.size());
GetBoundsForGlyphs(font_, glyphs, bounds->data());
SkFontGetBoundsForGlyphs(font_, glyphs, bounds->data());
}
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.");
return GetWidthForGlyph(font_, glyph);
return SkFontGetWidthForGlyph(font_, glyph);
}
} // namespace blink
......@@ -27,9 +27,9 @@ const T* advance_by_byte_size(const T* p, unsigned byte_size) {
} // namespace
void GetGlyphWidthForHarfBuzz(const SkFont& font,
hb_codepoint_t codepoint,
hb_position_t* width) {
void SkFontGetGlyphWidthForHarfBuzz(const SkFont& font,
hb_codepoint_t codepoint,
hb_position_t* width) {
DCHECK_LE(codepoint, 0xFFFFu);
CHECK(width);
......@@ -42,12 +42,12 @@ void GetGlyphWidthForHarfBuzz(const SkFont& font,
*width = SkiaScalarToHarfBuzzPosition(sk_width);
}
void GetGlyphWidthForHarfBuzz(const SkFont& font,
unsigned count,
const hb_codepoint_t* glyphs,
const unsigned glyph_stride,
hb_position_t* advances,
unsigned advance_stride) {
void SkFontGetGlyphWidthForHarfBuzz(const SkFont& font,
unsigned count,
const hb_codepoint_t* glyphs,
const unsigned glyph_stride,
hb_position_t* advances,
unsigned advance_stride) {
// Batch the call to getWidths because its function entry cost is not
// cheap. getWidths accepts multiple glyphd ID, but not from a sparse
// array that copy them to a regular array.
......@@ -77,9 +77,9 @@ void GetGlyphWidthForHarfBuzz(const SkFont& font,
// supposed to heuristically place combining marks around base glyphs. HarfBuzz
// does this by measuring "ink boxes" of glyphs, and placing them according to
// Unicode mark classes. Above, below, centered or left or right, etc.
void GetGlyphExtentsForHarfBuzz(const SkFont& font,
hb_codepoint_t codepoint,
hb_glyph_extents_t* extents) {
void SkFontGetGlyphExtentsForHarfBuzz(const SkFont& font,
hb_codepoint_t codepoint,
hb_glyph_extents_t* extents) {
DCHECK_LE(codepoint, 0xFFFFu);
CHECK(extents);
......@@ -109,7 +109,7 @@ void GetGlyphExtentsForHarfBuzz(const SkFont& font,
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)
// TODO(drott): Remove this once we have better metrics bounds
// 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) {
}
}
void GetBoundsForGlyphs(const SkFont& font,
const Vector<Glyph, 256>& glyphs,
SkRect* bounds) {
void SkFontGetBoundsForGlyphs(const SkFont& font,
const Vector<Glyph, 256>& glyphs,
SkRect* bounds) {
#if defined(OS_MACOSX)
for (unsigned i = 0; i < glyphs.size(); i++) {
GetBoundsForGlyph(font, glyphs[i], &bounds[i]);
SkFontGetBoundsForGlyph(font, glyphs[i], &bounds[i]);
}
#else
static_assert(sizeof(Glyph) == 2, "Skia expects 2 bytes glyph id.");
......@@ -148,7 +148,7 @@ void GetBoundsForGlyphs(const SkFont& font,
#endif
}
float GetWidthForGlyph(const SkFont& font, Glyph glyph) {
float SkFontGetWidthForGlyph(const SkFont& font, Glyph glyph) {
SkScalar sk_width;
font.getWidths(&glyph, 1, &sk_width, nullptr);
......
......@@ -15,22 +15,24 @@ class SkFont;
namespace blink {
void GetGlyphWidthForHarfBuzz(const SkFont&,
hb_codepoint_t,
hb_position_t* width);
void GetGlyphWidthForHarfBuzz(const SkFont&,
unsigned count,
const hb_codepoint_t* first_glyph,
unsigned glyph_stride,
hb_position_t* first_advance,
unsigned advance_stride);
void GetGlyphExtentsForHarfBuzz(const SkFont&,
hb_codepoint_t,
hb_glyph_extents_t*);
void GetBoundsForGlyph(const SkFont&, Glyph, SkRect* bounds);
void GetBoundsForGlyphs(const SkFont&, const Vector<Glyph, 256>&, SkRect*);
float GetWidthForGlyph(const SkFont&, Glyph);
void SkFontGetGlyphWidthForHarfBuzz(const SkFont&,
hb_codepoint_t,
hb_position_t* width);
void SkFontGetGlyphWidthForHarfBuzz(const SkFont&,
unsigned count,
const hb_codepoint_t* first_glyph,
unsigned glyph_stride,
hb_position_t* first_advance,
unsigned advance_stride);
void SkFontGetGlyphExtentsForHarfBuzz(const SkFont&,
hb_codepoint_t,
hb_glyph_extents_t*);
void SkFontGetBoundsForGlyph(const SkFont&, Glyph, SkRect* bounds);
void SkFontGetBoundsForGlyphs(const SkFont&,
const Vector<Glyph, 256>&,
SkRect*);
float SkFontGetWidthForGlyph(const SkFont&, Glyph);
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