Commit 79c4dc9d authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

Views: Add MRUCache of results from ShapeRunWithFont

Bookmark folders using Views are very janky (~5 fps, with the CPU
at 100%). Calls to RenderTextHarfBuzz::ShapeRunWithFont account for
almost all of this time.

Many of the calls to ShapeRunWithFont are done with the same arguments
every frame. To alleviate some of this jank, add a cache the results of
this function call.

Refactor RenderTextHarfBuzz::ShapeRunWithFont to be stateless, and add
structures ShapeRunWithFontInput and ShapeRunWithFontOutput for the
arguments and output of the function. Use ShapeRunWithFontInput as
a cache key.

Bug: 826265
Change-Id: Ic6726c1152c44dc5cb0eccddf1ff3adcd060d8e7
Reviewed-on: https://chromium-review.googlesource.com/1123456
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572420}
parent 6d36ece1
......@@ -8,19 +8,6 @@
namespace gfx {
FontRenderParams::FontRenderParams()
: antialiasing(true),
subpixel_positioning(true),
autohinter(false),
use_bitmaps(false),
hinting(HINTING_MEDIUM),
subpixel_rendering(SUBPIXEL_RENDERING_NONE) {
}
FontRenderParams::FontRenderParams(const FontRenderParams& other) = default;
FontRenderParams::~FontRenderParams() {}
// static
SkFontLCDConfig::LCDOrder FontRenderParams::SubpixelRenderingToSkiaLCDOrder(
FontRenderParams::SubpixelRendering subpixel_rendering) {
......
......@@ -18,9 +18,13 @@ namespace gfx {
// A collection of parameters describing how text should be rendered on Linux.
struct GFX_EXPORT FontRenderParams {
FontRenderParams();
FontRenderParams(const FontRenderParams& other);
~FontRenderParams();
bool operator==(const FontRenderParams& other) const {
return antialiasing == other.antialiasing &&
subpixel_positioning == other.subpixel_positioning &&
autohinter == other.autohinter && use_bitmaps == other.use_bitmaps &&
hinting == other.hinting &&
subpixel_rendering == other.subpixel_rendering;
}
// Level of hinting to be applied.
enum Hinting {
......@@ -45,27 +49,27 @@ struct GFX_EXPORT FontRenderParams {
// Antialiasing (grayscale if |subpixel_rendering| is SUBPIXEL_RENDERING_NONE
// and RGBA otherwise).
bool antialiasing;
bool antialiasing = true;
// Should subpixel positioning (i.e. fractional X positions for glyphs) be
// used?
// TODO(derat): Remove this; we don't set it in the browser and mostly ignore
// it in Blink: http://crbug.com/396659
bool subpixel_positioning;
bool subpixel_positioning = true;
// Should FreeType's autohinter be used (as opposed to Freetype's bytecode
// interpreter, which uses fonts' own hinting instructions)?
bool autohinter;
bool autohinter = false;
// Should embedded bitmaps in fonts should be used?
bool use_bitmaps;
bool use_bitmaps = false;
// Hinting level.
Hinting hinting;
Hinting hinting = HINTING_MEDIUM;
// Whether subpixel rendering should be used or not, and if so, the display's
// subpixel order.
SubpixelRendering subpixel_rendering;
SubpixelRendering subpixel_rendering = SUBPIXEL_RENDERING_NONE;
static SkFontLCDConfig::LCDOrder SubpixelRenderingToSkiaLCDOrder(
SubpixelRendering subpixel_rendering);
......
This diff is collapsed.
......@@ -76,8 +76,8 @@ struct GFX_EXPORT TextRunHarfBuzz {
UBiDiLevel level;
UScriptCode script;
std::unique_ptr<uint16_t[]> glyphs;
std::unique_ptr<SkPoint[]> positions;
std::vector<uint16_t> glyphs;
std::vector<SkPoint> positions;
std::vector<uint32_t> glyph_to_char;
size_t glyph_count;
......
......@@ -3839,7 +3839,7 @@ TEST_P(RenderTextHarfBuzzTest, HarfBuzz_SubglyphGraphemePartition) {
run.range = Range(0, 4);
run.glyph_count = 2;
run.glyph_to_char.resize(2);
run.positions.reset(new SkPoint[4]);
run.positions.resize(4);
run.width = 20;
RenderTextHarfBuzz* render_text = GetRenderTextHarfBuzz();
......
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