Commit 6af433d5 authored by Steve Kobes's avatar Steve Kobes Committed by Commit Bot

Rename LayoutShiftTracker::region_experimental_ to region_.

This removes the old region_ and the !use_sweep_line paths, which are
dead code after the launch of JankTrackingSweepLine.

Bug: 1000716
Change-Id: Id15d0592c860ad8cfa028dbe3e88f62ac85980c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1793002Reviewed-by: default avatarCharlie Andrews <charliea@chromium.org>
Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695646}
parent b42590ac
...@@ -215,9 +215,8 @@ void LayoutShiftTracker::ObjectShifted( ...@@ -215,9 +215,8 @@ void LayoutShiftTracker::ObjectShifted(
visible_old_rect.Scale(scale); visible_old_rect.Scale(scale);
visible_new_rect.Scale(scale); visible_new_rect.Scale(scale);
// TODO(crbug.com/1000716): Rename region_experimental_. region_.AddRect(visible_old_rect);
region_experimental_.AddRect(visible_old_rect); region_.AddRect(visible_new_rect);
region_experimental_.AddRect(visible_new_rect);
} }
void LayoutShiftTracker::NotifyObjectPrePaint( void LayoutShiftTracker::NotifyObjectPrePaint(
...@@ -260,10 +259,7 @@ double LayoutShiftTracker::SubframeWeightingFactor() const { ...@@ -260,10 +259,7 @@ double LayoutShiftTracker::SubframeWeightingFactor() const {
void LayoutShiftTracker::NotifyPrePaintFinished() { void LayoutShiftTracker::NotifyPrePaintFinished() {
if (!IsActive()) if (!IsActive())
return; return;
bool use_sweep_line = true; if (region_.IsEmpty())
bool region_is_empty =
use_sweep_line ? region_experimental_.IsEmpty() : region_.IsEmpty();
if (region_is_empty)
return; return;
IntRect viewport = frame_view_->GetScrollableArea()->VisibleContentRect(); IntRect viewport = frame_view_->GetScrollableArea()->VisibleContentRect();
...@@ -276,9 +272,7 @@ void LayoutShiftTracker::NotifyPrePaintFinished() { ...@@ -276,9 +272,7 @@ void LayoutShiftTracker::NotifyPrePaintFinished() {
double viewport_area = double viewport_area =
double(scaled_viewport.Width()) * double(scaled_viewport.Height()); double(scaled_viewport.Width()) * double(scaled_viewport.Height());
uint64_t region_area = double impact_fraction = region_.Area() / viewport_area;
use_sweep_line ? region_experimental_.Area() : region_.Area();
double impact_fraction = region_area / viewport_area;
DCHECK_GT(impact_fraction, 0); DCHECK_GT(impact_fraction, 0);
DCHECK_GT(frame_max_distance_, 0.0); DCHECK_GT(frame_max_distance_, 0.0);
...@@ -309,17 +303,10 @@ void LayoutShiftTracker::NotifyPrePaintFinished() { ...@@ -309,17 +303,10 @@ void LayoutShiftTracker::NotifyPrePaintFinished() {
ReportShift(score_delta, weighted_score_delta); ReportShift(score_delta, weighted_score_delta);
} }
if (use_sweep_line) { if (!region_.IsEmpty())
if (!region_experimental_.IsEmpty()) { SetLayoutShiftRects(region_.GetRects(), 1);
SetLayoutShiftRects(region_experimental_.GetRects(), 1, true); region_.Reset();
}
region_experimental_.Reset();
} else {
if (!region_.IsEmpty()) {
SetLayoutShiftRects(region_.Rects(), granularity_scale, false);
}
region_ = Region();
}
frame_max_distance_ = 0.0; frame_max_distance_ = 0.0;
frame_scroll_delta_ = ScrollOffset(); frame_scroll_delta_ = ScrollOffset();
} }
...@@ -451,7 +438,7 @@ std::unique_ptr<TracedValue> LayoutShiftTracker::PerFrameTraceData( ...@@ -451,7 +438,7 @@ std::unique_ptr<TracedValue> LayoutShiftTracker::PerFrameTraceData(
IntRect(IntPoint(), IntRect(IntPoint(),
frame_view_->GetScrollableArea()->VisibleContentRect().Size())); frame_view_->GetScrollableArea()->VisibleContentRect().Size()));
RegionToTracedValue(region_experimental_, granularity_scale, *value); RegionToTracedValue(region_, granularity_scale, *value);
value->SetBoolean("is_main_frame", frame_view_->GetFrame().IsMainFrame()); value->SetBoolean("is_main_frame", frame_view_->GetFrame().IsMainFrame());
value->SetBoolean("had_recent_input", input_detected); value->SetBoolean("had_recent_input", input_detected);
...@@ -472,8 +459,7 @@ WebVector<gfx::Rect> LayoutShiftTracker::ConvertIntRectsToGfxRects( ...@@ -472,8 +459,7 @@ WebVector<gfx::Rect> LayoutShiftTracker::ConvertIntRectsToGfxRects(
} }
void LayoutShiftTracker::SetLayoutShiftRects(const Vector<IntRect>& int_rects, void LayoutShiftTracker::SetLayoutShiftRects(const Vector<IntRect>& int_rects,
double granularity_scale, double granularity_scale) {
bool using_sweep_line) {
// Store the layout shift rects in the HUD layer. // Store the layout shift rects in the HUD layer.
GraphicsLayer* root_graphics_layer = GraphicsLayer* root_graphics_layer =
frame_view_->GetLayoutView()->Compositor()->RootGraphicsLayer(); frame_view_->GetLayoutView()->Compositor()->RootGraphicsLayer();
...@@ -488,15 +474,10 @@ void LayoutShiftTracker::SetLayoutShiftRects(const Vector<IntRect>& int_rects, ...@@ -488,15 +474,10 @@ void LayoutShiftTracker::SetLayoutShiftRects(const Vector<IntRect>& int_rects,
return; return;
if (cc_layer->layer_tree_host()->hud_layer()) { if (cc_layer->layer_tree_host()->hud_layer()) {
WebVector<gfx::Rect> rects; WebVector<gfx::Rect> rects;
if (using_sweep_line) {
Region old_region; Region old_region;
for (IntRect rect : int_rects) for (IntRect rect : int_rects)
old_region.Unite(Region(rect)); old_region.Unite(Region(rect));
rects = rects = ConvertIntRectsToGfxRects(old_region.Rects(), granularity_scale);
ConvertIntRectsToGfxRects(old_region.Rects(), granularity_scale);
} else {
rects = ConvertIntRectsToGfxRects(int_rects, granularity_scale);
}
cc_layer->layer_tree_host()->hud_layer()->SetLayoutShiftRects( cc_layer->layer_tree_host()->hud_layer()->SetLayoutShiftRects(
rects.ReleaseVector()); rects.ReleaseVector());
cc_layer->layer_tree_host()->hud_layer()->SetNeedsPushProperties(); cc_layer->layer_tree_host()->hud_layer()->SetNeedsPushProperties();
......
...@@ -76,8 +76,7 @@ class CORE_EXPORT LayoutShiftTracker { ...@@ -76,8 +76,7 @@ class CORE_EXPORT LayoutShiftTracker {
const Vector<IntRect>& int_rects, const Vector<IntRect>& int_rects,
double granularity_scale); double granularity_scale);
void SetLayoutShiftRects(const Vector<IntRect>& int_rects, void SetLayoutShiftRects(const Vector<IntRect>& int_rects,
double granularity_scale, double granularity_scale);
bool using_sweep_line);
void UpdateInputTimestamp(base::TimeTicks timestamp); void UpdateInputTimestamp(base::TimeTicks timestamp);
// This owns us. // This owns us.
...@@ -110,10 +109,7 @@ class CORE_EXPORT LayoutShiftTracker { ...@@ -110,10 +109,7 @@ class CORE_EXPORT LayoutShiftTracker {
PointerdownPendingData pointerdown_pending_data_; PointerdownPendingData pointerdown_pending_data_;
// The per-animation-frame impact region. // The per-animation-frame impact region.
Region region_; LayoutShiftRegion region_;
// Experimental impact region implementation using sweep-line algorithm.
LayoutShiftRegion region_experimental_;
// Tracks the short period after an input event during which we ignore shifts // Tracks the short period after an input event during which we ignore shifts
// for the purpose of cumulative scoring, and report them to the web perf API // for the purpose of cumulative scoring, and report them to the web perf API
......
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