File indexing completed on 2024-04-28 15:24:42

0001 /*
0002     Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
0003                   2004, 2005 Rob Buis <buis@kde.org>
0004 
0005     This file is part of the KDE project
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #ifndef SVGTransform_h
0024 #define SVGTransform_h
0025 #if ENABLE(SVG)
0026 
0027 #include "AffineTransform.h"
0028 #include "FloatPoint.h"
0029 #include <wtf/RefCounted.h>
0030 #include <wtf/RefPtr.h>
0031 
0032 namespace WebCore
0033 {
0034 
0035 class FloatSize;
0036 
0037 class SVGTransform
0038 {
0039 public:
0040     enum SVGTransformType {
0041         SVG_TRANSFORM_UNKNOWN           = 0,
0042         SVG_TRANSFORM_MATRIX            = 1,
0043         SVG_TRANSFORM_TRANSLATE         = 2,
0044         SVG_TRANSFORM_SCALE             = 3,
0045         SVG_TRANSFORM_ROTATE            = 4,
0046         SVG_TRANSFORM_SKEWX             = 5,
0047         SVG_TRANSFORM_SKEWY             = 6
0048     };
0049 
0050     SVGTransform();
0051     SVGTransform(SVGTransformType);
0052     explicit SVGTransform(const AffineTransform &);
0053     virtual ~SVGTransform();
0054 
0055     SVGTransformType type() const;
0056 
0057     AffineTransform matrix() const;
0058 
0059     float angle() const;
0060     FloatPoint rotationCenter() const;
0061 
0062     void setMatrix(const AffineTransform &);
0063     void setTranslate(float tx, float ty);
0064     void setScale(float sx, float sy);
0065     void setRotate(float angle, float cx, float cy);
0066     void setSkewX(float angle);
0067     void setSkewY(float angle);
0068 
0069     // Internal use only (animation system)
0070     FloatPoint translate() const;
0071     FloatSize scale() const;
0072 
0073     bool isValid();
0074 
0075 private:
0076     SVGTransformType m_type;
0077     float m_angle;
0078     FloatPoint m_center;
0079     AffineTransform m_matrix;
0080 };
0081 
0082 inline bool operator==(const SVGTransform &a, const SVGTransform &b)
0083 {
0084     return a.type() == b.type() && a.angle() == b.angle() && a.matrix() == b.matrix();
0085 }
0086 
0087 inline bool operator!=(const SVGTransform &a, const SVGTransform &b)
0088 {
0089     return !(a == b);
0090 }
0091 
0092 } // namespace WebCore
0093 
0094 #endif // ENABLE(SVG)
0095 #endif
0096