Flutter Engine
The Flutter Engine
vertices_builder.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_IMPORTER_VERTICES_BUILDER_H_
6#define FLUTTER_IMPELLER_SCENE_IMPORTER_VERTICES_BUILDER_H_
7
8#include <cstddef>
9#include <map>
10
12#include "impeller/scene/importer/scene_flatbuffers.h"
13
14namespace impeller {
15namespace scene {
16namespace importer {
17
18//------------------------------------------------------------------------------
19/// VerticesBuilder
20///
21
23 public:
24 static std::unique_ptr<VerticesBuilder> MakeUnskinned();
25
26 static std::unique_ptr<VerticesBuilder> MakeSkinned();
27
28 enum class ComponentType {
29 kSignedByte = 5120,
30 kUnsignedByte,
35 kFloat,
36 };
37
38 enum class AttributeType {
39 kPosition,
40 kNormal,
41 kTangent,
42 kTextureCoords,
43 kColor,
44 kJoints,
45 kWeights,
46 };
47
49 Scalar(const void* source, size_t byte_offset, bool normalized)>;
51 size_t size_bytes = 0;
53 };
54
57 std::function<void(Scalar* destination,
58 const void* source,
59 const ComponentProperties& component_props,
60 const AttributeProperties& attribute_props)>;
62 size_t offset_bytes = 0;
63 size_t size_bytes = 0;
64 size_t component_count = 0;
66 };
67
69
71
72 virtual void WriteFBVertices(fb::MeshPrimitiveT& primitive) const = 0;
73
74 virtual void SetAttributeFromBuffer(AttributeType attribute,
75 ComponentType component_type,
76 const void* buffer_start,
77 size_t attribute_stride_bytes,
78 size_t attribute_count) = 0;
79
80 protected:
81 static void WriteAttribute(void* destination,
82 size_t destination_stride_bytes,
83 AttributeType attribute,
84 ComponentType component_type,
85 const void* source,
86 size_t attribute_stride_bytes,
87 size_t attribute_count);
88
89 private:
92 kAttributeTypes;
93
94 VerticesBuilder(const VerticesBuilder&) = delete;
95
96 VerticesBuilder& operator=(const VerticesBuilder&) = delete;
97};
98
99//------------------------------------------------------------------------------
100/// UnskinnedVerticesBuilder
101///
102
104 public:
105 struct Vertex {
111 };
112
114
115 virtual ~UnskinnedVerticesBuilder() override;
116
117 // |VerticesBuilder|
118 void WriteFBVertices(fb::MeshPrimitiveT& primitive) const override;
119
120 // |VerticesBuilder|
122 ComponentType component_type,
123 const void* buffer_start,
124 size_t attribute_stride_bytes,
125 size_t attribute_count) override;
126
127 private:
128 std::vector<Vertex> vertices_;
129
131
132 UnskinnedVerticesBuilder& operator=(const UnskinnedVerticesBuilder&) = delete;
133};
134
135//------------------------------------------------------------------------------
136/// SkinnedVerticesBuilder
137///
138
140 public:
141 struct Vertex {
145 };
146
148
149 virtual ~SkinnedVerticesBuilder() override;
150
151 // |VerticesBuilder|
152 void WriteFBVertices(fb::MeshPrimitiveT& primitive) const override;
153
154 // |VerticesBuilder|
156 ComponentType component_type,
157 const void* buffer_start,
158 size_t attribute_stride_bytes,
159 size_t attribute_count) override;
160
161 private:
162 std::vector<Vertex> vertices_;
163
165
166 SkinnedVerticesBuilder& operator=(const SkinnedVerticesBuilder&) = delete;
167};
168
169} // namespace importer
170} // namespace scene
171} // namespace impeller
172
173#endif // FLUTTER_IMPELLER_SCENE_IMPORTER_VERTICES_BUILDER_H_
void WriteFBVertices(fb::MeshPrimitiveT &primitive) const override
void SetAttributeFromBuffer(AttributeType attribute, ComponentType component_type, const void *buffer_start, size_t attribute_stride_bytes, size_t attribute_count) override
void SetAttributeFromBuffer(AttributeType attribute, ComponentType component_type, const void *buffer_start, size_t attribute_stride_bytes, size_t attribute_count) override
void WriteFBVertices(fb::MeshPrimitiveT &primitive) const override
std::function< Scalar(const void *source, size_t byte_offset, bool normalized)> ComponentConverter
virtual void SetAttributeFromBuffer(AttributeType attribute, ComponentType component_type, const void *buffer_start, size_t attribute_stride_bytes, size_t attribute_count)=0
static std::unique_ptr< VerticesBuilder > MakeUnskinned()
static std::unique_ptr< VerticesBuilder > MakeSkinned()
static void WriteAttribute(void *destination, size_t destination_stride_bytes, AttributeType attribute, ComponentType component_type, const void *source, size_t attribute_stride_bytes, size_t attribute_count)
std::function< void(Scalar *destination, const void *source, const ComponentProperties &component_props, const AttributeProperties &attribute_props)> AttributeWriter
virtual void WriteFBVertices(fb::MeshPrimitiveT &primitive) const =0
@ kNormal
Default priority level.
Definition: embedder.h:262
SkBitmap source
Definition: examples.cpp:28
Dart_NativeFunction function
Definition: fuchsia.cc:51
float Scalar
Definition: scalar.h:18
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition: SkVx.h:680
static constexpr Color White()
Definition: color.h:266