gpu: Tweak Android WebGL test expectations
[chromium-blink-merge.git] / ui / gfx / box_f.cc
blob107c5d691bff6dbedf1e2f5352c5d96bc0b0f275
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/box_f.h"
7 #include "base/strings/stringprintf.h"
9 namespace gfx {
11 std::string BoxF::ToString() const {
12 return base::StringPrintf("%s %fx%fx%f",
13 origin().ToString().c_str(),
14 width_,
15 height_,
16 depth_);
19 bool BoxF::IsEmpty() const {
20 return (width_ == 0 && height_ == 0) ||
21 (width_ == 0 && depth_ == 0) ||
22 (height_ == 0 && depth_ == 0);
25 void BoxF::Union(const BoxF& box) {
26 if (IsEmpty()) {
27 *this = box;
28 return;
30 if (box.IsEmpty())
31 return;
33 float min_x = std::min(x(), box.x());
34 float min_y = std::min(y(), box.y());
35 float min_z = std::min(z(), box.z());
36 float max_x = std::max(right(), box.right());
37 float max_y = std::max(bottom(), box.bottom());
38 float max_z = std::max(front(), box.front());
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 BoxF UnionBoxes(const BoxF& a, const BoxF& b) {
47 BoxF result = a;
48 result.Union(b);
49 return result;
52 } // namespace gfx