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

Side by Side Diff: ui/gfx/quad_f.cc

Issue 11369144: ui: Make gfx::Point::Scale() mutate the class, similar to gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for aura Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« cc/layer_impl.cc ('K') | « ui/gfx/point_unittest.cc ('k') | ui/gfx/quad_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698