| Flutter Impeller |

Public Member Functions | List of all members
impeller::DlAtlasGeometry Class Reference

A wrapper around data provided by a drawAtlas call. More...

`#include <dl_atlas_geometry.h>`

Inheritance diagram for impeller::DlAtlasGeometry:

## Public Member Functions
| DlAtlasGeometry (const std::shared_ptr< Texture > &atlas, const RSTransform *xform, const flutter::DlRect *tex, const flutter::DlColor *colors, size_t count, BlendMode mode, const SamplerDescriptor &sampling, std::optional< Rect > cull_rect)
| ~DlAtlasGeometry ()
bool | ShouldUseBlend () const override
| Whether the blend shader should be used. More...
bool | ShouldSkip () const override
VertexBuffer | CreateSimpleVertexBuffer (HostBuffer &host_buffer) const override
VertexBuffer | CreateBlendVertexBuffer (HostBuffer &host_buffer) const override
Rect | ComputeBoundingBox () const override
std::shared_ptr< Texture > | GetAtlas () const override
const SamplerDescriptor & | GetSamplerDescriptor () const override
BlendMode | GetBlendMode () const override

## Detailed Description

A wrapper around data provided by a drawAtlas call.

Definition at line 17 of file dl_atlas_geometry.h.

## Constructor & Destructor Documentation

## ◆ DlAtlasGeometry()

impeller::DlAtlasGeometry::DlAtlasGeometry | ( | const std::shared_ptr< Texture > & | atlas,
|  | const RSTransform * | xform,
|  | const flutter::DlRect * | tex,
|  | const flutter::DlColor * | colors,
|  | size_t | count,
|  | BlendMode | mode,
|  | const SamplerDescriptor & | sampling,
|  | std::optional< Rect > | cull_rect
| ) |  |

Definition at line 18 of file dl_atlas_geometry.cc.

26 : atlas_(atlas),
27 xform_(xform),
28 tex_(tex),
29 colors_(colors),
30 count_(count),
31 mode_(mode),
32 sampling_(sampling),
33 cull_rect_(cull_rect) {}

## ◆ ~DlAtlasGeometry()

impeller::DlAtlasGeometry::~DlAtlasGeometry | ( |  | ) |
| default

## Member Function Documentation

## ◆ ComputeBoundingBox()

Rect impeller::DlAtlasGeometry::ComputeBoundingBox | ( |  | ) | const
| override virtual

Implements impeller::AtlasGeometry.

Definition at line 45 of file dl_atlas_geometry.cc.

45 {
46 if (cull_rect_.has_value()) {
47 return cull_rect_.value();
48 }
49 Rect bounding_box;
50 for (size_t i = 0; i < count_; i++) {
51 auto bounds = xform_[i].GetBounds(tex_[i].GetSize());
52 bounding_box = Rect::Union(bounding_box, bounds);
53 }
54 cull_rect_ = bounding_box;
55 return bounding_box;
56 }

References impeller::RSTransform::GetBounds(), and impeller::TRect< Scalar >::Union().

## ◆ CreateBlendVertexBuffer()

VertexBuffer impeller::DlAtlasGeometry::CreateBlendVertexBuffer | ( | HostBuffer & | host_buffer | ) | const
| override virtual

Implements impeller::AtlasGeometry.

Definition at line 103 of file dl_atlas_geometry.cc.

104 {
105 using VS = PorterDuffBlendVertexShader;
106
107 constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
108
109 auto buffer_view = host_buffer.Emplace(
110 sizeof(VS::PerVertexData) * count_ * 6, alignof(VS::PerVertexData),
111 [&](uint8_t* raw_data) {
112 VS::PerVertexData* data =
113 reinterpret_cast<VS::PerVertexData*>(raw_data);
114 int offset = 0;
115 auto texture_size = atlas_->GetSize();
116 for (auto i = 0u; i < count_; i++) {
117 flutter::DlRect sample_rect = tex_[i];
118 auto points = sample_rect.GetPoints();
119 auto transformed_points = xform_[i].GetQuad(sample_rect.GetSize());
120 for (size_t j = 0; j < 6; j++) {
121 data[offset].vertices = transformed_points[indices[j]];
122 data[offset].texture_coords = points[indices[j]] / texture_size;
123 data[offset].color =
124 skia_conversions::ToColor(colors_[i]).Premultiply();
125 offset += 1;
126 }
127 }
128 });
129
130 return VertexBuffer{
131 .vertex_buffer = buffer_view,
132 .index_buffer = {},
133 .vertex_count = count_ * 6,
134 .index_type = IndexType::kNone,
135 };
136 }

References buffer_view, data, impeller::HostBuffer::Emplace(), impeller::RSTransform::GetQuad(), impeller::kNone, offset, impeller::Color::Premultiply(), impeller::skia_conversions::ToColor(), and impeller::VertexBuffer::vertex_buffer.

Referenced by impeller::testing::TEST_P().

## ◆ CreateSimpleVertexBuffer()

