| 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 SkRSXform *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 18 of file dl_atlas_geometry.h.

## Constructor & Destructor Documentation

## ◆ DlAtlasGeometry()

impeller::DlAtlasGeometry::DlAtlasGeometry | ( | const std::shared_ptr< Texture > & | atlas,
|  | const SkRSXform * | 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 matrix = skia_conversions::ToRSXForm(xform_[i]);
52 auto sample_rect = tex_[i];
53 auto bounds = Rect::MakeSize(sample_rect.GetSize()).TransformBounds(matrix);
54 bounding_box = bounds.Union(bounding_box);
55 }
56 cull_rect_ = bounding_box;
57 return bounding_box;
58 }

References impeller::TRect< Scalar >::MakeSize(), impeller::skia_conversions::ToRSXForm(), impeller::TRect< T >::TransformBounds(), and impeller::TRect< T >::Union().

## ◆ CreateBlendVertexBuffer()

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

Implements impeller::AtlasGeometry.

Definition at line 107 of file dl_atlas_geometry.cc.

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

References buffer_view, data, impeller::HostBuffer::Emplace(), impeller::TRect< T >::GetTransformedPoints(), impeller::kNone, impeller::TRect< Scalar >::MakeSize(), offset, impeller::Color::Premultiply(), impeller::skia_conversions::ToColor(), impeller::skia_conversions::ToRSXForm(), 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 72 of file dl_atlas_geometry.cc.

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

References buffer_view, data, impeller::HostBuffer::Emplace(), impeller::TRect< T >::GetTransformedPoints(), impeller::kNone, impeller::TRect< Scalar >::MakeSize(), offset, impeller::skia_conversions::ToRSXForm(), 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 60 of file dl_atlas_geometry.cc.

60 {
61 return atlas_;
62 }

## ◆ GetBlendMode()

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

Implements impeller::AtlasGeometry.

Definition at line 68 of file dl_atlas_geometry.cc.

68 {
69 return mode_;
70 }

## ◆ GetSamplerDescriptor()

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

Implements impeller::AtlasGeometry.

Definition at line 64 of file dl_atlas_geometry.cc.

64 {
65 return sampling_;
66 }

## ◆ 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:63
impeller::BlendMode::kSource
@ kSource
impeller::TRect::TransformBounds
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:466
impeller::skia_conversions::ToColor
Color ToColor(const flutter::DlColor &color)
Definition: skia_conversions.cc:106
buffer_view
BufferView buffer_view
Definition: blit_command_gles.cc:128
offset
SeparatedVector2 offset
Definition: stroke_path_geometry.cc:304
impeller::skia_conversions::ToRSXForm
Matrix ToRSXForm(const SkRSXform &form)
Definition: skia_conversions.cc:117
impeller::VS
SolidFillVertexShader VS
Definition: stroke_path_geometry.cc:16
impeller::TRect::GetTransformedPoints
constexpr std::array< TPoint< T >, 4 > GetTransformedPoints(const Matrix &transform) const
Definition: rect.h:420
impeller::BlendMode::kClear
@ kClear
impeller::DlRect
flutter::DlRect DlRect
Definition: dl_dispatcher.h:23
impeller::IndexType::kNone
@ kNone
Does not use the index buffer.
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:776
impeller::TRect< Scalar >::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:150
impeller::DlAtlasGeometry::ShouldUseBlend
bool ShouldUseBlend() const override
Whether the blend shader should be used.
Definition: dl_atlas_geometry.cc:37
impeller::TRect::Union
constexpr TRect Union(const TRect &o) const
Definition: rect.h:507
impeller::Color::Premultiply
constexpr Color Premultiply() const
Definition: color.h:211