Commit 991fa1ab authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

Optimize font measurement code

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I4396b5dbaad5486719a3a3230858ced6cfdb3642
Reviewed-on: https://chromium-review.googlesource.com/1244096Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594078}
parent a5d33b00
......@@ -1150,13 +1150,13 @@ void ShapeResult::ComputeGlyphBounds(const ShapeResult::RunInfo& run) {
Vector<Glyph, 256> glyphs(num_glyphs);
for (unsigned i = 0; i < num_glyphs; i++)
glyphs[i] = run.glyph_data_[i].glyph;
Vector<FloatRect, 256> bounds_list(num_glyphs);
Vector<SkRect, 256> bounds_list(num_glyphs);
current_font_data.BoundsForGlyphs(glyphs, &bounds_list);
GlyphBoundsAccumulator bounds(width_);
for (unsigned i = 0; i < num_glyphs; i++) {
const HarfBuzzRunGlyphData& glyph_data = run.glyph_data_[i];
bounds.Unite<is_horizontal_run>(glyph_data, bounds_list[i]);
bounds.Unite<is_horizontal_run>(glyph_data, FloatRect(bounds_list[i]));
bounds.origin += glyph_data.advance;
}
#endif
......
......@@ -354,18 +354,15 @@ FloatRect SimpleFontData::PlatformBoundsForGlyph(Glyph glyph) const {
return FloatRect(bounds);
}
void SimpleFontData::BoundsForGlyphs(const Vector<Glyph, 256> glyphs,
Vector<FloatRect, 256>* bounds) const {
void SimpleFontData::BoundsForGlyphs(const Vector<Glyph, 256>& glyphs,
Vector<SkRect, 256>* bounds) const {
DCHECK_EQ(glyphs.size(), bounds->size());
if (!platform_data_.size())
return;
Vector<SkRect, 256> skia_bounds(glyphs.size());
SkiaTextMetrics(&paint_).GetSkiaBoundsForGlyphs(glyphs, skia_bounds.data());
for (unsigned i = 0; i < skia_bounds.size(); i++)
(*bounds)[i] = FloatRect(skia_bounds[i]);
DCHECK_EQ(bounds->size(), glyphs.size());
SkiaTextMetrics(&paint_).GetSkiaBoundsForGlyphs(glyphs, bounds->data());
}
float SimpleFontData::PlatformWidthForGlyph(Glyph glyph) const {
......
......@@ -112,7 +112,7 @@ class PLATFORM_EXPORT SimpleFontData : public FontData {
}
FloatRect BoundsForGlyph(Glyph) const;
void BoundsForGlyphs(const Vector<Glyph, 256>, Vector<FloatRect, 256>*) const;
void BoundsForGlyphs(const Vector<Glyph, 256>&, Vector<SkRect, 256>*) const;
FloatRect PlatformBoundsForGlyph(Glyph) const;
float WidthForGlyph(Glyph) const;
float PlatformWidthForGlyph(Glyph) const;
......
......@@ -110,7 +110,7 @@ void SkiaTextMetrics::GetSkiaBoundsForGlyph(Glyph glyph, SkRect* bounds) {
}
}
void SkiaTextMetrics::GetSkiaBoundsForGlyphs(const Vector<Glyph, 256> glyphs,
void SkiaTextMetrics::GetSkiaBoundsForGlyphs(const Vector<Glyph, 256>& glyphs,
SkRect* bounds) {
#if defined(OS_MACOSX)
for (unsigned i = 0; i < glyphs.size(); i++) {
......
......@@ -26,7 +26,7 @@ class SkiaTextMetrics final {
void GetGlyphExtentsForHarfBuzz(hb_codepoint_t, hb_glyph_extents_t*);
void GetSkiaBoundsForGlyph(Glyph, SkRect* bounds);
void GetSkiaBoundsForGlyphs(const Vector<Glyph, 256>, SkRect*);
void GetSkiaBoundsForGlyphs(const Vector<Glyph, 256>&, SkRect*);
float GetSkiaWidthForGlyph(Glyph);
static 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