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

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

Issue 2171813002: Better performance for -LayoutUnit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | third_party/WebKit/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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 return LayoutUnit(a) - b; 637 return LayoutUnit(a) - b;
638 } 638 }
639 639
640 inline float operator-(const float a, const LayoutUnit& b) 640 inline float operator-(const float a, const LayoutUnit& b)
641 { 641 {
642 return a - b.toFloat(); 642 return a - b.toFloat();
643 } 643 }
644 644
645 inline LayoutUnit operator-(const LayoutUnit& a) 645 inline LayoutUnit operator-(const LayoutUnit& a)
646 { 646 {
647 // -min() is saturated to max().
648 if (a == LayoutUnit::min())
649 return LayoutUnit::max();
650
651 LayoutUnit returnVal; 647 LayoutUnit returnVal;
652 returnVal.setRawValue(-a.rawValue()); 648 returnVal.setRawValue(saturatedNegative(a.rawValue()));
653 return returnVal; 649 return returnVal;
654 } 650 }
655 651
656 // For returning the remainder after a division with integer results. 652 // For returning the remainder after a division with integer results.
657 inline LayoutUnit intMod(const LayoutUnit& a, const LayoutUnit& b) 653 inline LayoutUnit intMod(const LayoutUnit& a, const LayoutUnit& b)
658 { 654 {
659 // This calculates the modulo so that: a = static_cast<int>(a / b) * b + int Mod(a, b). 655 // This calculates the modulo so that: a = static_cast<int>(a / b) * b + int Mod(a, b).
660 LayoutUnit returnVal; 656 LayoutUnit returnVal;
661 returnVal.setRawValue(a.rawValue() % b.rawValue()); 657 returnVal.setRawValue(a.rawValue() % b.rawValue());
662 return returnVal; 658 return returnVal;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 807 }
812 808
813 inline std::ostream& operator<<(std::ostream& stream, const LayoutUnit& value) 809 inline std::ostream& operator<<(std::ostream& stream, const LayoutUnit& value)
814 { 810 {
815 return stream << value.toDouble(); 811 return stream << value.toDouble();
816 } 812 }
817 813
818 } // namespace blink 814 } // namespace blink
819 815
820 #endif // LayoutUnit_h 816 #endif // LayoutUnit_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/SaturatedArithmetic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698