| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/quad_f.h" | 5 #include "ui/gfx/quad_f.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 RectF QuadF::BoundingBox() const { | 125 RectF QuadF::BoundingBox() const { |
| 126 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x())); | 126 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x())); |
| 127 float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x())); | 127 float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x())); |
| 128 float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y())); | 128 float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y())); |
| 129 float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y())); | 129 float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y())); |
| 130 return RectF(rl, rt, rr - rl, rb - rt); | 130 return RectF(rl, rt, rr - rl, rb - rt); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void QuadF::Scale(float x_scale, float y_scale) { | 133 void QuadF::Scale(float x_scale, float y_scale) { |
| 134 p1_ = p1_.Scale(x_scale, y_scale); | 134 p1_.Scale(x_scale, y_scale); |
| 135 p2_ = p2_.Scale(x_scale, y_scale); | 135 p2_.Scale(x_scale, y_scale); |
| 136 p3_ = p3_.Scale(x_scale, y_scale); | 136 p3_.Scale(x_scale, y_scale); |
| 137 p4_ = p4_.Scale(x_scale, y_scale); | 137 p4_.Scale(x_scale, y_scale); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void QuadF::operator+=(const Vector2dF& rhs) { | 140 void QuadF::operator+=(const Vector2dF& rhs) { |
| 141 p1_ += rhs; | 141 p1_ += rhs; |
| 142 p2_ += rhs; | 142 p2_ += rhs; |
| 143 p3_ += rhs; | 143 p3_ += rhs; |
| 144 p4_ += rhs; | 144 p4_ += rhs; |
| 145 } | 145 } |
| 146 | 146 |
| 147 void QuadF::operator-=(const Vector2dF& rhs) { | 147 void QuadF::operator-=(const Vector2dF& rhs) { |
| 148 p1_ -= rhs; | 148 p1_ -= rhs; |
| 149 p2_ -= rhs; | 149 p2_ -= rhs; |
| 150 p3_ -= rhs; | 150 p3_ -= rhs; |
| 151 p4_ -= rhs; | 151 p4_ -= rhs; |
| 152 } | 152 } |
| 153 | 153 |
| 154 QuadF operator+(const QuadF& lhs, const Vector2dF& rhs) { | 154 QuadF operator+(const QuadF& lhs, const Vector2dF& rhs) { |
| 155 QuadF result = lhs; | 155 QuadF result = lhs; |
| 156 result += rhs; | 156 result += rhs; |
| 157 return result; | 157 return result; |
| 158 } | 158 } |
| 159 | 159 |
| 160 QuadF operator-(const QuadF& lhs, const Vector2dF& rhs) { | 160 QuadF operator-(const QuadF& lhs, const Vector2dF& rhs) { |
| 161 QuadF result = lhs; | 161 QuadF result = lhs; |
| 162 result -= rhs; | 162 result -= rhs; |
| 163 return result; | 163 return result; |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace gfx | 166 } // namespace gfx |
| OLD | NEW |