blob: cfdbd7aba760716ebe04b571d173fca430db71db [file] [log] [blame]
Florin Malitaa6e30f72018-03-23 13:41:58 -04001/*
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
16namespace skottie {
17
18template <typename T>
19struct ValueTraits {
20 static size_t Cardinality(const T&);
21
22 template <typename U>
23 static U As(const T&);
Florin Malitac353ee22018-04-30 21:49:41 -040024
25 static T Lerp(const T&, const T&, float);
Florin Malitaa6e30f72018-03-23 13:41:58 -040026};
27
28using ScalarValue = SkScalar;
29using VectorValue = std::vector<ScalarValue>;
Florin Malitac353ee22018-04-30 21:49:41 -040030
31struct 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
45struct 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 Malitaa6e30f72018-03-23 13:41:58 -040061
62} // namespace skottie
63
64#endif // SkottieValue_DEFINED