1/*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB.  If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef SVGPathBlender_h
21#define SVGPathBlender_h
22
23#include "SVGPathConsumer.h"
24
25namespace WebCore {
26
27enum FloatBlendMode {
28    BlendHorizontal,
29    BlendVertical
30};
31
32class SVGPathSource;
33
34class SVGPathBlender {
35    WTF_MAKE_NONCOPYABLE(SVGPathBlender); WTF_MAKE_FAST_ALLOCATED;
36public:
37    SVGPathBlender();
38
39    bool addAnimatedPath(SVGPathSource*, SVGPathSource*, SVGPathConsumer*, unsigned repeatCount);
40    bool blendAnimatedPath(float, SVGPathSource*, SVGPathSource*, SVGPathConsumer*);
41    void cleanup();
42
43private:
44    bool blendMoveToSegment();
45    bool blendLineToSegment();
46    bool blendLineToHorizontalSegment();
47    bool blendLineToVerticalSegment();
48    bool blendCurveToCubicSegment();
49    bool blendCurveToCubicSmoothSegment();
50    bool blendCurveToQuadraticSegment();
51    bool blendCurveToQuadraticSmoothSegment();
52    bool blendArcToSegment();
53
54    float blendAnimatedDimensonalFloat(float, float, FloatBlendMode);
55    FloatPoint blendAnimatedFloatPoint(const FloatPoint& from, const FloatPoint& to);
56
57    SVGPathSource* m_fromSource;
58    SVGPathSource* m_toSource;
59    SVGPathConsumer* m_consumer;
60
61    FloatPoint m_fromCurrentPoint;
62    FloatPoint m_toCurrentPoint;
63
64    PathCoordinateMode m_fromMode;
65    PathCoordinateMode m_toMode;
66    float m_progress;
67    unsigned m_addTypesCount;
68    bool m_isInFirstHalfOfAnimation;
69};
70
71} // namespace WebCore
72
73#endif // SVGPathBlender_h
74