| Flutter Impeller |

geometry.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
9 #include "flutter/fml/macros.h"
10 #include "impeller/core/allocator.h"
11 #include "impeller/core/device_buffer.h"
12 #include "impeller/core/host_buffer.h"
13 #include "impeller/core/vertex_buffer.h"
14 #include "impeller/geometry/matrix.h"
15 #include "impeller/geometry/vector.h"
16 #include "impeller/renderer/command.h"
17 #include "impeller/scene/importer/scene_flatbuffers.h"
18 #include "impeller/scene/pipeline_key.h"
19 #include "impeller/scene/scene_context.h"
20
21 namespace impeller {
22 namespace scene {
23
24 class CuboidGeometry;
25 class UnskinnedVertexBufferGeometry;
26
27 class Geometry {
28 public:
29 virtual ~Geometry();
30
31 static std::shared_ptr<CuboidGeometry> MakeCuboid(Vector3 size);
32
33 static std::shared_ptr<Geometry> MakeVertexBuffer(VertexBuffer vertex_buffer,
34 bool is_skinned);
35
36 static std::shared_ptr<Geometry> MakeFromFlatbuffer(
37 const fb::MeshPrimitive& mesh,
38 Allocator& allocator);
39
40 virtual GeometryType GetGeometryType() const = 0;
41
42 virtual VertexBuffer GetVertexBuffer(Allocator& allocator) const = 0;
43
44 virtual void BindToCommand(const SceneContext& scene_context,
45 HostBuffer& buffer,
46 const Matrix& transform,
47 Command& command) const = 0;
48
49 virtual void SetJointsTexture(const std::shared_ptr<Texture>& texture);
50 };
51
52 class CuboidGeometry final : public Geometry {
53 public:
54 CuboidGeometry();
55
56 ~CuboidGeometry() override;
57
58 void SetSize(Vector3 size);
59
60 // |Geometry|
61 GeometryType GetGeometryType() const override;
62
63 // |Geometry|
64 VertexBuffer GetVertexBuffer(Allocator& allocator) const override;
65
66 // |Geometry|
67 void BindToCommand(const SceneContext& scene_context,
68 HostBuffer& buffer,
69 const Matrix& transform,
70 Command& command) const override;
71
72 private:
73 Vector3 size_;
74
75 FML_DISALLOW_COPY_AND_ASSIGN(CuboidGeometry);
76 };
77
78 class UnskinnedVertexBufferGeometry final : public Geometry {
79 public:
80 UnskinnedVertexBufferGeometry();
81
82 ~UnskinnedVertexBufferGeometry() override;
83
84 void SetVertexBuffer(VertexBuffer vertex_buffer);
85
86 // |Geometry|
87 GeometryType GetGeometryType() const override;
88
89 // |Geometry|
90 VertexBuffer GetVertexBuffer(Allocator& allocator) const override;
91
92 // |Geometry|
93 void BindToCommand(const SceneContext& scene_context,
94 HostBuffer& buffer,
95 const Matrix& transform,
96 Command& command) const override;
97
98 private:
99 VertexBuffer vertex_buffer_;
100
101 FML_DISALLOW_COPY_AND_ASSIGN(UnskinnedVertexBufferGeometry);
102 };
103
104 class SkinnedVertexBufferGeometry final : public Geometry {
105 public:
106 SkinnedVertexBufferGeometry();
107
108 ~SkinnedVertexBufferGeometry() override;
109
110 void SetVertexBuffer(VertexBuffer vertex_buffer);
111
112 // |Geometry|
113 GeometryType GetGeometryType() const override;
114
115 // |Geometry|
116 VertexBuffer GetVertexBuffer(Allocator& allocator) const override;
117
118 // |Geometry|
119 void BindToCommand(const SceneContext& scene_context,
120 HostBuffer& buffer,
121 const Matrix& transform,
122 Command& command) const override;
123
124 // |Geometry|
125 void SetJointsTexture(const std::shared_ptr<Texture>& texture) override;
126
127 private:
128 VertexBuffer vertex_buffer_;
129 std::shared_ptr<Texture> joints_texture_;
130
131 FML_DISALLOW_COPY_AND_ASSIGN(SkinnedVertexBufferGeometry);
132 };
133
134 } // namespace scene
135 } // namespace impeller
impeller::scene::CuboidGeometry
Definition: geometry.h:52
impeller::scene::SkinnedVertexBufferGeometry::~SkinnedVertexBufferGeometry
~SkinnedVertexBufferGeometry() override
impeller::scene::Geometry::SetJointsTexture
virtual void SetJointsTexture(const std::shared_ptr< Texture > &texture)
Definition: geometry.cc:122
impeller::Command
An object used to specify work to the GPU along with references to resources the GPU will used when d...
Definition: command.h:99
pipeline_key.h
host_buffer.h
scene_context.h
impeller::scene::SkinnedVertexBufferGeometry
Definition: geometry.h:104
impeller::scene::Geometry::MakeCuboid
static std::shared_ptr< CuboidGeometry > MakeCuboid(Vector3 size)
Definition: geometry.cc:32
vertex_buffer.h
device_buffer.h
impeller::scene::CuboidGeometry::BindToCommand
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, Command &command) const override
Definition: geometry.cc:164
impeller::HostBuffer
Definition: host_buffer.h:20
impeller::VertexBuffer
Definition: vertex_buffer.h:12
impeller::scene::UnskinnedVertexBufferGeometry::UnskinnedVertexBufferGeometry
UnskinnedVertexBufferGeometry()
impeller::scene::SkinnedVertexBufferGeometry::SkinnedVertexBufferGeometry
SkinnedVertexBufferGeometry()
impeller::scene::UnskinnedVertexBufferGeometry::GetGeometryType
GeometryType GetGeometryType() const override
Definition: geometry.cc:190
impeller::scene::CuboidGeometry::~CuboidGeometry
~CuboidGeometry() override
impeller::scene::CuboidGeometry::GetGeometryType
GeometryType GetGeometryType() const override
Definition: geometry.cc:137
impeller::scene::UnskinnedVertexBufferGeometry::GetVertexBuffer
VertexBuffer GetVertexBuffer(Allocator &allocator) const override
Definition: geometry.cc:195
impeller::scene::SceneContext
Definition: scene_context.h:39
impeller::scene::Geometry::GetVertexBuffer
virtual VertexBuffer GetVertexBuffer(Allocator &allocator) const =0
matrix.h
command.h
impeller::scene::SkinnedVertexBufferGeometry::GetGeometryType
GeometryType GetGeometryType() const override
Definition: geometry.cc:227
impeller::scene::SkinnedVertexBufferGeometry::GetVertexBuffer
VertexBuffer GetVertexBuffer(Allocator &allocator) const override
Definition: geometry.cc:232
impeller::scene::SkinnedVertexBufferGeometry::BindToCommand
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, Command &command) const override
Definition: geometry.cc:238
impeller::scene::UnskinnedVertexBufferGeometry::BindToCommand
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, Command &command) const override
Definition: geometry.cc:201
impeller::scene::UnskinnedVertexBufferGeometry::SetVertexBuffer
void SetVertexBuffer(VertexBuffer vertex_buffer)
Definition: geometry.cc:184
impeller::scene::Geometry::~Geometry
virtual ~Geometry()
impeller::scene::UnskinnedVertexBufferGeometry
Definition: geometry.h:78
impeller::Allocator
An object that allocates device memory.
Definition: allocator.h:25
impeller::scene::Geometry::MakeFromFlatbuffer
static std::shared_ptr< Geometry > MakeFromFlatbuffer(const fb::MeshPrimitive &mesh, Allocator &allocator)
Definition: geometry.cc:51
impeller::scene::Geometry::MakeVertexBuffer
static std::shared_ptr< Geometry > MakeVertexBuffer(VertexBuffer vertex_buffer, bool is_skinned)
Definition: geometry.cc:38
impeller::scene::UnskinnedVertexBufferGeometry::~UnskinnedVertexBufferGeometry
~UnskinnedVertexBufferGeometry() override
impeller::scene::Geometry
Definition: geometry.h:27
allocator.h
impeller::scene::GeometryType
GeometryType
Definition: pipeline_key.h:12
impeller::scene::CuboidGeometry::CuboidGeometry
CuboidGeometry()
vector.h
impeller::scene::SkinnedVertexBufferGeometry::SetVertexBuffer
void SetVertexBuffer(VertexBuffer vertex_buffer)
Definition: geometry.cc:222
impeller::scene::Geometry::BindToCommand
virtual void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, Command &command) const =0
impeller::scene::CuboidGeometry::GetVertexBuffer
VertexBuffer GetVertexBuffer(Allocator &allocator) const override
Definition: geometry.cc:142
impeller::scene::SkinnedVertexBufferGeometry::SetJointsTexture
void SetJointsTexture(const std::shared_ptr< Texture > &texture) override
Definition: geometry.cc:268
impeller
Definition: aiks_context.cc:10
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:36
impeller::Vector3
Definition: vector.h:17
impeller::scene::CuboidGeometry::SetSize
void SetSize(Vector3 size)
Definition: geometry.cc:132
impeller::scene::Geometry::GetGeometryType
virtual GeometryType GetGeometryType() const =0