OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/base/index_rect.h" |
| 6 |
| 7 #include <algorithm> |
| 8 |
| 9 #include "base/strings/stringprintf.h" |
| 10 |
| 11 namespace cc { |
| 12 |
| 13 void IndexRect::ClampTo(const IndexRect& other) { |
| 14 left_ = std::max(left_, other.left()); |
| 15 top_ = std::max(top_, other.top()); |
| 16 right_ = std::min(right_, other.right()); |
| 17 bottom_ = std::min(bottom_, other.bottom()); |
| 18 } |
| 19 |
| 20 bool IndexRect::Contains(int index_x, int index_y) const { |
| 21 return index_x >= left_ && index_x <= right_ && index_y >= top_ && |
| 22 index_y <= bottom_; |
| 23 } |
| 24 |
| 25 std::string IndexRect::ToString() const { |
| 26 return base::StringPrintf("%d,%d,%d,%d", left(), right(), top(), bottom()); |
| 27 } |
| 28 |
| 29 } // namespace cc |
OLD | NEW |