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/transform.h" | 5 #include "ui/gfx/transform.h" |
6 | 6 |
7 #include "ui/gfx/point3.h" | 7 #include "ui/gfx/point3.h" |
8 #include "ui/gfx/rect.h" | 8 #include "ui/gfx/rect.h" |
9 #include "ui/gfx/skia_util.h" | 9 #include "ui/gfx/skia_util.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 static int SymmetricRound(float x) { | 13 static int SymmetricRound(float x) { |
14 return static_cast<int>( | 14 return static_cast<int>( |
15 x > 0 | 15 x > 0 |
16 ? std::floor(x + 0.5f) | 16 ? std::floor(x + 0.5f) |
17 : std::ceil(x - 0.5f)); | 17 : std::ceil(x - 0.5f)); |
18 } | 18 } |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 namespace ui { | 22 namespace gfx { |
23 | 23 |
24 Transform::Transform() { | 24 Transform::Transform() { |
25 matrix_.reset(); | 25 matrix_.reset(); |
26 } | 26 } |
27 | 27 |
28 Transform::~Transform() {} | 28 Transform::~Transform() {} |
29 | 29 |
30 bool Transform::operator==(const Transform& rhs) const { | 30 bool Transform::operator==(const Transform& rhs) const { |
31 return matrix_ == rhs.matrix_; | 31 return matrix_ == rhs.matrix_; |
32 } | 32 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 SkIntToScalar(point.y()), | 197 SkIntToScalar(point.y()), |
198 0, | 198 0, |
199 1 }; | 199 1 }; |
200 | 200 |
201 xform.map(p); | 201 xform.map(p); |
202 | 202 |
203 point.SetPoint(SymmetricRound(p[0]), | 203 point.SetPoint(SymmetricRound(p[0]), |
204 SymmetricRound(p[1])); | 204 SymmetricRound(p[1])); |
205 } | 205 } |
206 | 206 |
207 } // namespace ui | 207 } // namespace gfx |
OLD | NEW |