OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 #ifndef RotateTransformOperation_h | 25 #ifndef RotateTransformOperation_h |
26 #define RotateTransformOperation_h | 26 #define RotateTransformOperation_h |
27 | 27 |
28 #include "platform/geometry/FloatPoint3D.h" | 28 #include "platform/geometry/FloatPoint3D.h" |
29 #include "platform/transforms/Rotation.h" | 29 #include "platform/transforms/Rotation.h" |
30 #include "platform/transforms/TransformOperation.h" | 30 #include "platform/transforms/TransformOperation.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 class PLATFORM_EXPORT RotateTransformOperation final | 34 class PLATFORM_EXPORT RotateTransformOperation : public TransformOperation { |
35 : public TransformOperation { | |
36 public: | 35 public: |
37 static PassRefPtr<RotateTransformOperation> create(double angle, | 36 static PassRefPtr<RotateTransformOperation> create(double angle, |
38 OperationType type) { | 37 OperationType type) { |
39 return create(Rotation(FloatPoint3D(0, 0, 1), angle), type); | 38 return create(Rotation(FloatPoint3D(0, 0, 1), angle), type); |
40 } | 39 } |
41 | 40 |
42 static PassRefPtr<RotateTransformOperation> create(double x, | 41 static PassRefPtr<RotateTransformOperation> create(double x, |
43 double y, | 42 double y, |
44 double z, | 43 double z, |
45 double angle, | 44 double angle, |
46 OperationType type) { | 45 OperationType type) { |
47 return create(Rotation(FloatPoint3D(x, y, z), angle), type); | 46 return create(Rotation(FloatPoint3D(x, y, z), angle), type); |
48 } | 47 } |
49 | 48 |
50 static PassRefPtr<RotateTransformOperation> create(const Rotation& rotation, | 49 static PassRefPtr<RotateTransformOperation> create(const Rotation& rotation, |
51 OperationType type) { | 50 OperationType type) { |
| 51 DCHECK(isMatchingOperationType(type)); |
52 return adoptRef(new RotateTransformOperation(rotation, type)); | 52 return adoptRef(new RotateTransformOperation(rotation, type)); |
53 } | 53 } |
54 | 54 |
55 double x() const { return m_rotation.axis.x(); } | 55 double x() const { return m_rotation.axis.x(); } |
56 double y() const { return m_rotation.axis.y(); } | 56 double y() const { return m_rotation.axis.y(); } |
57 double z() const { return m_rotation.axis.z(); } | 57 double z() const { return m_rotation.axis.z(); } |
58 double angle() const { return m_rotation.angle; } | 58 double angle() const { return m_rotation.angle; } |
59 const FloatPoint3D& axis() const { return m_rotation.axis; } | 59 const FloatPoint3D& axis() const { return m_rotation.axis; } |
60 | 60 |
61 static bool getCommonAxis(const RotateTransformOperation*, | 61 static bool getCommonAxis(const RotateTransformOperation*, |
62 const RotateTransformOperation*, | 62 const RotateTransformOperation*, |
63 FloatPoint3D& resultAxis, | 63 FloatPoint3D& resultAxis, |
64 double& resultAngleA, | 64 double& resultAngleA, |
65 double& resultAngleB); | 65 double& resultAngleB); |
66 | 66 |
67 virtual bool canBlendWith(const TransformOperation& other) const; | 67 virtual bool canBlendWith(const TransformOperation& other) const; |
68 OperationType type() const override { return m_type; } | 68 OperationType type() const override { return m_type; } |
69 | 69 |
70 void apply(TransformationMatrix& transform, | 70 void apply(TransformationMatrix& transform, |
71 const FloatSize& /*borderBoxSize*/) const override { | 71 const FloatSize& /*borderBoxSize*/) const override { |
72 transform.rotate3d(m_rotation); | 72 transform.rotate3d(m_rotation); |
73 } | 73 } |
74 | 74 |
75 static bool isMatchingOperationType(OperationType type) { | 75 static bool isMatchingOperationType(OperationType type) { |
76 return type == Rotate || type == RotateX || type == RotateY || | 76 return type == Rotate || type == RotateX || type == RotateY || |
77 type == RotateZ || type == Rotate3D; | 77 type == RotateZ || type == Rotate3D; |
78 } | 78 } |
79 | 79 |
80 private: | 80 protected: |
81 bool operator==(const TransformOperation&) const override; | 81 bool operator==(const TransformOperation&) const override; |
82 | 82 |
83 PassRefPtr<TransformOperation> blend(const TransformOperation* from, | 83 PassRefPtr<TransformOperation> blend(const TransformOperation* from, |
84 double progress, | 84 double progress, |
85 bool blendToIdentity = false) override; | 85 bool blendToIdentity = false) override; |
86 PassRefPtr<TransformOperation> zoom(double factor) final { return this; } | 86 PassRefPtr<TransformOperation> zoom(double factor) override { return this; } |
87 | 87 |
88 RotateTransformOperation(const Rotation& rotation, OperationType type) | 88 RotateTransformOperation(const Rotation& rotation, OperationType type) |
89 : m_rotation(rotation), m_type(type) { | 89 : m_rotation(rotation), m_type(type) { |
90 ASSERT(isMatchingOperationType(type)); | |
91 } | 90 } |
92 | 91 |
93 const Rotation m_rotation; | 92 const Rotation m_rotation; |
94 const OperationType m_type; | 93 const OperationType m_type; |
95 }; | 94 }; |
96 | 95 |
97 DEFINE_TRANSFORM_TYPE_CASTS(RotateTransformOperation); | 96 DEFINE_TRANSFORM_TYPE_CASTS(RotateTransformOperation); |
98 | 97 |
| 98 class PLATFORM_EXPORT RotateAroundOriginTransformOperation final |
| 99 : public RotateTransformOperation { |
| 100 public: |
| 101 static PassRefPtr<RotateAroundOriginTransformOperation> |
| 102 create(double angle, double originX, double originY) { |
| 103 return adoptRef( |
| 104 new RotateAroundOriginTransformOperation(angle, originX, originY)); |
| 105 } |
| 106 |
| 107 void apply(TransformationMatrix&, const FloatSize&) const override; |
| 108 |
| 109 static bool isMatchingOperationType(OperationType type) { |
| 110 return type == RotateAroundOrigin; |
| 111 } |
| 112 |
| 113 private: |
| 114 RotateAroundOriginTransformOperation(double angle, |
| 115 double originX, |
| 116 double originY); |
| 117 |
| 118 bool operator==(const TransformOperation&) const override; |
| 119 |
| 120 PassRefPtr<TransformOperation> blend(const TransformOperation* from, |
| 121 double progress, |
| 122 bool blendToIdentity = false) override; |
| 123 PassRefPtr<TransformOperation> zoom(double factor) override; |
| 124 |
| 125 double m_originX; |
| 126 double m_originY; |
| 127 }; |
| 128 |
| 129 DEFINE_TRANSFORM_TYPE_CASTS(RotateAroundOriginTransformOperation); |
| 130 |
99 } // namespace blink | 131 } // namespace blink |
100 | 132 |
101 #endif // RotateTransformOperation_h | 133 #endif // RotateTransformOperation_h |
OLD | NEW |