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

Unified Diff: cc/base/index_rect.cc

Issue 2350563002: cc: Implement IndexRect for encapsulating tile indices. (Closed)
Patch Set: review comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/base/index_rect.h ('k') | cc/base/index_rect_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/index_rect.cc
diff --git a/cc/base/index_rect.cc b/cc/base/index_rect.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0c64c42a1b03efab8c0efc881e98216a4e578351
--- /dev/null
+++ b/cc/base/index_rect.cc
@@ -0,0 +1,29 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/base/index_rect.h"
+
+#include <algorithm>
+
+#include "base/strings/stringprintf.h"
+
+namespace cc {
+
+void IndexRect::ClampTo(const IndexRect& other) {
+ left_ = std::max(left_, other.left());
+ top_ = std::max(top_, other.top());
+ right_ = std::min(right_, other.right());
+ bottom_ = std::min(bottom_, other.bottom());
+}
+
+bool IndexRect::Contains(int index_x, int index_y) const {
+ return index_x >= left_ && index_x <= right_ && index_y >= top_ &&
+ index_y <= bottom_;
+}
+
+std::string IndexRect::ToString() const {
+ return base::StringPrintf("%d,%d,%d,%d", left(), right(), top(), bottom());
+}
+
+} // namespace cc
« no previous file with comments | « cc/base/index_rect.h ('k') | cc/base/index_rect_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698