| 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 #ifndef FLUTTER_IMPELLER_SCENE_GEOMETRY_H_
6 #define FLUTTER_IMPELLER_SCENE_GEOMETRY_H_
7
8 #include <memory>
9
10 #include "impeller/core/allocator.h"
11 #include "impeller/core/host_buffer.h"
12 #include "impeller/core/vertex_buffer.h"
13 #include "impeller/geometry/matrix.h"
14 #include "impeller/geometry/vector.h"
15 #include "impeller/renderer/render_pass.h"
16 #include "impeller/scene/importer/scene_flatbuffers.h"
17 #include "impeller/scene/pipeline_key.h"
18 #include "impeller/scene/scene_context.h"
19
20 namespace impeller {
21 namespace scene {
22
23 class CuboidGeometry;
24 class UnskinnedVertexBufferGeometry;
25
26 class Geometry {
27 public:
28 virtual ~Geometry();
29
30 static std::shared_ptr<CuboidGeometry> MakeCuboid(Vector3 size);
31
32 static std::shared_ptr<Geometry> MakeVertexBuffer(VertexBuffer vertex_buffer,
33 bool is_skinned);
34
35 static std::shared_ptr<Geometry> MakeFromFlatbuffer(
36 const fb::MeshPrimitive& mesh,
37 Allocator& allocator);
38
39 virtual GeometryType GetGeometryType() const = 0;
40
41 virtual VertexBuffer GetVertexBuffer(Allocator& allocator) const = 0;
42
43 virtual void BindToCommand(const SceneContext& scene_context,
44 HostBuffer& buffer,
45 const Matrix& transform,
46 RenderPass& pass) const = 0;
47
48 virtual void SetJointsTexture(const std::shared_ptr<Texture>& texture);
49 };
50
51 class CuboidGeometry final : public Geometry {
52 public:
53 CuboidGeometry();
54
55 ~CuboidGeometry() override;
56
57 void SetSize(Vector3 size);
58
59 // |Geometry|
60 GeometryType GetGeometryType() const override;
61
62 // |Geometry|
63 VertexBuffer GetVertexBuffer(Allocator& allocator) const override;
64
65 // |Geometry|
66 void BindToCommand(const SceneContext& scene_context,
67 HostBuffer& buffer,
68 const Matrix& transform,
69 RenderPass& pass) const override;
70
71 private:
72 Vector3 size_;
73
74 CuboidGeometry(const CuboidGeometry&) = delete;
75
76 CuboidGeometry& operator=(const CuboidGeometry&) = delete;
77 };
78
79 class UnskinnedVertexBufferGeometry final : public Geometry {
80 public:
81 UnskinnedVertexBufferGeometry();
82
83 ~UnskinnedVertexBufferGeometry() override;
84
85 void SetVertexBuffer(VertexBuffer vertex_buffer);
86
87 // |Geometry|
88 GeometryType GetGeometryType() const override;
89
90 // |Geometry|
91 VertexBuffer GetVertexBuffer(Allocator& allocator) const override;
92
93 // |Geometry|
94 void BindToCommand(const SceneContext& scene_context,
95 HostBuffer& buffer,
96 const Matrix& transform,
97 RenderPass& pass) const override;
98
99 private:
100 VertexBuffer vertex_buffer_;
101
102 UnskinnedVertexBufferGeometry(const UnskinnedVertexBufferGeometry&) = delete;
103
104 UnskinnedVertexBufferGeometry& operator=(
105 const UnskinnedVertexBufferGeometry&) = delete;
106 };
107
108 class SkinnedVertexBufferGeometry final : public Geometry {
109 public:
110 SkinnedVertexBufferGeometry();
111
112 ~SkinnedVertexBufferGeometry() override;
113
114 void SetVertexBuffer(VertexBuffer vertex_buffer);
115
116 // |Geometry|
117 GeometryType GetGeometryType() const override;
118
119 // |Geometry|
120 VertexBuffer GetVertexBuffer(Allocator& allocator) const override;
121
122 // |Geometry|
123 void BindToCommand(const SceneContext& scene_context,
124 HostBuffer& buffer,
125 const Matrix& transform,
126 RenderPass& pass) const override;
127
128 // |Geometry|
129 void SetJointsTexture(const std::shared_ptr<Texture>& texture) override;
130
131 private:
132 VertexBuffer vertex_buffer_;
133 std::shared_ptr<Texture> joints_texture_;
134
135 SkinnedVertexBufferGeometry(const SkinnedVertexBufferGeometry&) = delete;
136
137 SkinnedVertexBufferGeometry& operator=(const SkinnedVertexBufferGeometry&) =
138 delete;
139 };
140
141 } // namespace scene
142 } // namespace impeller
143
144 #endif // FLUTTER_IMPELLER_SCENE_GEOMETRY_H_
impeller::scene::SkinnedVertexBufferGeometry::BindToCommand
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, RenderPass &pass) const override
Definition: geometry.cc:237
impeller::scene::CuboidGeometry
Definition: geometry.h:51
impeller::scene::SkinnedVertexBufferGeometry::~SkinnedVertexBufferGeometry
~SkinnedVertexBufferGeometry() override
impeller::scene::Geometry::SetJointsTexture
virtual void SetJointsTexture(const std::shared_ptr< Texture > &texture)
Definition: geometry.cc:121
pipeline_key.h
host_buffer.h
scene_context.h
impeller::scene::SkinnedVertexBufferGeometry
Definition: geometry.h:108
impeller::scene::Geometry::MakeCuboid
static std::shared_ptr< CuboidGeometry > MakeCuboid(Vector3 size)
Definition: geometry.cc:31
vertex_buffer.h
impeller::HostBuffer
Definition: host_buffer.h:28
impeller::VertexBuffer
Definition: vertex_buffer.h:13
impeller::scene::UnskinnedVertexBufferGeometry::UnskinnedVertexBufferGeometry
UnskinnedVertexBufferGeometry()
impeller::scene::SkinnedVertexBufferGeometry::SkinnedVertexBufferGeometry
SkinnedVertexBufferGeometry()
impeller::scene::UnskinnedVertexBufferGeometry::GetGeometryType
GeometryType GetGeometryType() const override
Definition: geometry.cc:189
impeller::scene::CuboidGeometry::~CuboidGeometry
~CuboidGeometry() override
impeller::scene::CuboidGeometry::GetGeometryType
GeometryType GetGeometryType() const override
Definition: geometry.cc:136
impeller::scene::UnskinnedVertexBufferGeometry::GetVertexBuffer
VertexBuffer GetVertexBuffer(Allocator &allocator) const override
Definition: geometry.cc:194
impeller::scene::SceneContext
Definition: scene_context.h:41
impeller::scene::Geometry::GetVertexBuffer
virtual VertexBuffer GetVertexBuffer(Allocator &allocator) const =0
matrix.h
impeller::scene::SkinnedVertexBufferGeometry::GetGeometryType
GeometryType GetGeometryType() const override
Definition: geometry.cc:226
impeller::scene::SkinnedVertexBufferGeometry::GetVertexBuffer
VertexBuffer GetVertexBuffer(Allocator &allocator) const override
Definition: geometry.cc:231
render_pass.h
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:231
impeller::scene::UnskinnedVertexBufferGeometry::SetVertexBuffer
void SetVertexBuffer(VertexBuffer vertex_buffer)
Definition: geometry.cc:183
impeller::scene::Geometry::~Geometry
virtual ~Geometry()
impeller::scene::CuboidGeometry::BindToCommand
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, RenderPass &pass) const override
Definition: geometry.cc:163
impeller::scene::UnskinnedVertexBufferGeometry
Definition: geometry.h:79
impeller::Allocator
An object that allocates device memory.
Definition: allocator.h:22
impeller::scene::Geometry::MakeFromFlatbuffer
static std::shared_ptr< Geometry > MakeFromFlatbuffer(const fb::MeshPrimitive &mesh, Allocator &allocator)
Definition: geometry.cc:50
impeller::scene::Geometry::MakeVertexBuffer
static std::shared_ptr< Geometry > MakeVertexBuffer(VertexBuffer vertex_buffer, bool is_skinned)
Definition: geometry.cc:37
impeller::scene::UnskinnedVertexBufferGeometry::~UnskinnedVertexBufferGeometry
~UnskinnedVertexBufferGeometry() override
impeller::scene::Geometry
Definition: geometry.h:26
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
allocator.h
impeller::scene::GeometryType
GeometryType
Definition: pipeline_key.h:13
impeller::scene::CuboidGeometry::CuboidGeometry
CuboidGeometry()
vector.h
impeller::scene::SkinnedVertexBufferGeometry::SetVertexBuffer
void SetVertexBuffer(VertexBuffer vertex_buffer)
Definition: geometry.cc:221
impeller::scene::UnskinnedVertexBufferGeometry::BindToCommand
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, RenderPass &pass) const override
Definition: geometry.cc:200
impeller::scene::CuboidGeometry::GetVertexBuffer
VertexBuffer GetVertexBuffer(Allocator &allocator) const override
Definition: geometry.cc:141
impeller::scene::SkinnedVertexBufferGeometry::SetJointsTexture
void SetJointsTexture(const std::shared_ptr< Texture > &texture) override
Definition: geometry.cc:267
impeller::scene::Geometry::BindToCommand
virtual void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, const Matrix &transform, RenderPass &pass) const =0
impeller
Definition: aiks_blend_unittests.cc:18
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::Vector3
Definition: vector.h:20
impeller::scene::CuboidGeometry::SetSize
void SetSize(Vector3 size)
Definition: geometry.cc:131
impeller::scene::Geometry::GetGeometryType
virtual GeometryType GetGeometryType() const =0