Commit 870c2627 authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

[CI] Inline FloatSize::IsZero and FloatRoundedRect::IsZero

blink_perf.events.hit-test-lots-of-layers is a microbenchmark of
hit PaintLayer::HitTestLayer which uses GeometryMapper. One of the
hottest functions is GeometryMapper::LocalToClipRectInternal which
creates a lot of FloatClipRects that check FloatRoundedRect::IsZero
in their constructor. By inlining the IsZero functions, we get a
3%-4% improvement on the entire benchmark.

Bug: 818772
Change-Id: I0fb4c02152b799399aa19d521ba91ed46e326c3c
Reviewed-on: https://chromium-review.googlesource.com/966797Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543802}
parent cbdfc885
......@@ -49,11 +49,6 @@ FloatRoundedRect::FloatRoundedRect(const FloatRect& rect,
const FloatSize& bottom_right)
: rect_(rect), radii_(top_left, top_right, bottom_left, bottom_right) {}
bool FloatRoundedRect::Radii::IsZero() const {
return top_left_.IsZero() && top_right_.IsZero() && bottom_left_.IsZero() &&
bottom_right_.IsZero();
}
void FloatRoundedRect::Radii::Scale(float factor) {
if (factor == 1)
return;
......
......@@ -73,7 +73,10 @@ class PLATFORM_EXPORT FloatRoundedRect {
const FloatSize& BottomLeft() const { return bottom_left_; }
const FloatSize& BottomRight() const { return bottom_right_; }
bool IsZero() const;
bool IsZero() const {
return top_left_.IsZero() && top_right_.IsZero() &&
bottom_left_.IsZero() && bottom_right_.IsZero();
}
void Scale(float factor);
// Multiply all radii by |factor| and floor the result to the nearest
......
......@@ -46,11 +46,6 @@ float FloatSize::DiagonalLength() const {
return hypotf(width_, height_);
}
bool FloatSize::IsZero() const {
return fabs(width_) < std::numeric_limits<float>::epsilon() &&
fabs(height_) < std::numeric_limits<float>::epsilon();
}
bool FloatSize::IsExpressibleAsIntSize() const {
return isWithinIntRange(width_) && isWithinIntRange(height_);
}
......
......@@ -70,7 +70,10 @@ class PLATFORM_EXPORT FloatSize {
void SetHeight(float height) { height_ = height; }
bool IsEmpty() const { return width_ <= 0 || height_ <= 0; }
bool IsZero() const;
bool IsZero() const {
return fabs(width_) < std::numeric_limits<float>::epsilon() &&
fabs(height_) < std::numeric_limits<float>::epsilon();
}
bool IsExpressibleAsIntSize() const;
float AspectRatio() const { return width_ / height_; }
......
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