Commit 5a643a1e authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Avoid batch preparation for SkPaint::getTextWidth on Mac

This patch stops batching SkPaint::getTextWidth() on Mac.

Batching SkPaint::getTextWidth() http://crrev.com/c/1150010
has no benefits on Mac because Mac uses getTextPath() instead
of getTextWidth() due to
https://bugs.chromium.org/p/skia/issues/detail?id=5328

The cost to prepare batching is usually much lower than the
benefit of batching, the total speed is more than 10x faster,
but since Mac does not get the benefit at all, the cost of
the preparation turned out to be not ignorable.

http://crrev.com/c/1150010:
https://pinpoint-dot-chromeperf.appspot.com/job/14d1dc0fa40000
This CL:
https://pinpoint-dot-chromeperf.appspot.com/job/11a873fda40000

Bug: 868148
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: Ifbb0f6576cd58f36cd17463a550a15924f5b2209
Reviewed-on: https://chromium-review.googlesource.com/1153007
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578711}
parent 023276ea
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "base/containers/adapters.h" #include "base/containers/adapters.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "third_party/blink/renderer/platform/fonts/character_range.h" #include "third_party/blink/renderer/platform/fonts/character_range.h"
#include "third_party/blink/renderer/platform/fonts/font.h" #include "third_party/blink/renderer/platform/fonts/font.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.h" #include "third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.h"
...@@ -913,6 +914,18 @@ void ShapeResult::ComputeGlyphBounds(const ShapeResult::RunInfo& run) { ...@@ -913,6 +914,18 @@ void ShapeResult::ComputeGlyphBounds(const ShapeResult::RunInfo& run) {
// Skia runs much faster if we give a list of glyph ID rather than calling it // Skia runs much faster if we give a list of glyph ID rather than calling it
// on each glyph. // on each glyph.
const SimpleFontData& current_font_data = *run.font_data_; const SimpleFontData& current_font_data = *run.font_data_;
#if defined(OS_MACOSX)
// TODO(kojii): MacOS does not benefit from batching the Skia request due to
// https://bugs.chromium.org/p/skia/issues/detail?id=5328 , and the cost to
// prepare batching, which is normally much less than the benefit of batching,
// is not ignorable unfortunately.
GlyphBoundsAccumulator bounds(width_);
for (const HarfBuzzRunGlyphData& glyph_data : run.glyph_data_) {
bounds.Unite<is_horizontal_run>(
glyph_data, current_font_data.BoundsForGlyph(glyph_data.glyph));
bounds.origin += glyph_data.advance;
}
#else
unsigned num_glyphs = run.glyph_data_.size(); unsigned num_glyphs = run.glyph_data_.size();
Vector<Glyph, 256> glyphs(num_glyphs); Vector<Glyph, 256> glyphs(num_glyphs);
for (unsigned i = 0; i < num_glyphs; i++) for (unsigned i = 0; i < num_glyphs; i++)
...@@ -926,6 +939,7 @@ void ShapeResult::ComputeGlyphBounds(const ShapeResult::RunInfo& run) { ...@@ -926,6 +939,7 @@ void ShapeResult::ComputeGlyphBounds(const ShapeResult::RunInfo& run) {
bounds.Unite<is_horizontal_run>(glyph_data, bounds_list[i]); bounds.Unite<is_horizontal_run>(glyph_data, bounds_list[i]);
bounds.origin += glyph_data.advance; bounds.origin += glyph_data.advance;
} }
#endif
if (!is_horizontal_run) if (!is_horizontal_run)
bounds.ConvertVerticalRunToLogical(current_font_data.GetFontMetrics()); bounds.ConvertVerticalRunToLogical(current_font_data.GetFontMetrics());
glyph_bounding_box_.Unite(bounds.bounds); glyph_bounding_box_.Unite(bounds.bounds);
......
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