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

Side by Side Diff: Source/platform/LayoutUnit.h

Issue 346913004: Some inline ARM assembly for saturated arithmetic, a small speed-up for (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Implicit casting removed Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/wtf/SaturatedArithmetic.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, Google Inc. All rights reserved. 2 * Copyright (c) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 213 }
214 static bool isInBounds(unsigned value) 214 static bool isInBounds(unsigned value)
215 { 215 {
216 return value <= static_cast<unsigned>(std::numeric_limits<int>::max()) / kFixedPointDenominator; 216 return value <= static_cast<unsigned>(std::numeric_limits<int>::max()) / kFixedPointDenominator;
217 } 217 }
218 static bool isInBounds(double value) 218 static bool isInBounds(double value)
219 { 219 {
220 return ::fabs(value) <= std::numeric_limits<int>::max() / kFixedPointDen ominator; 220 return ::fabs(value) <= std::numeric_limits<int>::max() / kFixedPointDen ominator;
221 } 221 }
222 222
223 inline void setValue(int value) 223 ALWAYS_INLINE void setValue(int value)
224 { 224 {
225 if (value > intMaxForLayoutUnit) 225 m_value = saturatedSet(value, kLayoutUnitFractionalBits);
226 m_value = std::numeric_limits<int>::max();
227 else if (value < intMinForLayoutUnit)
228 m_value = std::numeric_limits<int>::min();
229 else
230 m_value = value * kFixedPointDenominator;
231 } 226 }
227
232 inline void setValue(unsigned value) 228 inline void setValue(unsigned value)
233 { 229 {
234 if (value >= static_cast<unsigned>(intMaxForLayoutUnit)) 230 m_value = saturatedSet(value, kLayoutUnitFractionalBits);
235 m_value = std::numeric_limits<int>::max();
236 else
237 m_value = value * kFixedPointDenominator;
238 } 231 }
239 232
240 int m_value; 233 int m_value;
241 }; 234 };
242 235
243 inline bool operator<=(const LayoutUnit& a, const LayoutUnit& b) 236 inline bool operator<=(const LayoutUnit& a, const LayoutUnit& b)
244 { 237 {
245 return a.rawValue() <= b.rawValue(); 238 return a.rawValue() <= b.rawValue();
246 } 239 }
247 240
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 if (value >= max) 788 if (value >= max)
796 return max; 789 return max;
797 if (value <= min) 790 if (value <= min)
798 return min; 791 return min;
799 return value; 792 return value;
800 } 793 }
801 794
802 } // namespace WebCore 795 } // namespace WebCore
803 796
804 #endif // LayoutUnit_h 797 #endif // LayoutUnit_h
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/SaturatedArithmetic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698