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 #ifndef UI_GFX_TRANSFORM_H_ | 5 #ifndef UI_GFX_TRANSFORM_H_ |
6 #define UI_GFX_TRANSFORM_H_ | 6 #define UI_GFX_TRANSFORM_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "third_party/skia/include/utils/SkMatrix44.h" | 12 #include "third_party/skia/include/core/SkMatrix44.h" |
13 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
14 #include "ui/gfx/vector2d_f.h" | 14 #include "ui/gfx/vector2d_f.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 | 17 |
18 class BoxF; | 18 class BoxF; |
19 class RectF; | 19 class RectF; |
20 class Point; | 20 class Point; |
21 class Point3F; | 21 class Point3F; |
22 class Vector3dF; | 22 class Vector3dF; |
23 | 23 |
24 // 4x4 transformation matrix. Transform is cheap and explicitly allows | 24 // 4x4 transformation matrix. Transform is cheap and explicitly allows |
25 // copy/assign. | 25 // copy/assign. |
26 class GFX_EXPORT Transform { | 26 class GFX_EXPORT Transform { |
27 public: | 27 public: |
28 | 28 enum SkipInitialization { kSkipInitialization }; |
29 enum SkipInitialization { | |
30 kSkipInitialization | |
31 }; | |
32 | 29 |
33 Transform() : matrix_(SkMatrix44::kIdentity_Constructor) {} | 30 Transform() : matrix_(SkMatrix44::kIdentity_Constructor) {} |
34 | 31 |
35 // Skips initializing this matrix to avoid overhead, when we know it will be | 32 // Skips initializing this matrix to avoid overhead, when we know it will be |
36 // initialized before use. | 33 // initialized before use. |
37 Transform(SkipInitialization) | 34 Transform(SkipInitialization) |
38 : matrix_(SkMatrix44::kUninitialized_Constructor) {} | 35 : matrix_(SkMatrix44::kUninitialized_Constructor) {} |
39 Transform(const Transform& rhs) : matrix_(rhs.matrix_) {} | 36 Transform(const Transform& rhs) : matrix_(rhs.matrix_) {} |
40 // Initialize with the concatenation of lhs * rhs. | 37 // Initialize with the concatenation of lhs * rhs. |
41 Transform(const Transform& lhs, const Transform& rhs) | 38 Transform(const Transform& lhs, const Transform& rhs) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 return *this; | 251 return *this; |
255 } | 252 } |
256 | 253 |
257 // Returns the underlying matrix. | 254 // Returns the underlying matrix. |
258 const SkMatrix44& matrix() const { return matrix_; } | 255 const SkMatrix44& matrix() const { return matrix_; } |
259 SkMatrix44& matrix() { return matrix_; } | 256 SkMatrix44& matrix() { return matrix_; } |
260 | 257 |
261 std::string ToString() const; | 258 std::string ToString() const; |
262 | 259 |
263 private: | 260 private: |
264 void TransformPointInternal(const SkMatrix44& xform, | 261 void TransformPointInternal(const SkMatrix44& xform, Point* point) const; |
265 Point* point) const; | |
266 | 262 |
267 void TransformPointInternal(const SkMatrix44& xform, | 263 void TransformPointInternal(const SkMatrix44& xform, Point3F* point) const; |
268 Point3F* point) const; | |
269 | 264 |
270 SkMatrix44 matrix_; | 265 SkMatrix44 matrix_; |
271 | 266 |
272 // copy/assign are allowed. | 267 // copy/assign are allowed. |
273 }; | 268 }; |
274 | 269 |
275 // This is declared here for use in gtest-based unit tests but is defined in | 270 // This is declared here for use in gtest-based unit tests but is defined in |
276 // the gfx_test_support target. Depend on that to use this in your unit test. | 271 // the gfx_test_support target. Depend on that to use this in your unit test. |
277 // This should not be used in production code - call ToString() instead. | 272 // This should not be used in production code - call ToString() instead. |
278 void PrintTo(const Transform& transform, ::std::ostream* os); | 273 void PrintTo(const Transform& transform, ::std::ostream* os); |
279 | 274 |
280 } // namespace gfx | 275 } // namespace gfx |
281 | 276 |
282 #endif // UI_GFX_TRANSFORM_H_ | 277 #endif // UI_GFX_TRANSFORM_H_ |
OLD | NEW |