| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef IntPoint_h | 27 #ifndef IntPoint_h |
| 28 #define IntPoint_h | 28 #define IntPoint_h |
| 29 | 29 |
| 30 #include "platform/geometry/IntSize.h" | 30 #include "platform/geometry/IntSize.h" |
| 31 #include "wtf/Allocator.h" | 31 #include "wtf/Allocator.h" |
| 32 #include "wtf/Forward.h" | 32 #include "wtf/Forward.h" |
| 33 #include "wtf/MathExtras.h" | 33 #include "wtf/MathExtras.h" |
| 34 #include "wtf/SaturatedArithmetic.h" |
| 34 #include "wtf/VectorTraits.h" | 35 #include "wtf/VectorTraits.h" |
| 35 | 36 |
| 36 #if OS(MACOSX) | 37 #if OS(MACOSX) |
| 37 typedef struct CGPoint CGPoint; | 38 typedef struct CGPoint CGPoint; |
| 38 | 39 |
| 39 #ifdef __OBJC__ | 40 #ifdef __OBJC__ |
| 40 #import <Foundation/Foundation.h> | 41 #import <Foundation/Foundation.h> |
| 41 #endif | 42 #endif |
| 42 #endif | 43 #endif |
| 43 | 44 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 | 55 |
| 55 int x() const { return m_x; } | 56 int x() const { return m_x; } |
| 56 int y() const { return m_y; } | 57 int y() const { return m_y; } |
| 57 | 58 |
| 58 void setX(int x) { m_x = x; } | 59 void setX(int x) { m_x = x; } |
| 59 void setY(int y) { m_y = y; } | 60 void setY(int y) { m_y = y; } |
| 60 | 61 |
| 61 void move(const IntSize& s) { move(s.width(), s.height()); } | 62 void move(const IntSize& s) { move(s.width(), s.height()); } |
| 62 void moveBy(const IntPoint& offset) { move(offset.x(), offset.y()); } | 63 void moveBy(const IntPoint& offset) { move(offset.x(), offset.y()); } |
| 63 void move(int dx, int dy) { m_x += dx; m_y += dy; } | 64 void move(int dx, int dy) { m_x += dx; m_y += dy; } |
| 65 void saturatedMove(int dx, int dy) |
| 66 { |
| 67 m_x = saturatedAddition(m_x, dx); |
| 68 m_y = saturatedAddition(m_y, dy); |
| 69 } |
| 70 |
| 64 void scale(float sx, float sy) | 71 void scale(float sx, float sy) |
| 65 { | 72 { |
| 66 m_x = lroundf(static_cast<float>(m_x * sx)); | 73 m_x = lroundf(static_cast<float>(m_x * sx)); |
| 67 m_y = lroundf(static_cast<float>(m_y * sy)); | 74 m_y = lroundf(static_cast<float>(m_y * sy)); |
| 68 } | 75 } |
| 69 | 76 |
| 70 IntPoint expandedTo(const IntPoint& other) const | 77 IntPoint expandedTo(const IntPoint& other) const |
| 71 { | 78 { |
| 72 return IntPoint(m_x > other.m_x ? m_x : other.m_x, | 79 return IntPoint(m_x > other.m_x ? m_x : other.m_x, |
| 73 m_y > other.m_y ? m_y : other.m_y); | 80 m_y > other.m_y ? m_y : other.m_y); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 inline int IntPoint::distanceSquaredToPoint(const IntPoint& point) const | 171 inline int IntPoint::distanceSquaredToPoint(const IntPoint& point) const |
| 165 { | 172 { |
| 166 return ((*this) - point).diagonalLengthSquared(); | 173 return ((*this) - point).diagonalLengthSquared(); |
| 167 } | 174 } |
| 168 | 175 |
| 169 } // namespace blink | 176 } // namespace blink |
| 170 | 177 |
| 171 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::IntPoint); | 178 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::IntPoint); |
| 172 | 179 |
| 173 #endif // IntPoint_h | 180 #endif // IntPoint_h |
| OLD | NEW |