OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/animation/animatable/AnimatablePath.h" | 5 #include "core/animation/animatable/AnimatablePath.h" |
6 | 6 |
7 #include "core/style/DataEquivalency.h" | 7 #include "core/style/DataEquivalency.h" |
8 #include "core/svg/SVGPathBlender.h" | 8 #include "core/svg/SVGPathBlender.h" |
9 #include "core/svg/SVGPathByteStreamBuilder.h" | 9 #include "core/svg/SVGPathByteStreamBuilder.h" |
10 #include "core/svg/SVGPathByteStreamSource.h" | 10 #include "core/svg/SVGPathByteStreamSource.h" |
11 #include <memory> | |
12 | 11 |
13 namespace blink { | 12 namespace blink { |
14 | 13 |
15 bool AnimatablePath::usesDefaultInterpolationWith(const AnimatableValue* value)
const | 14 bool AnimatablePath::usesDefaultInterpolationWith(const AnimatableValue* value)
const |
16 { | 15 { |
17 // Default interpolation is used if the paths have different lengths, | 16 // Default interpolation is used if the paths have different lengths, |
18 // or the paths have a segment with different types (ignoring "relativeness"
). | 17 // or the paths have a segment with different types (ignoring "relativeness"
). |
19 | 18 |
20 const StylePath* toPath = toAnimatablePath(value)->path(); | 19 const StylePath* toPath = toAnimatablePath(value)->path(); |
21 if (!m_path || !toPath) | 20 if (!m_path || !toPath) |
(...skipping 15 matching lines...) Expand all Loading... |
37 } | 36 } |
38 | 37 |
39 return toSource.hasMoreData(); | 38 return toSource.hasMoreData(); |
40 } | 39 } |
41 | 40 |
42 PassRefPtr<AnimatableValue> AnimatablePath::interpolateTo(const AnimatableValue*
value, double fraction) const | 41 PassRefPtr<AnimatableValue> AnimatablePath::interpolateTo(const AnimatableValue*
value, double fraction) const |
43 { | 42 { |
44 if (usesDefaultInterpolationWith(value)) | 43 if (usesDefaultInterpolationWith(value)) |
45 return defaultInterpolateTo(this, value, fraction); | 44 return defaultInterpolateTo(this, value, fraction); |
46 | 45 |
47 std::unique_ptr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); | 46 OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); |
48 SVGPathByteStreamBuilder builder(*byteStream); | 47 SVGPathByteStreamBuilder builder(*byteStream); |
49 | 48 |
50 SVGPathByteStreamSource fromSource(path()->byteStream()); | 49 SVGPathByteStreamSource fromSource(path()->byteStream()); |
51 SVGPathByteStreamSource toSource(toAnimatablePath(value)->path()->byteStream
()); | 50 SVGPathByteStreamSource toSource(toAnimatablePath(value)->path()->byteStream
()); |
52 | 51 |
53 SVGPathBlender blender(&fromSource, &toSource, &builder); | 52 SVGPathBlender blender(&fromSource, &toSource, &builder); |
54 bool ok = blender.blendAnimatedPath(fraction); | 53 bool ok = blender.blendAnimatedPath(fraction); |
55 ASSERT_UNUSED(ok, ok); | 54 ASSERT_UNUSED(ok, ok); |
56 return AnimatablePath::create(StylePath::create(std::move(byteStream))); | 55 return AnimatablePath::create(StylePath::create(std::move(byteStream))); |
57 } | 56 } |
58 | 57 |
59 bool AnimatablePath::equalTo(const AnimatableValue* value) const | 58 bool AnimatablePath::equalTo(const AnimatableValue* value) const |
60 { | 59 { |
61 return dataEquivalent(m_path.get(), toAnimatablePath(value)->path()); | 60 return dataEquivalent(m_path.get(), toAnimatablePath(value)->path()); |
62 } | 61 } |
63 | 62 |
64 } // namespace blink | 63 } // namespace blink |
OLD | NEW |