11 #include "impeller/entity/position_color.vert.h"
12 #include "impeller/entity/vertices.frag.h"
27 geometry_ = std::move(geometry);
31 src_contents_ = std::move(contents);
43 blend_mode_ = blend_mode;
56 std::shared_ptr<Contents> src_contents = src_contents_;
58 if (geometry_->HasTextureCoordinates()) {
59 auto contents = std::make_shared<VerticesUVContents>(*
this);
61 if (!geometry_->HasVertexColors()) {
62 contents->SetAlpha(alpha_);
63 return contents->Render(renderer, entity, pass);
65 src_contents = contents;
68 auto dst_contents = std::make_shared<VerticesColorContents>(*
this);
71 std::shared_ptr<Contents> contents;
73 dst_contents->SetAlpha(alpha_);
74 contents = dst_contents;
79 color_filter_contents->SetAlpha(alpha_);
81 contents = color_filter_contents;
85 return contents->Render(renderer, entity, pass);
97 const Entity& entity)
const {
114 src_contents->RenderToSnapshot(renderer,
120 "VerticesUVContents Snapshot");
121 if (!snapshot.has_value()) {
127 const std::shared_ptr<Geometry>& geometry = parent_.
GetGeometry();
129 auto coverage = src_contents->GetCoverage(
Entity{});
130 if (!coverage.has_value()) {
133 auto geometry_result = geometry->GetPositionUVBuffer(
134 coverage.value(),
Matrix(), renderer, entity, pass);
136 opts.primitive_type = geometry_result.type;
141 VS::FrameInfo frame_info;
142 frame_info.mvp = geometry_result.transform;
143 frame_info.texture_sampler_y_coord_scale =
144 snapshot->texture->GetYCoordScale();
145 frame_info.alpha = alpha_ * snapshot->opacity;
146 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
148 FS::BindTextureSampler(pass, snapshot->texture,
149 renderer.
GetContext()->GetSamplerLibrary()->GetSampler(
150 snapshot->sampler_descriptor));
152 return pass.
Draw().ok();
164 const Entity& entity)
const {
180 const std::shared_ptr<VerticesGeometry>& geometry = parent_.
GetGeometry();
182 auto geometry_result =
183 geometry->GetPositionColorBuffer(renderer, entity, pass);
185 opts.primitive_type = geometry_result.type;
190 VS::FrameInfo frame_info;
191 frame_info.mvp = geometry_result.transform;
192 VS::BindFrameInfo(pass, host_buffer.EmplaceUniform(frame_info));
194 FS::FragInfo frag_info;
195 frag_info.alpha = alpha_;
196 FS::BindFragInfo(pass, host_buffer.EmplaceUniform(frag_info));
198 return pass.
Draw().ok();