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

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

Issue 11275089: SkRect to gfx::Rect type conversions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove unnecessary lines 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
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/transform.h" 5 #include "ui/gfx/transform.h"
6 6
7 #include "ui/gfx/point3_f.h" 7 #include "ui/gfx/point3_f.h"
8 #include "ui/gfx/rect.h" 8 #include "ui/gfx/rect.h"
9 #include "ui/gfx/rect_conversions.h"
9 #include "ui/gfx/safe_integer_conversions.h" 10 #include "ui/gfx/safe_integer_conversions.h"
10 #include "ui/gfx/skia_util.h" 11 #include "ui/gfx/skia_util.h"
11 12
12 namespace gfx { 13 namespace gfx {
13 14
14 Transform::Transform() { 15 Transform::Transform() {
15 matrix_.reset(); 16 matrix_.reset();
16 } 17 }
17 18
18 Transform::~Transform() {} 19 Transform::~Transform() {}
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return false; 149 return false;
149 150
150 TransformPointInternal(inverse, point); 151 TransformPointInternal(inverse, point);
151 return true; 152 return true;
152 } 153 }
153 154
154 void Transform::TransformRect(Rect* rect) const { 155 void Transform::TransformRect(Rect* rect) const {
155 SkRect src = RectToSkRect(*rect); 156 SkRect src = RectToSkRect(*rect);
156 const SkMatrix& matrix = matrix_; 157 const SkMatrix& matrix = matrix_;
157 matrix.mapRect(&src); 158 matrix.mapRect(&src);
158 *rect = SkRectToRect(src); 159 *rect = gfx::ToFlooredRectDeprecated(SkRectToRectF(src));
sky 2012/11/01 16:10:24 The plan was to remove ToFlooredRectDeprecated. If
danakj 2012/11/01 16:38:21 IMO it's more a matter of making existing code tha
danakj 2012/11/01 17:38:27 I guess these methods need to take a RectF then, a
159 } 160 }
160 161
161 bool Transform::TransformRectReverse(Rect* rect) const { 162 bool Transform::TransformRectReverse(Rect* rect) const {
162 SkMatrix44 inverse; 163 SkMatrix44 inverse;
163 if (!matrix_.invert(&inverse)) 164 if (!matrix_.invert(&inverse))
164 return false; 165 return false;
165 const SkMatrix& matrix = inverse; 166 const SkMatrix& matrix = inverse;
166 SkRect src = RectToSkRect(*rect); 167 SkRect src = RectToSkRect(*rect);
167 matrix.mapRect(&src); 168 matrix.mapRect(&src);
168 *rect = SkRectToRect(src); 169 *rect = gfx::ToFlooredRectDeprecated(SkRectToRectF(src));
169 return true; 170 return true;
170 } 171 }
171 172
172 void Transform::TransformPointInternal(const SkMatrix44& xform, 173 void Transform::TransformPointInternal(const SkMatrix44& xform,
173 Point3F& point) const { 174 Point3F& point) const {
174 SkScalar p[4] = { 175 SkScalar p[4] = {
175 SkFloatToScalar(point.x()), 176 SkFloatToScalar(point.x()),
176 SkFloatToScalar(point.y()), 177 SkFloatToScalar(point.y()),
177 SkFloatToScalar(point.z()), 178 SkFloatToScalar(point.z()),
178 1 }; 179 1 };
(...skipping 11 matching lines...) Expand all
190 Point& point) const { 191 Point& point) const {
191 SkScalar p[4] = { SkIntToScalar(point.x()), SkIntToScalar(point.y()), 192 SkScalar p[4] = { SkIntToScalar(point.x()), SkIntToScalar(point.y()),
192 0, 1 }; 193 0, 1 };
193 194
194 xform.map(p); 195 xform.map(p);
195 196
196 point.SetPoint(ToRoundedInt(p[0]), ToRoundedInt(p[1])); 197 point.SetPoint(ToRoundedInt(p[0]), ToRoundedInt(p[1]));
197 } 198 }
198 199
199 } // namespace gfx 200 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698