Commit 224e6490 authored by wangxianzhu's avatar wangxianzhu Committed by Commit bot

Better performance for -LayoutUnit

BUG=629932

Review-Url: https://codereview.chromium.org/2171813002
Cr-Commit-Position: refs/heads/master@{#406913}
parent e792bd73
......@@ -644,12 +644,8 @@ inline float operator-(const float a, const LayoutUnit& b)
inline LayoutUnit operator-(const LayoutUnit& a)
{
// -min() is saturated to max().
if (a == LayoutUnit::min())
return LayoutUnit::max();
LayoutUnit returnVal;
returnVal.setRawValue(-a.rawValue());
returnVal.setRawValue(saturatedNegative(a.rawValue()));
return returnVal;
}
......
......@@ -73,6 +73,13 @@ ALWAYS_INLINE int32_t saturatedSubtraction(int32_t a, int32_t b)
return result;
}
ALWAYS_INLINE int32_t saturatedNegative(int32_t a)
{
if (UNLIKELY(a == std::numeric_limits<int>::min()))
return std::numeric_limits<int>::max();
return -a;
}
inline int getMaxSaturatedSetResultForTesting(int FractionalShift)
{
// For C version the set function maxes out to max int, this differs from
......
......@@ -33,6 +33,11 @@ ALWAYS_INLINE int32_t saturatedSubtraction(int32_t a, int32_t b)
return result;
}
ALWAYS_INLINE int32_t saturatedNegative(int32_t a)
{
return saturatedSubtraction(0, a);
}
inline int getMaxSaturatedSetResultForTesting(int FractionalShift)
{
// For ARM Asm version the set function maxes out to the biggest
......
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