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