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

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

Issue 11359172: ui: Remove implicit flooring in skia rect conversion methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make root window transform in tests produce an integer result 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
« no previous file with comments | « ui/gfx/transform.h ('k') | ui/views/controls/table/table_view_views.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/point.h"
7 #include "ui/gfx/point3_f.h" 8 #include "ui/gfx/point3_f.h"
8 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect_f.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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 bool Transform::TransformPointReverse(Point3F& point) const { 145 bool Transform::TransformPointReverse(Point3F& point) const {
145 // TODO(sad): Try to avoid trying to invert the matrix. 146 // TODO(sad): Try to avoid trying to invert the matrix.
146 SkMatrix44 inverse; 147 SkMatrix44 inverse;
147 if (!matrix_.invert(&inverse)) 148 if (!matrix_.invert(&inverse))
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(RectF* rect) const {
155 SkRect src = RectToSkRect(*rect); 156 SkRect src = RectFToSkRect(*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 = SkRectToRectF(src);
159 } 160 }
160 161
161 bool Transform::TransformRectReverse(Rect* rect) const { 162 bool Transform::TransformRectReverse(RectF* 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 = RectFToSkRect(*rect);
167 matrix.mapRect(&src); 168 matrix.mapRect(&src);
168 *rect = SkRectToRect(src); 169 *rect = 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
« no previous file with comments | « ui/gfx/transform.h ('k') | ui/views/controls/table/table_view_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698