Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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.
 
const std::vector< Point > & GetVertices () const
 
const std::vector< uint16_t > & GetIndices () const
 
const std::vector< Scalar > & GetGaussians () const
 
bool IsEmpty () const
 
std::optional< RectGetBounds () const
 
GeometryResult GetPositionBuffer (const ContentContext &renderer, const Entity &entity, RenderPass &pass) const
 

Static Public Member Functions

static std::shared_ptr< ShadowVerticesMake (std::vector< Point > vertices, std::vector< uint16_t > indices, std::vector< Scalar > gaussians)
 

Static Public Attributes

static const std::shared_ptr< ShadowVerticeskEmpty
 

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 ( )
inlineconstexpr

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 
)
inlineconstexpr

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 1388 of file shadow_path_geometry.cc.

1388 {
1389 return Rect::MakePointBounds(vertices_);
1390}
static constexpr 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 1418 of file shadow_path_geometry.cc.

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

References data, impeller::HostBuffer::Emplace(), GetIndexCount(), GetIndices(), impeller::Entity::GetShaderTransform(), impeller::ContentContext::GetTransientsDataBuffer(), impeller::ContentContext::GetTransientsIndexesBuffer(), GetVertexCount(), i, 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 
)
inlinestatic

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: