| Flutter Impeller |

animation.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 FLUTTER_IMPELLER_SCENE_ANIMATION_ANIMATION_H_
6 #define FLUTTER_IMPELLER_SCENE_ANIMATION_ANIMATION_H_
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "flutter/fml/hash_combine.h"
13 #include "flutter/fml/macros.h"
14 #include "impeller/base/timing.h"
15 #include "impeller/geometry/quaternion.h"
16 #include "impeller/geometry/scalar.h"
17 #include "impeller/geometry/vector.h"
18 #include "impeller/scene/animation/property_resolver.h"
19 #include "impeller/scene/importer/scene_flatbuffers.h"
20
21 namespace impeller {
22 namespace scene {
23
24 class Node;
25
26 class Animation final {
27 public:
28 static std::shared_ptr<Animation> MakeFromFlatbuffer(
29 const fb::Animation& animation,
30 const std::vector<std::shared_ptr<Node>>& scene_nodes);
31
32 enum class Property {
33 kTranslation,
34 kRotation,
35 kScale,
36 };
37
38 struct BindKey {
39 std::string node_name;
40 Property property = Property::kTranslation;
41
42 struct Hash {
43 std::size_t operator()(const BindKey& o) const {
44 return fml::HashCombine(o.node_name, o.property);
45 }
46 };
47
48 struct Equal {
49 bool operator()(const BindKey& lhs, const BindKey& rhs) const {
50 return lhs.node_name == rhs.node_name && lhs.property == rhs.property;
51 }
52 };
53 };
54
55 struct Channel {
56 BindKey bind_target;
57 std::unique_ptr<PropertyResolver> resolver;
58 };
59 ~Animation();
60
61 const std::string& GetName() const;
62
63 const std::vector<Channel>& GetChannels() const;
64
65 SecondsF GetEndTime() const;
66
67 private:
68 Animation();
69
70 std::string name_;
71 std::vector<Channel> channels_;
72 SecondsF end_time_;
73
74 Animation(const Animation&) = delete;
75
76 Animation& operator=(const Animation&) = delete;
77 };
78
79 } // namespace scene
80 } // namespace impeller
81
82 #endif // FLUTTER_IMPELLER_SCENE_ANIMATION_ANIMATION_H_
timing.h
impeller::scene::Animation::Channel::bind_target
BindKey bind_target
Definition: animation.h:56
impeller::scene::Animation::Channel
Definition: animation.h:55
impeller::scene::Animation::GetChannels
const std::vector< Channel > & GetChannels() const
Definition: animation.cc:116
impeller::scene::Animation::BindKey::Hash
Definition: animation.h:42
quaternion.h
impeller::scene::Animation::BindKey
Definition: animation.h:38
impeller::scene::Animation::MakeFromFlatbuffer
static std::shared_ptr< Animation > MakeFromFlatbuffer(const fb::Animation &animation, const std::vector< std::shared_ptr< Node >> &scene_nodes)
Definition: animation.cc:19
property_resolver.h
impeller::scene::Animation::BindKey::Equal
Definition: animation.h:48
impeller::SecondsF
std::chrono::duration< float > SecondsF
Definition: timing.h:13
impeller::scene::Animation::Property::kTranslation
@ kTranslation
impeller::scene::Animation::BindKey::Hash::operator()
std::size_t operator()(const BindKey &o) const
Definition: animation.h:43
impeller::scene::Animation::GetName
const std::string & GetName() const
Definition: animation.cc:112
impeller::scene::Animation::Channel::resolver
std::unique_ptr< PropertyResolver > resolver
Definition: animation.h:57
impeller::scene::Animation::BindKey::Equal::operator()
bool operator()(const BindKey &lhs, const BindKey &rhs) const
Definition: animation.h:49
impeller::scene::Animation::Property::kScale
@ kScale
scalar.h
impeller::scene::Animation::Property
Property
Definition: animation.h:32
vector.h
impeller::scene::Animation::Property::kRotation
@ kRotation
impeller::scene::Animation::~Animation
~Animation()
impeller::scene::Animation::GetEndTime
SecondsF GetEndTime() const
Definition: animation.cc:120
impeller::scene::Animation::BindKey::node_name
std::string node_name
Definition: animation.h:39
impeller
Definition: aiks_context.cc:10
impeller::scene::Animation::BindKey::property
Property property
Definition: animation.h:40
impeller::scene::Animation
Definition: animation.h:26