1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef RotateTransformOperation_h
#define RotateTransformOperation_h
#include "platform/geometry/FloatPoint3D.h"
#include "platform/transforms/Rotation.h"
#include "platform/transforms/TransformOperation.h"
namespace blink {
class PLATFORM_EXPORT RotateTransformOperation : public TransformOperation {
public:
static PassRefPtr<RotateTransformOperation> create(double angle,
OperationType type) {
return create(Rotation(FloatPoint3D(0, 0, 1), angle), type);
}
static PassRefPtr<RotateTransformOperation> create(double x,
double y,
double z,
double angle,
OperationType type) {
return create(Rotation(FloatPoint3D(x, y, z), angle), type);
}
static PassRefPtr<RotateTransformOperation> create(const Rotation& rotation,
OperationType type) {
DCHECK(isMatchingOperationType(type));
return adoptRef(new RotateTransformOperation(rotation, type));
}
double x() const { return m_rotation.axis.x(); }
double y() const { return m_rotation.axis.y(); }
double z() const { return m_rotation.axis.z(); }
double angle() const { return m_rotation.angle; }
const FloatPoint3D& axis() const { return m_rotation.axis; }
static bool getCommonAxis(const RotateTransformOperation*,
const RotateTransformOperation*,
FloatPoint3D& resultAxis,
double& resultAngleA,
double& resultAngleB);
virtual bool canBlendWith(const TransformOperation& other) const;
OperationType type() const override { return m_type; }
OperationType primitiveType() const final { return Rotate3D; }
void apply(TransformationMatrix& transform,
const FloatSize& /*borderBoxSize*/) const override {
transform.rotate3d(m_rotation);
}
static bool isMatchingOperationType(OperationType type) {
return type == Rotate || type == RotateX || type == RotateY ||
type == RotateZ || type == Rotate3D;
}
protected:
bool operator==(const TransformOperation&) const override;
PassRefPtr<TransformOperation> blend(const TransformOperation* from,
double progress,
bool blendToIdentity = false) override;
PassRefPtr<TransformOperation> zoom(double factor) override { return this; }
RotateTransformOperation(const Rotation& rotation, OperationType type)
: m_rotation(rotation), m_type(type) {
}
const Rotation m_rotation;
const OperationType m_type;
};
DEFINE_TRANSFORM_TYPE_CASTS(RotateTransformOperation);
class PLATFORM_EXPORT RotateAroundOriginTransformOperation final
: public RotateTransformOperation {
public:
static PassRefPtr<RotateAroundOriginTransformOperation>
create(double angle, double originX, double originY) {
return adoptRef(
new RotateAroundOriginTransformOperation(angle, originX, originY));
}
void apply(TransformationMatrix&, const FloatSize&) const override;
static bool isMatchingOperationType(OperationType type) {
return type == RotateAroundOrigin;
}
private:
RotateAroundOriginTransformOperation(double angle,
double originX,
double originY);
bool operator==(const TransformOperation&) const override;
PassRefPtr<TransformOperation> blend(const TransformOperation* from,
double progress,
bool blendToIdentity = false) override;
PassRefPtr<TransformOperation> zoom(double factor) override;
double m_originX;
double m_originY;
};
DEFINE_TRANSFORM_TYPE_CASTS(RotateAroundOriginTransformOperation);
} // namespace blink
#endif // RotateTransformOperation_h
|