VertexBuffer impeller::DlAtlasGeometry::CreateSimpleVertexBuffer | ( | HostBuffer & | host_buffer | ) | const
| override virtual

Implements impeller::AtlasGeometry.

Definition at line 70 of file dl_atlas_geometry.cc.

71 {
72 using VS = TextureFillVertexShader;
73
74 constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
75
76 auto buffer_view = host_buffer.Emplace(
77 sizeof(VS::PerVertexData) * count_ * 6, alignof(VS::PerVertexData),
78 [&](uint8_t* raw_data) {
79 VS::PerVertexData* data =
80 reinterpret_cast<VS::PerVertexData*>(raw_data);
81 int offset = 0;
82 auto texture_size = atlas_->GetSize();
83 for (auto i = 0u; i < count_; i++) {
84 flutter::DlRect sample_rect = tex_[i];
85 auto points = sample_rect.GetPoints();
86 auto transformed_points = xform_[i].GetQuad(sample_rect.GetSize());
87 for (size_t j = 0; j < 6; j++) {
88 data[offset].position = transformed_points[indices[j]];
89 data[offset].texture_coords = points[indices[j]] / texture_size;
90 offset += 1;
91 }
92 }
93 });
94
95 return VertexBuffer{
96 .vertex_buffer = buffer_view,
97 .index_buffer = {},
98 .vertex_count = count_ * 6,
99 .index_type = IndexType::kNone,
100 };
101 }

References buffer_view, data, impeller::HostBuffer::Emplace(), impeller::RSTransform::GetQuad(), impeller::kNone, offset, and impeller::VertexBuffer::vertex_buffer.

Referenced by impeller::testing::TEST_P().

## ◆ GetAtlas()

std::shared_ptr< Texture > impeller::DlAtlasGeometry::GetAtlas | ( |  | ) | const
| override virtual

Implements impeller::AtlasGeometry.

Definition at line 58 of file dl_atlas_geometry.cc.

58 {
59 return atlas_;
60 }

## ◆ GetBlendMode()

BlendMode impeller::DlAtlasGeometry::GetBlendMode | ( |  | ) | const
| override virtual

Implements impeller::AtlasGeometry.

Definition at line 66 of file dl_atlas_geometry.cc.

66 {
67 return mode_;
68 }

## ◆ GetSamplerDescriptor()

const SamplerDescriptor & impeller::DlAtlasGeometry::GetSamplerDescriptor | ( |  | ) | const
| override virtual

Implements impeller::AtlasGeometry.

Definition at line 62 of file dl_atlas_geometry.cc.

62 {
63 return sampling_;
64 }

## ◆ ShouldSkip()

bool impeller::DlAtlasGeometry::ShouldSkip | ( |  | ) | const
| override virtual

Implements impeller::AtlasGeometry.

Definition at line 41 of file dl_atlas_geometry.cc.

41 {
42 return atlas_ == nullptr || (ShouldUseBlend() && mode_ == BlendMode::kClear);
43 }

References impeller::kClear, and ShouldUseBlend().

Referenced by impeller::testing::TEST_P().

## ◆ ShouldUseBlend()

bool impeller::DlAtlasGeometry::ShouldUseBlend | ( |  | ) | const
| override virtual

Whether the blend shader should be used.

Implements impeller::AtlasGeometry.

Definition at line 37 of file dl_atlas_geometry.cc.

37 {
38 return colors_ != nullptr && mode_ != BlendMode::kSource;
39 }

References impeller::kSource.

Referenced by ShouldSkip(), and impeller::testing::TEST_P().

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

- impeller/display_list/dl_atlas_geometry.h
- impeller/display_list/dl_atlas_geometry.cc

data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:64
impeller::BlendMode::kSource
@ kSource
impeller::VS
GlyphAtlasPipeline::VertexShader VS
Definition: text_contents.cc:25
impeller::skia_conversions::ToColor
Color ToColor(const flutter::DlColor &color)
Definition: skia_conversions.cc:89
impeller::RSTransform::GetQuad
void GetQuad(Scalar width, Scalar height, Quad &quad) const
Definition: rstransform.cc:24
buffer_view
BufferView buffer_view
Definition: blit_command_gles.cc:152
offset
SeparatedVector2 offset
Definition: stroke_path_geometry.cc:319
impeller::BlendMode::kClear
@ kClear
impeller::DlRect
flutter::DlRect DlRect
Definition: dl_dispatcher.h:25
impeller::IndexType::kNone
@ kNone
Does not use the index buffer.
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:792
impeller::DlAtlasGeometry::ShouldUseBlend
bool ShouldUseBlend() const override
Whether the blend shader should be used.
Definition: dl_atlas_geometry.cc:37
impeller::TRect< Scalar >::Union
constexpr TRect Union(const TRect &o) const
Definition: rect.h:517
impeller::Color::Premultiply
constexpr Color Premultiply() const
Definition: color.h:211
impeller::RSTransform::GetBounds
std::optional< Rect > GetBounds(Scalar width, Scalar height) const
Definition: rstransform.cc:49