OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/base/math_util.h" | 5 #include "cc/base/math_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 DCHECK(transform.Preserves2dAxisAlignment()); | 195 DCHECK(transform.Preserves2dAxisAlignment()); |
196 | 196 |
197 if (transform.IsIdentityOrIntegerTranslation()) { | 197 if (transform.IsIdentityOrIntegerTranslation()) { |
198 gfx::Vector2d offset(static_cast<int>(transform.matrix().getFloat(0, 3)), | 198 gfx::Vector2d offset(static_cast<int>(transform.matrix().getFloat(0, 3)), |
199 static_cast<int>(transform.matrix().getFloat(1, 3))); | 199 static_cast<int>(transform.matrix().getFloat(1, 3))); |
200 return rect + offset; | 200 return rect + offset; |
201 } | 201 } |
202 if (transform.IsIdentityOrTranslation()) { | 202 if (transform.IsIdentityOrTranslation()) { |
203 gfx::Vector2dF offset(transform.matrix().getFloat(0, 3), | 203 gfx::Vector2dF offset(transform.matrix().getFloat(0, 3), |
204 transform.matrix().getFloat(1, 3)); | 204 transform.matrix().getFloat(1, 3)); |
205 return gfx::ToEnclosedRect(rect + offset); | 205 return gfx::ToEnclosedRect(gfx::RectF(rect) + offset); |
206 } | 206 } |
207 | 207 |
208 SkMScalar quad[2 * 2]; // input: 2 x 2D points | 208 SkMScalar quad[2 * 2]; // input: 2 x 2D points |
209 quad[0] = rect.x(); | 209 quad[0] = rect.x(); |
210 quad[1] = rect.y(); | 210 quad[1] = rect.y(); |
211 quad[2] = rect.right(); | 211 quad[2] = rect.right(); |
212 quad[3] = rect.bottom(); | 212 quad[3] = rect.bottom(); |
213 | 213 |
214 SkMScalar result[4 * 2]; // output: 2 x 4D homogeneous points | 214 SkMScalar result[4 * 2]; // output: 2 x 4D homogeneous points |
215 transform.matrix().map2(quad, 2, result); | 215 transform.matrix().map2(quad, 2, result); |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 transform.matrix().getFloat(2, 0)); | 875 transform.matrix().getFloat(2, 0)); |
876 } | 876 } |
877 | 877 |
878 gfx::Vector3dF MathUtil::GetYAxis(const gfx::Transform& transform) { | 878 gfx::Vector3dF MathUtil::GetYAxis(const gfx::Transform& transform) { |
879 return gfx::Vector3dF(transform.matrix().getFloat(0, 1), | 879 return gfx::Vector3dF(transform.matrix().getFloat(0, 1), |
880 transform.matrix().getFloat(1, 1), | 880 transform.matrix().getFloat(1, 1), |
881 transform.matrix().getFloat(2, 1)); | 881 transform.matrix().getFloat(2, 1)); |
882 } | 882 } |
883 | 883 |
884 } // namespace cc | 884 } // namespace cc |
OLD | NEW |