OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef InterpolatedSVGPathSource_h |
| 6 #define InterpolatedSVGPathSource_h |
| 7 |
| 8 #include "core/animation/SVGPathSegInterpolationFunctions.h" |
| 9 #include "core/svg/SVGPathSource.h" |
| 10 #include "wtf/Vector.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class InterpolatedSVGPathSource : public SVGPathSource { |
| 15 public: |
| 16 InterpolatedSVGPathSource(const InterpolableList& listValue, const Vector<SV
GPathSegType>& pathSegTypes) |
| 17 : m_currentIndex(0) |
| 18 , m_interpolablePathSegs(listValue) |
| 19 , m_pathSegTypes(pathSegTypes) |
| 20 { |
| 21 ASSERT(m_interpolablePathSegs.length() == m_pathSegTypes.size()); |
| 22 } |
| 23 |
| 24 private: |
| 25 bool hasMoreData() const override; |
| 26 SVGPathSegType peekSegmentType() override; |
| 27 PathSegmentData parseSegment() override; |
| 28 |
| 29 PathCoordinates m_currentCoordinates; |
| 30 size_t m_currentIndex; |
| 31 const InterpolableList& m_interpolablePathSegs; |
| 32 const Vector<SVGPathSegType>& m_pathSegTypes; |
| 33 }; |
| 34 |
| 35 bool InterpolatedSVGPathSource::hasMoreData() const |
| 36 { |
| 37 return m_currentIndex < m_interpolablePathSegs.length(); |
| 38 } |
| 39 |
| 40 SVGPathSegType InterpolatedSVGPathSource::peekSegmentType() |
| 41 { |
| 42 ASSERT(hasMoreData()); |
| 43 return m_pathSegTypes.at(m_currentIndex); |
| 44 } |
| 45 |
| 46 PathSegmentData InterpolatedSVGPathSource::parseSegment() |
| 47 { |
| 48 PathSegmentData segment = SVGPathSegInterpolationFunctions::consumeInterpola
blePathSeg(*m_interpolablePathSegs.get(m_currentIndex), m_pathSegTypes.at(m_curr
entIndex), m_currentCoordinates); |
| 49 m_currentIndex++; |
| 50 return segment; |
| 51 } |
| 52 |
| 53 } // namespace blink |
| 54 |
| 55 #endif // InterpolatedSVGPathSource_h |
OLD | NEW |