Index: cc/base/index_rect.cc |
diff --git a/cc/base/index_rect.cc b/cc/base/index_rect.cc |
index 0c64c42a1b03efab8c0efc881e98216a4e578351..0d65af27349bfb0f417c6bbfc42b6ff4d27a4c76 100644 |
--- a/cc/base/index_rect.cc |
+++ b/cc/base/index_rect.cc |
@@ -6,6 +6,7 @@ |
#include <algorithm> |
+#include "base/numerics/saturated_arithmetic.h" |
#include "base/strings/stringprintf.h" |
namespace cc { |
@@ -22,6 +23,13 @@ bool IndexRect::Contains(int index_x, int index_y) const { |
index_y <= bottom_; |
} |
+void IndexRect::Inset(int left, int right, int top, int bottom) { |
+ left_ = base::SaturatedAddition(left_, left); |
+ right_ = base::SaturatedSubtraction(right_, right); |
+ top_ = base::SaturatedAddition(top_, top); |
+ bottom_ = base::SaturatedSubtraction(bottom_, bottom); |
+} |
+ |
std::string IndexRect::ToString() const { |
return base::StringPrintf("%d,%d,%d,%d", left(), right(), top(), bottom()); |
} |