Removed unused icon resources from app_list.
[chromium-blink-merge.git] / ui / gfx / geometry / box_f.cc
blob674bb509c882d115e3b9cb233602c6b95bde3f00
1 // Copyright 2013 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.
5 #include "ui/gfx/geometry/box_f.h"
7 #include <algorithm>
9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h"
12 namespace gfx {
14 std::string BoxF::ToString() const {
15 return base::StringPrintf("%s %fx%fx%f",
16 origin().ToString().c_str(),
17 width_,
18 height_,
19 depth_);
22 bool BoxF::IsEmpty() const {
23 return (width_ == 0 && height_ == 0) ||
24 (width_ == 0 && depth_ == 0) ||
25 (height_ == 0 && depth_ == 0);
28 void BoxF::ExpandTo(const Point3F& min, const Point3F& max) {
29 DCHECK_LE(min.x(), max.x());
30 DCHECK_LE(min.y(), max.y());
31 DCHECK_LE(min.z(), max.z());
33 float min_x = std::min(x(), min.x());
34 float min_y = std::min(y(), min.y());
35 float min_z = std::min(z(), min.z());
36 float max_x = std::max(right(), max.x());
37 float max_y = std::max(bottom(), max.y());
38 float max_z = std::max(front(), max.z());
40 origin_.SetPoint(min_x, min_y, min_z);
41 width_ = max_x - min_x;
42 height_ = max_y - min_y;
43 depth_ = max_z - min_z;
46 void BoxF::Union(const BoxF& box) {
47 if (IsEmpty()) {
48 *this = box;
49 return;
51 if (box.IsEmpty())
52 return;
53 ExpandTo(box);
56 void BoxF::ExpandTo(const Point3F& point) {
57 ExpandTo(point, point);
60 void BoxF::ExpandTo(const BoxF& box) {
61 ExpandTo(box.origin(), gfx::Point3F(box.right(), box.bottom(), box.front()));
64 BoxF UnionBoxes(const BoxF& a, const BoxF& b) {
65 BoxF result = a;
66 result.Union(b);
67 return result;
70 } // namespace gfx