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