Commit 1fdcaafe authored by Nicolás Peña Moreno's avatar Nicolás Peña Moreno Committed by Commit Bot

[LCP] regression tentative fix

This CL adds some optimization to do an early return when we know that
the PaintTimingDetectors are not going to do any work. This is the case
when the documentElement is visible and there is some opacity:0 (as
those paints are going to be ignored), as well as when the
documentElement is invisible and there is an opacity:0 depth higher than
1.

Bug: 1113723, 1113411, 1113067

Change-Id: If7a5a0224a89aa1da659b177da0d45d8dca30d57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2360480Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799242}
parent 002c4b58
...@@ -137,6 +137,8 @@ void PaintTimingDetector::NotifyImagePaint( ...@@ -137,6 +137,8 @@ void PaintTimingDetector::NotifyImagePaint(
const ImageResourceContent* cached_image, const ImageResourceContent* cached_image,
const PropertyTreeStateOrAlias& current_paint_chunk_properties, const PropertyTreeStateOrAlias& current_paint_chunk_properties,
const IntRect& image_border) { const IntRect& image_border) {
if (IgnorePaintTimingScope::ShouldIgnore())
return;
LocalFrameView* frame_view = object.GetFrameView(); LocalFrameView* frame_view = object.GetFrameView();
if (!frame_view) if (!frame_view)
return; return;
...@@ -153,6 +155,8 @@ void PaintTimingDetector::NotifyImagePaint( ...@@ -153,6 +155,8 @@ void PaintTimingDetector::NotifyImagePaint(
void PaintTimingDetector::NotifyImageFinished( void PaintTimingDetector::NotifyImageFinished(
const LayoutObject& object, const LayoutObject& object,
const ImageResourceContent* cached_image) { const ImageResourceContent* cached_image) {
if (IgnorePaintTimingScope::ShouldIgnore())
return;
if (image_paint_timing_detector_) if (image_paint_timing_detector_)
image_paint_timing_detector_->NotifyImageFinished(object, cached_image); image_paint_timing_detector_->NotifyImageFinished(object, cached_image);
} }
......
...@@ -312,7 +312,7 @@ class ScopedPaintTimingDetectorBlockPaintHook { ...@@ -312,7 +312,7 @@ class ScopedPaintTimingDetectorBlockPaintHook {
// static // static
inline void PaintTimingDetector::NotifyTextPaint( inline void PaintTimingDetector::NotifyTextPaint(
const IntRect& text_visual_rect) { const IntRect& text_visual_rect) {
if (IgnorePaintTimingScope::IgnoreDepth() > 1) if (IgnorePaintTimingScope::ShouldIgnore())
return; return;
ScopedPaintTimingDetectorBlockPaintHook::AggregateTextPaint(text_visual_rect); ScopedPaintTimingDetectorBlockPaintHook::AggregateTextPaint(text_visual_rect);
} }
......
...@@ -35,6 +35,14 @@ class PLATFORM_EXPORT IgnorePaintTimingScope { ...@@ -35,6 +35,14 @@ class PLATFORM_EXPORT IgnorePaintTimingScope {
static void IncrementIgnoreDepth() { ++ignore_depth_; } static void IncrementIgnoreDepth() { ++ignore_depth_; }
static int IgnoreDepth() { return ignore_depth_; } static int IgnoreDepth() { return ignore_depth_; }
// Used to bail out of paint timing algorithms when we know we won't track
// anything. We want to do this when a) document is visible but there is some
// opacity b) document is invisible but the depth is beyond 1.
static bool ShouldIgnore() {
return (!is_document_element_invisible_ && ignore_depth_) ||
ignore_depth_ > 1;
}
private: private:
base::AutoReset<int> reset_ignore_depth_; base::AutoReset<int> reset_ignore_depth_;
base::AutoReset<bool> reset_is_document_element_invisible_; base::AutoReset<bool> reset_is_document_element_invisible_;
......
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