| Flutter Impeller |

Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
impeller::ShadowVertices Class Reference

`#include <shadow_path_geometry.h>`

## Public Member Functions
constexpr | ShadowVertices ()
constexpr | ShadowVertices (std::vector< Point > vertices, std::vector< uint16_t > indices, std::vector< Scalar > gaussians)
size_t | GetVertexCount () const
size_t | GetIndexCount () const
| The count of the indices that define the mesh. More...
const std::vector< Point > & | GetVertices () const
const std::vector< uint16_t > & | GetIndices () const
const std::vector< Scalar > & | GetGaussians () const
bool | IsEmpty () const
std::optional< Rect > | GetBounds () const
GeometryResult | GetPositionBuffer (const ContentContext &renderer, const Entity &entity, RenderPass &pass) const

## Static Public Member Functions
static std::shared_ptr< ShadowVertices > | Make (std::vector< Point > vertices, std::vector< uint16_t > indices, std::vector< Scalar > gaussians)

## Static Public Attributes
static const std::shared_ptr< ShadowVertices > | kEmpty

## Detailed Description

A class to hold a vertex mesh for rendering shadows. The vertices are each associated with a gaussian coefficent that represents where that vertex lives in the shadow from a value of 1.0 (at the edge of or fully in the darkest part of the umbra) to 0.0 at the edge of or fully outside the penumbra).

The vertices are also associated with a vector of indices that assemble them into a mesh that covers the full umbra and penumbra of the shape.

The mesh is usually intended to be rendered at device (pixel) resolution.

Definition at line 24 of file shadow_path_geometry.h.

## Constructor & Destructor Documentation

## ◆ ShadowVertices() [1/2]

constexpr impeller::ShadowVertices::ShadowVertices | ( |  | ) |
| inline constexpr

Definition at line 35 of file shadow_path_geometry.h.

35 {}

## ◆ ShadowVertices() [2/2]

constexpr impeller::ShadowVertices::ShadowVertices | ( | std::vector< Point > | vertices,
|  | std::vector< uint16_t > | indices,
|  | std::vector< Scalar > | gaussians
| ) |  |
| inline constexpr

Definition at line 37 of file shadow_path_geometry.h.

40 : vertices_(std::move(vertices)),
41 indices_(std::move(indices)),
42 gaussians_(std::move(gaussians)) {}

## Member Function Documentation

## ◆ GetBounds()

std::optional< Rect > impeller::ShadowVertices::GetBounds | ( |  | ) | const

Definition at line 1385 of file shadow_path_geometry.cc.

1385 {
1386 return Rect::MakePointBounds(vertices_);
1387 }
impeller::TRect< Scalar >::MakePointBounds
constexpr static std::optional< TRect > MakePointBounds(const U &value)
Definition: rect.h:165

References impeller::TRect< Scalar >::MakePointBounds().

## ◆ GetGaussians()

const std::vector<Scalar>& impeller::ShadowVertices::GetGaussians | ( |  | ) | const
| inline

Definition at line 54 of file shadow_path_geometry.h.

54 { return gaussians_; }

## ◆ GetIndexCount()

size_t impeller::ShadowVertices::GetIndexCount | ( |  | ) | const
| inline

The count of the indices that define the mesh.

Definition at line 50 of file shadow_path_geometry.h.

50 { return indices_.size(); }

Referenced by GetPositionBuffer().

## ◆ GetIndices()

const std::vector<uint16_t>& impeller::ShadowVertices::GetIndices | ( |  | ) | const
| inline

Definition at line 53 of file shadow_path_geometry.h.

53 { return indices_; }

Referenced by GetPositionBuffer().

## ◆ GetPositionBuffer()

GeometryResult impeller::ShadowVertices::GetPositionBuffer | ( | const ContentContext & | renderer,
|  | const Entity & | entity,
|  | RenderPass & | pass
| ) |  | const

Definition at line 1415 of file shadow_path_geometry.cc.

