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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 !matrix_.getDouble(2, 0) && | 241 !matrix_.getDouble(2, 0) && |
242 !matrix_.getDouble(2, 1); | 242 !matrix_.getDouble(2, 1); |
243 | 243 |
244 bool has_no_scale = matrix_.getDouble(0, 0) == 1 && | 244 bool has_no_scale = matrix_.getDouble(0, 0) == 1 && |
245 matrix_.getDouble(1, 1) == 1 && | 245 matrix_.getDouble(1, 1) == 1 && |
246 matrix_.getDouble(2, 2) == 1; | 246 matrix_.getDouble(2, 2) == 1; |
247 | 247 |
248 return has_no_perspective && has_no_rotation_or_skew && has_no_scale; | 248 return has_no_perspective && has_no_rotation_or_skew && has_no_scale; |
249 } | 249 } |
250 | 250 |
| 251 bool Transform::IsIdentityOrIntegerTranslation() const { |
| 252 if (!IsIdentityOrTranslation()) |
| 253 return false; |
| 254 |
| 255 bool no_fractional_translation = |
| 256 static_cast<int>(matrix_.getDouble(0, 3)) == matrix_.getDouble(0, 3) && |
| 257 static_cast<int>(matrix_.getDouble(1, 3)) == matrix_.getDouble(1, 3) && |
| 258 static_cast<int>(matrix_.getDouble(2, 3)) == matrix_.getDouble(2, 3); |
| 259 |
| 260 return no_fractional_translation; |
| 261 } |
| 262 |
251 bool Transform::IsScaleOrTranslation() const { | 263 bool Transform::IsScaleOrTranslation() const { |
252 if (matrix_.isIdentity()) | 264 if (matrix_.isIdentity()) |
253 return true; | 265 return true; |
254 | 266 |
255 bool has_no_perspective = !matrix_.getDouble(3, 0) && | 267 bool has_no_perspective = !matrix_.getDouble(3, 0) && |
256 !matrix_.getDouble(3, 1) && | 268 !matrix_.getDouble(3, 1) && |
257 !matrix_.getDouble(3, 2) && | 269 !matrix_.getDouble(3, 2) && |
258 (matrix_.getDouble(3, 3) == 1); | 270 (matrix_.getDouble(3, 3) == 1); |
259 | 271 |
260 bool has_no_rotation_or_skew = !matrix_.getDouble(0, 1) && | 272 bool has_no_rotation_or_skew = !matrix_.getDouble(0, 1) && |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 SkDoubleToMScalar(0), | 492 SkDoubleToMScalar(0), |
481 SkDoubleToMScalar(1) | 493 SkDoubleToMScalar(1) |
482 }; | 494 }; |
483 | 495 |
484 xform.mapMScalars(p); | 496 xform.mapMScalars(p); |
485 | 497 |
486 point.SetPoint(ToRoundedInt(p[0]), ToRoundedInt(p[1])); | 498 point.SetPoint(ToRoundedInt(p[0]), ToRoundedInt(p[1])); |
487 } | 499 } |
488 | 500 |
489 } // namespace gfx | 501 } // namespace gfx |
OLD | NEW |