Flutter Impeller
vertices_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_ENTITY_GEOMETRY_VERTICES_GEOMETRY_H_
6 #define FLUTTER_IMPELLER_ENTITY_GEOMETRY_VERTICES_GEOMETRY_H_
7 
9 
10 namespace impeller {
11 
12 /// @brief A geometry that is created from a vertices object.
13 class VerticesGeometry final : public Geometry {
14  public:
15  enum class VertexMode {
16  kTriangles,
19  };
20 
21  VerticesGeometry(std::vector<Point> vertices,
22  std::vector<uint16_t> indices,
23  std::vector<Point> texture_coordinates,
24  std::vector<Color> colors,
25  Rect bounds,
26  VerticesGeometry::VertexMode vertex_mode);
27 
28  ~VerticesGeometry() = default;
29 
31  const Entity& entity,
32  RenderPass& pass);
33 
34  // |Geometry|
35  GeometryResult GetPositionUVBuffer(Rect texture_coverage,
36  Matrix effect_transform,
37  const ContentContext& renderer,
38  const Entity& entity,
39  RenderPass& pass) const override;
40 
41  // |Geometry|
43  const Entity& entity,
44  RenderPass& pass) const override;
45 
46  // |Geometry|
47  std::optional<Rect> GetCoverage(const Matrix& transform) const override;
48 
49  // |Geometry|
50  GeometryVertexType GetVertexType() const override;
51 
52  bool HasVertexColors() const;
53 
54  bool HasTextureCoordinates() const;
55 
56  std::optional<Rect> GetTextureCoordinateCoverge() const;
57 
58  private:
59  void NormalizeIndices();
60 
61  PrimitiveType GetPrimitiveType() const;
62 
63  std::vector<Point> vertices_;
64  std::vector<Color> colors_;
65  std::vector<Point> texture_coordinates_;
66  std::vector<uint16_t> indices_;
67  Rect bounds_;
68  VerticesGeometry::VertexMode vertex_mode_ =
70 };
71 
72 } // namespace impeller
73 
74 #endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_VERTICES_GEOMETRY_H_
impeller::VerticesGeometry
A geometry that is created from a vertices object.
Definition: vertices_geometry.h:13
impeller::VerticesGeometry::VerticesGeometry
VerticesGeometry(std::vector< Point > vertices, std::vector< uint16_t > indices, std::vector< Point > texture_coordinates, std::vector< Color > colors, Rect bounds, VerticesGeometry::VertexMode vertex_mode)
Definition: vertices_geometry.cc:55
impeller::VerticesGeometry::GetPositionUVBuffer
GeometryResult GetPositionUVBuffer(Rect texture_coverage, Matrix effect_transform, const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: vertices_geometry.cc:189
impeller::GeometryVertexType
GeometryVertexType
Definition: geometry.h:49
impeller::Entity
Definition: entity.h:21
impeller::PrimitiveType
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition: formats.h:353
impeller::VerticesGeometry::VertexMode
VertexMode
Definition: vertices_geometry.h:15
impeller::VerticesGeometry::HasVertexColors
bool HasVertexColors() const
Definition: vertices_geometry.cc:90
impeller::VerticesGeometry::VertexMode::kTriangleStrip
@ kTriangleStrip
impeller::VerticesGeometry::GetPositionColorBuffer
GeometryResult GetPositionColorBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass)
Definition: vertices_geometry.cc:145
geometry.h
impeller::GeometryResult
Definition: geometry.h:20
impeller::VerticesGeometry::GetVertexType
GeometryVertexType GetVertexType() const override
Definition: vertices_geometry.cc:246
impeller::VerticesGeometry::GetCoverage
std::optional< Rect > GetCoverage(const Matrix &transform) const override
Definition: vertices_geometry.cc:257
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::Geometry
Definition: geometry.h:83
impeller::VerticesGeometry::GetPositionBuffer
GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: vertices_geometry.cc:111
impeller::VerticesGeometry::VertexMode::kTriangles
@ kTriangles
impeller::VerticesGeometry::HasTextureCoordinates
bool HasTextureCoordinates() const
Definition: vertices_geometry.cc:94
impeller
Definition: aiks_blur_unittests.cc:20
impeller::VerticesGeometry::VertexMode::kTriangleFan
@ kTriangleFan
impeller::ContentContext
Definition: content_context.h:392
impeller::TRect
Definition: rect.h:122
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::VerticesGeometry::GetTextureCoordinateCoverge
std::optional< Rect > GetTextureCoordinateCoverge() const
Definition: vertices_geometry.cc:98
impeller::VerticesGeometry::~VerticesGeometry
~VerticesGeometry()=default