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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include "ui/gfx/transform.h" | 8 #include "ui/gfx/transform.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 !matrix_.getDouble(2, 0) && | 234 !matrix_.getDouble(2, 0) && |
235 !matrix_.getDouble(2, 1); | 235 !matrix_.getDouble(2, 1); |
236 | 236 |
237 bool has_no_scale = matrix_.getDouble(0, 0) == 1 && | 237 bool has_no_scale = matrix_.getDouble(0, 0) == 1 && |
238 matrix_.getDouble(1, 1) == 1 && | 238 matrix_.getDouble(1, 1) == 1 && |
239 matrix_.getDouble(2, 2) == 1; | 239 matrix_.getDouble(2, 2) == 1; |
240 | 240 |
241 return has_no_perspective && has_no_rotation_or_skew && has_no_scale; | 241 return has_no_perspective && has_no_rotation_or_skew && has_no_scale; |
242 } | 242 } |
243 | 243 |
| 244 bool Transform::IsIdentityOrIntegerTranslation() const { |
| 245 if (!IsIdentityOrTranslation()) |
| 246 return false; |
| 247 |
| 248 bool no_fractional_translation = |
| 249 static_cast<int>(matrix_.getDouble(0, 3)) == matrix_.getDouble(0, 3) && |
| 250 static_cast<int>(matrix_.getDouble(1, 3)) == matrix_.getDouble(1, 3) && |
| 251 static_cast<int>(matrix_.getDouble(2, 3)) == matrix_.getDouble(2, 3); |
| 252 |
| 253 return no_fractional_translation; |
| 254 } |
| 255 |
244 bool Transform::IsScaleOrTranslation() const { | 256 bool Transform::IsScaleOrTranslation() const { |
245 bool has_no_perspective = !matrix_.getDouble(3, 0) && | 257 bool has_no_perspective = !matrix_.getDouble(3, 0) && |
246 !matrix_.getDouble(3, 1) && | 258 !matrix_.getDouble(3, 1) && |
247 !matrix_.getDouble(3, 2) && | 259 !matrix_.getDouble(3, 2) && |
248 (matrix_.getDouble(3, 3) == 1); | 260 (matrix_.getDouble(3, 3) == 1); |
249 | 261 |
250 bool has_no_rotation_or_skew = !matrix_.getDouble(0, 1) && | 262 bool has_no_rotation_or_skew = !matrix_.getDouble(0, 1) && |
251 !matrix_.getDouble(0, 2) && | 263 !matrix_.getDouble(0, 2) && |
252 !matrix_.getDouble(1, 0) && | 264 !matrix_.getDouble(1, 0) && |
253 !matrix_.getDouble(1, 2) && | 265 !matrix_.getDouble(1, 2) && |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 SkDoubleToMScalar(0), | 462 SkDoubleToMScalar(0), |
451 SkDoubleToMScalar(1) | 463 SkDoubleToMScalar(1) |
452 }; | 464 }; |
453 | 465 |
454 xform.mapMScalars(p); | 466 xform.mapMScalars(p); |
455 | 467 |
456 point.SetPoint(ToRoundedInt(p[0]), ToRoundedInt(p[1])); | 468 point.SetPoint(ToRoundedInt(p[0]), ToRoundedInt(p[1])); |
457 } | 469 } |
458 | 470 |
459 } // namespace gfx | 471 } // namespace gfx |
OLD | NEW |