Commit 6da50028 authored by Emil A Eklund's avatar Emil A Eklund Committed by Commit Bot

Optimize and inline EnclosingLayoutRect

The FloatRect version of EnclosingLayoutRect shows up rather prominently
in profiling data for both layout and LayoutNG, particularly in the font
metrics and text shaping code. This change reduces the time spent in the
method by half by avoiding overhead and allowing it to be inlined.

Change-Id: Ica28d6a41edf476619f581c2ff2d9471d13f7c12
Reviewed-on: https://chromium-review.googlesource.com/c/1277597Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599027}
parent 5cd8c123
......@@ -159,12 +159,6 @@ LayoutRect UnionRectEvenIfEmpty(const Vector<LayoutRect>& rects) {
return result;
}
LayoutRect EnclosingLayoutRect(const FloatRect& rect) {
LayoutPoint location = FlooredLayoutPoint(rect.MinXMinYCorner());
LayoutPoint max_point = CeiledLayoutPoint(rect.MaxXMaxYCorner());
return LayoutRect(location, max_point - location);
}
std::ostream& operator<<(std::ostream& ostream, const LayoutRect& rect) {
return ostream << rect.ToString();
}
......
......@@ -32,6 +32,7 @@
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_LAYOUT_RECT_H_
#include <iosfwd>
#include "third_party/blink/renderer/platform/geometry/float_rect.h"
#include "third_party/blink/renderer/platform/geometry/int_rect.h"
#include "third_party/blink/renderer/platform/geometry/layout_point.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect_outsets.h"
......@@ -309,7 +310,13 @@ inline IntRect EnclosedIntRect(const LayoutRect& rect) {
return IntRect(location, max_point - location);
}
PLATFORM_EXPORT LayoutRect EnclosingLayoutRect(const FloatRect&);
inline LayoutRect EnclosingLayoutRect(const FloatRect& rect) {
LayoutUnit x = LayoutUnit::FromFloatFloor(rect.X());
LayoutUnit y = LayoutUnit::FromFloatFloor(rect.Y());
LayoutUnit max_x = LayoutUnit::FromFloatCeil(rect.MaxX());
LayoutUnit max_y = LayoutUnit::FromFloatCeil(rect.MaxY());
return LayoutRect(x, y, max_x - x, max_y - y);
}
inline IntRect PixelSnappedIntRect(LayoutUnit left,
LayoutUnit top,
......
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