Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1518)

Unified Diff: base/numerics/saturated_arithmetic.h

Issue 2744423002: Handle large rects better. (Closed)
Patch Set: Followup fixes Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/geometry/rect.h » ('j') | ui/gfx/geometry/rect.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/numerics/saturated_arithmetic.h
diff --git a/base/numerics/saturated_arithmetic.h b/base/numerics/saturated_arithmetic.h
index 7e24fe3617b127fe6641574271f55d3dbafd5f06..012832b014b1d47e61c2a5134307ee05fde13c82 100644
--- a/base/numerics/saturated_arithmetic.h
+++ b/base/numerics/saturated_arithmetic.h
@@ -56,6 +56,14 @@ ALWAYS_INLINE int32_t SaturatedNegative(int32_t a) {
return -a;
}
+ALWAYS_INLINE int32_t SaturatedAbsolute(int32_t a) {
+ if (a >= 0)
+ return a;
+ if (UNLIKELY(a == std::numeric_limits<int>::min()))
+ return std::numeric_limits<int>::max();
+ return -a;
+}
+
ALWAYS_INLINE int GetMaxSaturatedSetResultForTesting(int fractional_shift) {
// For C version the set function maxes out to max int, this differs from
// the ARM asm version, see saturated_arithmetic_arm.h for the equivalent asm
« no previous file with comments | « no previous file | ui/gfx/geometry/rect.h » ('j') | ui/gfx/geometry/rect.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698