Florin Malita | a6e30f7 | 2018-03-23 13:41:58 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkottieValue_DEFINED |
| 9 | #define SkottieValue_DEFINED |
| 10 | |
| 11 | #include "SkPath.h" |
| 12 | #include "SkScalar.h" |
| 13 | |
| 14 | #include <vector> |
| 15 | |
| 16 | namespace skottie { |
| 17 | |
| 18 | template <typename T> |
| 19 | struct ValueTraits { |
| 20 | static size_t Cardinality(const T&); |
| 21 | |
| 22 | template <typename U> |
| 23 | static U As(const T&); |
Florin Malita | c353ee2 | 2018-04-30 21:49:41 -0400 | [diff] [blame] | 24 | |
| 25 | static T Lerp(const T&, const T&, float); |
Florin Malita | a6e30f7 | 2018-03-23 13:41:58 -0400 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | using ScalarValue = SkScalar; |
| 29 | using VectorValue = std::vector<ScalarValue>; |
Florin Malita | c353ee2 | 2018-04-30 21:49:41 -0400 | [diff] [blame] | 30 | |
| 31 | struct BezierVertex { |
| 32 | SkPoint fInPoint, // "in" control point, relative to the vertex |
| 33 | fOutPoint, // "out" control point, relative to the vertex |
| 34 | fVertex; |
| 35 | |
| 36 | bool operator==(const BezierVertex& other) const { |
| 37 | return fInPoint == other.fInPoint |
| 38 | && fOutPoint == other.fOutPoint |
| 39 | && fVertex == other.fVertex; |
| 40 | } |
| 41 | |
| 42 | bool operator!=(const BezierVertex& other) const { return !(*this == other); } |
| 43 | }; |
| 44 | |
| 45 | struct ShapeValue { |
| 46 | std::vector<BezierVertex> fVertices; |
| 47 | bool fClosed : 1, |
| 48 | fVolatile : 1; |
| 49 | |
| 50 | ShapeValue() : fClosed(false), fVolatile(false) {} |
| 51 | ShapeValue(const ShapeValue&) = default; |
| 52 | ShapeValue(ShapeValue&&) = default; |
| 53 | ShapeValue& operator=(const ShapeValue&) = default; |
| 54 | |
| 55 | bool operator==(const ShapeValue& other) const { |
| 56 | return fVertices == other.fVertices && fClosed == other.fClosed; |
| 57 | } |
| 58 | |
| 59 | bool operator!=(const ShapeValue& other) const { return !(*this == other); } |
| 60 | }; |
Florin Malita | a6e30f7 | 2018-03-23 13:41:58 -0400 | [diff] [blame] | 61 | |
| 62 | } // namespace skottie |
| 63 | |
| 64 | #endif // SkottieValue_DEFINED |