1417 {
1418 using VS = ShadowVerticesVertexShader;
1419
1420 size_t vertex_count = GetVertexCount();
1421
1422 BufferView vertex_buffer = renderer.GetTransientsDataBuffer().Emplace(
1423 vertex_count * sizeof(VS::PerVertexData), alignof(VS::PerVertexData),
1424 [&](uint8_t* data) {
1425 VS::PerVertexData* vtx_contents =
1426 reinterpret_cast<VS::PerVertexData*>(data);
1427 for (size_t i = 0u; i < vertex_count; i++) {
1428 vtx_contents[i] = {
1429 .position = vertices_[i],
1430 .gaussian = gaussians_[i],
1431 };
1432 }
1433 });
1434
1435 size_t index_count = GetIndexCount();
1436 const uint16_t* indices_data = GetIndices().data();
1437 BufferView index_buffer = {};
1438 index_buffer = renderer.GetTransientsIndexesBuffer().Emplace(
1439 indices_data, index_count * sizeof(uint16_t), alignof(uint16_t));
1440
1441 return GeometryResult{
1442 .type = PrimitiveType::kTriangle,
1443 .vertex_buffer =
1444 {
1445 .vertex_buffer = vertex_buffer,
1446 .index_buffer = index_buffer,
1447 .vertex_count = index_count,
1448 .index_type = IndexType::k16bit,
1449 },
1450 .transform = entity.GetShaderTransform(pass),
1451 };
1452 }
impeller::ShadowVertices::GetVertexCount
size_t GetVertexCount() const
Definition: shadow_path_geometry.h:47
impeller::ShadowVertices::GetIndices
const std::vector< uint16_t > & GetIndices() const
Definition: shadow_path_geometry.h:53
impeller::ShadowVertices::GetIndexCount
size_t GetIndexCount() const
The count of the indices that define the mesh.
Definition: shadow_path_geometry.h:50
impeller::PrimitiveType::kTriangle
@ kTriangle
impeller::IndexType::k16bit
@ k16bit
impeller::VS
LinePipeline::VertexShader VS
Definition: line_contents.cc:13
data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:69

References data, impeller::HostBuffer::Emplace(), GetIndexCount(), GetIndices(), impeller::Entity::GetShaderTransform(), impeller::ContentContext::GetTransientsDataBuffer(), impeller::ContentContext::GetTransientsIndexesBuffer(), GetVertexCount(), impeller::k16bit, impeller::kTriangle, and impeller::GeometryResult::type.

## ◆ GetVertexCount()

size_t impeller::ShadowVertices::GetVertexCount | ( |  | ) | const
| inline

The count of the unique (duplicates minimized) vertices in the mesh. This number is also the count of gaussian coefficients in the mesh since the two are assigned 1:1.

Definition at line 47 of file shadow_path_geometry.h.

47 { return vertices_.size(); }

Referenced by GetPositionBuffer().

## ◆ GetVertices()

const std::vector<Point>& impeller::ShadowVertices::GetVertices | ( |  | ) | const
| inline

Definition at line 52 of file shadow_path_geometry.h.

52 { return vertices_; }

## ◆ IsEmpty()

bool impeller::ShadowVertices::IsEmpty | ( |  | ) | const
| inline

True if and only if there was no shadow for the shape and therefore no mesh to generate.

Definition at line 58 of file shadow_path_geometry.h.

58 { return vertices_.empty(); }

## ◆ Make()

static std::shared_ptr<ShadowVertices> impeller::ShadowVertices::Make | ( | std::vector< Point > | vertices,
|  | std::vector< uint16_t > | indices,
|  | std::vector< Scalar > | gaussians
| ) |  |
| inline static

Definition at line 28 of file shadow_path_geometry.h.

30 {
31 return std::make_shared<ShadowVertices>(
32 std::move(vertices), std::move(indices), std::move(gaussians));
33 }

## Member Data Documentation

## ◆ kEmpty

const std::shared_ptr< ShadowVertices > impeller::ShadowVertices::kEmpty
| static

Initial value:
=
std::make_shared<ShadowVertices>()

Definition at line 26 of file shadow_path_geometry.h.

The documentation for this class was generated from the following files:

- impeller/entity/geometry/shadow_path_geometry.h
- impeller/entity/geometry/shadow_path_geometry.cc