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

Unified Diff: ui/gfx/box_f.cc

Issue 25518002: Add BoxF::ExpandTo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | « ui/gfx/box_f.h ('k') | ui/gfx/box_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/box_f.cc
diff --git a/ui/gfx/box_f.cc b/ui/gfx/box_f.cc
index efb579671457c9d78d3dbac1630207559ebd3d2a..6b6f2fd8fb906cd9d2f6233c82691094c64430e1 100644
--- a/ui/gfx/box_f.cc
+++ b/ui/gfx/box_f.cc
@@ -45,6 +45,29 @@ void BoxF::Union(const BoxF& box) {
depth_ = max_z - min_z;
}
+void BoxF::ExpandTo(const Point3F& point) {
+ Point3F max(
+ origin_.x() + width_, origin_.y() + height_, origin_.z() + depth_);
+
+ if (point.x() < origin_.x())
+ origin_.set_x(point.x());
+ if (point.y() < origin_.y())
+ origin_.set_y(point.y());
+ if (point.z() < origin_.z())
+ origin_.set_z(point.z());
+
+ if (point.x() > max.x())
+ max.set_x(point.x());
+ if (point.y() > max.y())
+ max.set_y(point.y());
+ if (point.z() > max.z())
+ max.set_z(point.z());
+
+ width_ = max.x() - origin_.x();
+ height_ = max.y() - origin_.y();
+ depth_ = max.z() - origin_.z();
ajuma 2013/10/01 13:21:02 How about putting the logic that ExpandTo and Unio
+}
+
BoxF UnionBoxes(const BoxF& a, const BoxF& b) {
BoxF result = a;
result.Union(b);
« no previous file with comments | « ui/gfx/box_f.h ('k') | ui/gfx/box_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698