Commit 78cb39f8 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Use ink overflow to optimize selection text painter

When r752093 crrev.com/c/2111553 optimized two-pass paints of
selected text, it used frame rect.

This patch changes it to use ink-overflow instead.

Using ink-overflow as is can cause the similar performance
regression as crbug.com/1062767. From the investigations on
blink_perf.paint/select-all-words, the count of 2-pass paint
and average speed vary by:
                            2-pass Avg
  Frame rect                     29  0.0% 3194.094500003848ms
  Ink overflow                 5585 -8.3% 3457.8985000087414ms
  Ink overflow w/1px inflation  449 -0.9% 3222.998499998357ms
  Ink overflow w/2px inflation   14 +0.2% 3186.6954999917652ms
This patch uses 1px inflation for the balance between the
correctness and the performance.

Bug: 1108580
Change-Id: I5584461a5b605c77f457181fa597202fa33c4ca1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315897Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791360}
parent 6d4d0812
...@@ -54,11 +54,15 @@ void NGTextPainter::PaintSelectedText(unsigned start_offset, ...@@ -54,11 +54,15 @@ void NGTextPainter::PaintSelectedText(unsigned start_offset,
if (!fragment_paint_info_.shape_result) if (!fragment_paint_info_.shape_result)
return; return;
// Use fast path if all glyphs fit in |selection_rect|. Note |text_bounds_| is // Use fast path if all glyphs fit in |selection_rect|. |visual_rect_| is the
// the bounds of all glyphs of this text fragment, including characters before // ink bounds of all glyphs of this text fragment, including characters before
// |start_offset| or after |end_offset|. Computing exact bounds is expensive // |start_offset| or after |end_offset|. Computing exact bounds is expensive
// that this code only checks bounds of all glyphs. // that this code only checks bounds of all glyphs.
if (selection_rect.Contains(text_bounds_)) { IntRect snapped_selection_rect(PixelSnappedIntRect(selection_rect));
// Allowing 1px overflow is almost unnoticeable, while it can avoid two-pass
// painting in most small text.
snapped_selection_rect.Inflate(1);
if (snapped_selection_rect.Contains(visual_rect_)) {
Paint(start_offset, end_offset, length, selection_style, node_id); Paint(start_offset, end_offset, length, selection_style, node_id);
return; return;
} }
......
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