Commit de838847 authored by Steve Kobes's avatar Steve Kobes Committed by Commit Bot

Add sweep_line_region_granularity Finch param.

This controls the degree of region granularity snapping that occurs in
JankTracker when the sweep line algorithm (JankTrackingSweepLine) is
enabled.  Previously, the sweep line feature disabled all granularity
snapping.

The default param setting, kHigh, matches the degree of granularity
snapping that is performed without the sweep line algorithm.

Bug: 581518
Change-Id: I75a5264b9625349572e6a7f8a7249852e2a8304a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1655984
Commit-Queue: Steve Kobes <skobes@chromium.org>
Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Reviewed-by: default avatarEmily Hanley <eyaich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668556}
parent 3feaca4b
......@@ -4,8 +4,10 @@
#include "third_party/blink/renderer/core/layout/jank_tracker.h"
#include "base/metrics/field_trial_params.h"
#include "cc/layers/heads_up_display_layer.h"
#include "cc/layers/picture_layer.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
......@@ -26,11 +28,11 @@
namespace blink {
static constexpr TimeDelta kTimerDelay = TimeDelta::FromMilliseconds(500);
static const float kRegionGranularitySteps = 60.0;
// TODO: Vary by Finch experiment parameter.
static const float kSweepLineRegionGranularity = 1.0;
static const float kMovementThreshold = 3.0; // CSS pixels.
// Level of granularity snapping for impact region (see RegionGranularityScale).
enum GranularitySnapping { kPixel = 1, kLow = 2, kMedium = 3, kHigh = 4 };
static FloatPoint LogicalStart(const FloatRect& rect,
const LayoutObject& object) {
const ComputedStyle* style = object.Style();
......@@ -50,11 +52,29 @@ static float GetMoveDistance(const FloatRect& old_rect,
}
static float RegionGranularityScale(const IntRect& viewport) {
if (RuntimeEnabledFeatures::JankTrackingSweepLineEnabled())
return kSweepLineRegionGranularity;
return kRegionGranularitySteps /
std::min(viewport.Height(), viewport.Width());
static const base::FeatureParam<int> kSweepLineRegionGranularity{
&blink::features::kJankTrackingSweepLine, "sweep_line_region_granularity",
kHigh};
GranularitySnapping snapping_type =
RuntimeEnabledFeatures::JankTrackingSweepLineEnabled()
? (GranularitySnapping)kSweepLineRegionGranularity.Get()
: kHigh;
switch (snapping_type) {
case kPixel:
// Snap to multiples of 1px.
return 1.0;
case kLow:
// Snap to multiples of 2px.
return 1 / 2.0;
case kMedium:
// Snap to multiples of 5px.
return 1 / 5.0;
case kHigh:
// Snap to multiples of 1/60th of min(viewport width, viewport height).
return 60.0 / std::min(viewport.Height(), viewport.Width());
}
NOTREACHED();
}
static bool EqualWithinMovementThreshold(const FloatPoint& a,
......
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