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