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

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

Issue 378253003: Saturated arithmetic changed to use templates to fix build-issues (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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') | Source/wtf/SaturatedArithmetic.h » ('J')
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ALWAYS_INLINE void setValue(int value) 223 ALWAYS_INLINE void setValue(int value)
224 { 224 {
225 m_value = saturatedSet(value, kLayoutUnitFractionalBits); 225 // The inner function needs to be implemented as a template to
226 // maintain a common interface for both C++ and ARM versions. The first
227 // parameter specifies how many bits we saturate to (for ARM).
228 m_value = saturatedSetSigned<
229 32-kLayoutUnitFractionalBits,
Sami 2014/07/09 13:59:26 Please add spaces around the '-'.
picksi 2014/07/09 14:27:52 Done.
230 kLayoutUnitFractionalBits>(value);
226 } 231 }
227 232
228 inline void setValue(unsigned value) 233 ALWAYS_INLINE void setValue(unsigned value)
229 { 234 {
230 m_value = saturatedSet(value, kLayoutUnitFractionalBits); 235 // The inner function needs to be implemented as a template to
236 // maintain a common interface for both C++ and ARM versions. The first
237 // parameter specifies how many bits we saturate to (for ARM). This is
238 // one bit less than the signed version due to the ARM instructions for
239 // unsigned saturation.
240 m_value = saturatedSetUnsigned<
241 31-kLayoutUnitFractionalBits,
Sami 2014/07/09 13:59:26 Ditto.
picksi 2014/07/09 14:27:52 Done.
242 kLayoutUnitFractionalBits>(value);
231 } 243 }
232 244
233 int m_value; 245 int m_value;
234 }; 246 };
235 247
236 inline bool operator<=(const LayoutUnit& a, const LayoutUnit& b) 248 inline bool operator<=(const LayoutUnit& a, const LayoutUnit& b)
237 { 249 {
238 return a.rawValue() <= b.rawValue(); 250 return a.rawValue() <= b.rawValue();
239 } 251 }
240 252
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 if (value >= max) 800 if (value >= max)
789 return max; 801 return max;
790 if (value <= min) 802 if (value <= min)
791 return min; 803 return min;
792 return value; 804 return value;
793 } 805 }
794 806
795 } // namespace WebCore 807 } // namespace WebCore
796 808
797 #endif // LayoutUnit_h 809 #endif // LayoutUnit_h
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/SaturatedArithmetic.h » ('j') | Source/wtf/SaturatedArithmetic.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698