10 #include "impeller/entity/porter_duff_blend.vert.h"
11 #include "impeller/entity/texture_fill.vert.h"
14 #include "third_party/skia/include/core/SkPoint.h"
21 const flutter::DlColor* colors,
25 std::optional<Rect> cull_rect)
33 cull_rect_(cull_rect) {}
46 if (cull_rect_.has_value()) {
47 return cull_rect_.value();
50 for (
size_t i = 0; i < count_; i++) {
51 auto bounds = xform_[i].
GetBounds(tex_[i].GetSize());
54 cull_rect_ = bounding_box;
72 using VS = TextureFillVertexShader;
74 constexpr
size_t indices[6] = {0, 1, 2, 1, 2, 3};
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);
82 auto texture_size = atlas_->GetSize();
83 for (
auto i = 0u; i < count_; 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;
98 .vertex_count = count_ * 6,
105 using VS = PorterDuffBlendVertexShader;
107 constexpr
size_t indices[6] = {0, 1, 2, 1, 2, 3};
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);
115 auto texture_size = atlas_->GetSize();
116 for (
auto i = 0u; i < count_; 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;
133 .vertex_count = count_ * 6,
std::shared_ptr< Texture > GetAtlas() const override
BlendMode GetBlendMode() const override
VertexBuffer CreateBlendVertexBuffer(HostBuffer &host_buffer) const override
const SamplerDescriptor & GetSamplerDescriptor() const override
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)
bool ShouldUseBlend() const override
Whether the blend shader should be used.
bool ShouldSkip() const override
Rect ComputeBoundingBox() const override
VertexBuffer CreateSimpleVertexBuffer(HostBuffer &host_buffer) const override
BufferView Emplace(const BufferType &buffer, size_t alignment=0)
Emplace non-uniform data (like contiguous vertices) onto the host buffer.
Color ToColor(const flutter::DlColor &color)
@ kNone
Does not use the index buffer.
GlyphAtlasPipeline::VertexShader VS
constexpr Color Premultiply() const
constexpr TRect Union(const TRect &o) const
std::shared_ptr< const fml::Mapping > data