| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_BASE_INDEX_RECT_H_ | 5 #ifndef CC_BASE_INDEX_RECT_H_ |
| 6 #define CC_BASE_INDEX_RECT_H_ | 6 #define CC_BASE_INDEX_RECT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Clamp indices to the given IndexRect indices. For non-intersecting rects, | 95 // Clamp indices to the given IndexRect indices. For non-intersecting rects, |
| 96 // it makes this index rect invalid. | 96 // it makes this index rect invalid. |
| 97 void ClampTo(const IndexRect& other); | 97 void ClampTo(const IndexRect& other); |
| 98 | 98 |
| 99 // Returns true if the given index identified by index_x and index_y falls | 99 // Returns true if the given index identified by index_x and index_y falls |
| 100 // inside this index rectangle, including edge indices. | 100 // inside this index rectangle, including edge indices. |
| 101 bool Contains(int index_x, int index_y) const; | 101 bool Contains(int index_x, int index_y) const; |
| 102 | 102 |
| 103 // Shrink the index rect by the specified amount on each side. |
| 104 void Inset(int left, int right, int top, int bottom); |
| 105 |
| 103 std::string ToString() const; | 106 std::string ToString() const; |
| 104 | 107 |
| 105 private: | 108 private: |
| 106 int left_; | 109 int left_; |
| 107 int right_; | 110 int right_; |
| 108 int top_; | 111 int top_; |
| 109 int bottom_; | 112 int bottom_; |
| 110 }; | 113 }; |
| 111 | 114 |
| 112 inline bool operator==(const IndexRect& lhs, const IndexRect& rhs) { | 115 inline bool operator==(const IndexRect& lhs, const IndexRect& rhs) { |
| 113 return lhs.left() == rhs.left() && lhs.right() == rhs.right() && | 116 return lhs.left() == rhs.left() && lhs.right() == rhs.right() && |
| 114 lhs.top() == rhs.top() && lhs.bottom() == rhs.bottom(); | 117 lhs.top() == rhs.top() && lhs.bottom() == rhs.bottom(); |
| 115 } | 118 } |
| 116 | 119 |
| 117 inline bool operator!=(const IndexRect& lhs, const IndexRect& rhs) { | 120 inline bool operator!=(const IndexRect& lhs, const IndexRect& rhs) { |
| 118 return !(lhs == rhs); | 121 return !(lhs == rhs); |
| 119 } | 122 } |
| 120 | 123 |
| 121 } // namespace cc | 124 } // namespace cc |
| 122 | 125 |
| 123 #endif // CC_BASE_INDEX_RECT_H_ | 126 #endif // CC_BASE_INDEX_RECT_H_ |
| OLD | NEW |