| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 template <typename T> | 37 template <typename T> |
| 38 class ShapeInterval { | 38 class ShapeInterval { |
| 39 USING_FAST_MALLOC(ShapeInterval); | 39 USING_FAST_MALLOC(ShapeInterval); |
| 40 | 40 |
| 41 public: | 41 public: |
| 42 ShapeInterval() : m_x1(-1), m_x2(-2) { | 42 ShapeInterval() : m_x1(-1), m_x2(-2) { |
| 43 // The initial values of m_x1,x2 don't matter (unless you're looking | 43 // The initial values of m_x1,x2 don't matter (unless you're looking |
| 44 // at them in the debugger) so long as isUndefined() is true. | 44 // at them in the debugger) so long as isUndefined() is true. |
| 45 ASSERT(isUndefined()); | 45 DCHECK(isUndefined()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 ShapeInterval(T x1, T x2) : m_x1(x1), m_x2(x2) { ASSERT(x2 >= x1); } | 48 ShapeInterval(T x1, T x2) : m_x1(x1), m_x2(x2) { DCHECK(x2 >= x1); } |
| 49 | 49 |
| 50 bool isUndefined() const { return m_x2 < m_x1; } | 50 bool isUndefined() const { return m_x2 < m_x1; } |
| 51 T x1() const { return isUndefined() ? 0 : m_x1; } | 51 T x1() const { return isUndefined() ? 0 : m_x1; } |
| 52 T x2() const { return isUndefined() ? 0 : m_x2; } | 52 T x2() const { return isUndefined() ? 0 : m_x2; } |
| 53 T width() const { return isUndefined() ? 0 : m_x2 - m_x1; } | 53 T width() const { return isUndefined() ? 0 : m_x2 - m_x1; } |
| 54 bool isEmpty() const { return isUndefined() ? true : m_x1 == m_x2; } | 54 bool isEmpty() const { return isUndefined() ? true : m_x1 == m_x2; } |
| 55 | 55 |
| 56 void set(T x1, T x2) { | 56 void set(T x1, T x2) { |
| 57 ASSERT(x2 >= x1); | 57 DCHECK_GE(x2, x1); |
| 58 m_x1 = x1; | 58 m_x1 = x1; |
| 59 m_x2 = x2; | 59 m_x2 = x2; |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool overlaps(const ShapeInterval<T>& interval) const { | 62 bool overlaps(const ShapeInterval<T>& interval) const { |
| 63 if (isUndefined() || interval.isUndefined()) | 63 if (isUndefined() || interval.isUndefined()) |
| 64 return false; | 64 return false; |
| 65 return x2() >= interval.x1() && x1() <= interval.x2(); | 65 return x2() >= interval.x1() && x1() <= interval.x2(); |
| 66 } | 66 } |
| 67 | 67 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 94 | 94 |
| 95 typedef ShapeInterval<int> IntShapeInterval; | 95 typedef ShapeInterval<int> IntShapeInterval; |
| 96 typedef ShapeInterval<float> FloatShapeInterval; | 96 typedef ShapeInterval<float> FloatShapeInterval; |
| 97 | 97 |
| 98 typedef Vector<IntShapeInterval> IntShapeIntervals; | 98 typedef Vector<IntShapeInterval> IntShapeIntervals; |
| 99 typedef Vector<FloatShapeInterval> FloatShapeIntervals; | 99 typedef Vector<FloatShapeInterval> FloatShapeIntervals; |
| 100 | 100 |
| 101 } // namespace blink | 101 } // namespace blink |
| 102 | 102 |
| 103 #endif // ShapeInterval_h | 103 #endif // ShapeInterval_h |
| OLD | NEW |