| Flutter Impeller |

atlas_contents.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <optional>
6 #include <unordered_map>
7 #include <utility>
8
9 #include "flutter/fml/macros.h"
10
11 #include "impeller/core/formats.h"
12 #include "impeller/entity/contents/atlas_contents.h"
13 #include "impeller/entity/contents/content_context.h"
14 #include "impeller/entity/contents/filters/blend_filter_contents.h"
15 #include "impeller/entity/contents/filters/color_filter_contents.h"
16 #include "impeller/entity/contents/filters/filter_contents.h"
17 #include "impeller/entity/contents/framebuffer_blend_contents.h"
18 #include "impeller/entity/contents/texture_contents.h"
19 #include "impeller/entity/entity.h"
20 #include "impeller/entity/geometry/geometry.h"
21 #include "impeller/entity/texture_fill.frag.h"
22 #include "impeller/entity/texture_fill.vert.h"
23 #include "impeller/geometry/color.h"
24 #include "impeller/renderer/render_pass.h"
25 #include "impeller/renderer/sampler_library.h"
26 #include "impeller/renderer/vertex_buffer_builder.h"
27
28 namespace impeller {
29
30 AtlasContents::AtlasContents() = default;
31
32 AtlasContents::~AtlasContents() = default;
33
34 void AtlasContents::SetTexture(std::shared_ptr<Texture> texture) {
35 texture_ = std::move(texture);
36 }
37
38 std::shared_ptr<Texture> AtlasContents::GetTexture() const {
39 return texture_;
40 }
41
42 void AtlasContents::SetTransforms(std::vector<Matrix> transforms) {
43 transforms_ = std::move(transforms);
44 bounding_box_cache_.reset();
45 }
46
47 void AtlasContents::SetTextureCoordinates(std::vector<Rect> texture_coords) {
48 texture_coords_ = std::move(texture_coords);
49 bounding_box_cache_.reset();
50 }
51
52 void AtlasContents::SetColors(std::vector<Color> colors) {
53 colors_ = std::move(colors);
54 }
55
56 void AtlasContents::SetAlpha(Scalar alpha) {
57 alpha_ = alpha;
58 }
59
60 void AtlasContents::SetBlendMode(BlendMode blend_mode) {
61 blend_mode_ = blend_mode;
62 }
63
64 void AtlasContents::SetCullRect(std::optional<Rect> cull_rect) {
65 cull_rect_ = cull_rect;
66 }
67
68 struct AtlasBlenderKey {
69 Color color;
70 Rect rect;
71 uint32_t color_key;
72
73 struct Hash {
74 std::size_t operator()(const AtlasBlenderKey& key) const {
75 return fml::HashCombine(key.color_key, key.rect.size.width,
76 key.rect.size.height, key.rect.origin.x,
77 key.rect.origin.y);
78 }
79 };
80
81 struct Equal {
82 bool operator()(const AtlasBlenderKey& lhs,
83 const AtlasBlenderKey& rhs) const {
84 return lhs.rect == rhs.rect && lhs.color_key == rhs.color_key;
85 }
86 };
87 };
88
89 std::shared_ptr<SubAtlasResult> AtlasContents::GenerateSubAtlas() const {
90 FML_DCHECK(colors_.size() > 0 && blend_mode_ != BlendMode::kSource &&
91 blend_mode_ != BlendMode::kDestination);
92
93 std::unordered_map<AtlasBlenderKey, std::vector<Matrix>,
94 AtlasBlenderKey::Hash, AtlasBlenderKey::Equal>
95 sub_atlas = {};
96
97 for (auto i = 0u; i < texture_coords_.size(); i++) {
98 AtlasBlenderKey key = {.color = colors_[i],
99 .rect = texture_coords_[i],
100 .color_key = Color::ToIColor(colors_[i])};
101 if (sub_atlas.find(key) == sub_atlas.end()) {
102 sub_atlas[key] = {transforms_[i]};
103 } else {
104 sub_atlas[key].push_back(transforms_[i]);
105 }
106 }
107
108 auto result = std::make_shared<SubAtlasResult>();
109 Scalar x_offset = 0.0;
110 Scalar y_offset = 0.0;
111 Scalar x_extent = 0.0;
112 Scalar y_extent = 0.0;
113
114 for (auto it = sub_atlas.begin(); it != sub_atlas.end(); it++) {
115 // This size was arbitrarily chosen to keep the textures from getting too
116 // wide. We could instead use a more generic rect packer but in the majority
117 // of cases the sample rects will be fairly close in size making this a good
118 // enough approximation.
119 if (x_offset >= 1000) {
120 y_offset = y_extent + 1;
121 x_offset = 0.0;
122 }
123
124 auto key = it->first;
125 auto transforms = it->second;
126
127 auto new_rect = Rect::MakeXYWH(x_offset, y_offset, key.rect.size.width,
128 key.rect.size.height);
129 auto sub_transform = Matrix::MakeTranslation(Vector2(x_offset, y_offset));
130
131 x_offset += std::ceil(key.rect.size.width) + 1.0;
132
133 result->sub_texture_coords.push_back(key.rect);
134 result->sub_colors.push_back(key.color);
135 result->sub_transforms.push_back(sub_transform);
136
137 x_extent = std::max(x_extent, x_offset);
138 y_extent = std::max(y_extent, std::ceil(y_offset + key.rect.size.height));
139
140 for (auto transform : transforms) {
141 result->result_texture_coords.push_back(new_rect);
142 result->result_transforms.push_back(transform);
143 }
144 }
145 result->size = ISize(std::ceil(x_extent), std::ceil(y_extent));
146 return result;
147 }
148
149 std::optional<Rect> AtlasContents::GetCoverage(const Entity& entity) const {
150 if (cull_rect_.has_value()) {
151 return cull_rect_.value().TransformBounds(entity.GetTransformation());
152 }
153 return ComputeBoundingBox().TransformBounds(entity.GetTransformation());
154 }
155
156 Rect AtlasContents::ComputeBoundingBox() const {
157 if (!bounding_box_cache_.has_value()) {
158 Rect bounding_box = {};
159 for (size_t i = 0; i < texture_coords_.size(); i++) {
160 auto matrix = transforms_[i];
161 auto sample_rect = texture_coords_[i];
162 auto bounds = Rect::MakeSize(sample_rect.size).TransformBounds(matrix);
163 bounding_box = bounds.Union(bounding_box);
164 }
165 bounding_box_cache_ = bounding_box;
166 }
167 return bounding_box_cache_.value();
168 }
169
170 void AtlasContents::SetSamplerDescriptor(SamplerDescriptor desc) {
171 sampler_descriptor_ = std::move(desc);
172 }
173
174 const SamplerDescriptor& AtlasContents::GetSamplerDescriptor() const {
175 return sampler_descriptor_;
176 }
177
178 const std::vector<Matrix>& AtlasContents::GetTransforms() const {
179 return transforms_;
180 }
181
182 const std::vector<Rect>& AtlasContents::GetTextureCoordinates() const {
183 return texture_coords_;
184 }
185
186 const std::vector<Color>& AtlasContents::GetColors() const {
187 return colors_;
188 }
189
190 bool AtlasContents::Render(const ContentContext& renderer,
191 const Entity& entity,
192 RenderPass& pass) const {
193 if (texture_ == nullptr || blend_mode_ == BlendMode::kClear ||
194 alpha_ <= 0.0) {
195 return true;
196 }
197
198 // Ensure that we use the actual computed bounds and not a cull-rect
199 // approximation of them.
200 auto coverage = ComputeBoundingBox();
201
202 if (blend_mode_ == BlendMode::kSource || colors_.size() == 0) {
203 auto child_contents = AtlasTextureContents(*this);
204 child_contents.SetAlpha(alpha_);
205 child_contents.SetCoverage(coverage);
206 return child_contents.Render(renderer, entity, pass);
207 }
208 if (blend_mode_ == BlendMode::kDestination) {
209 auto child_contents = AtlasColorContents(*this);
210 child_contents.SetAlpha(alpha_);
211 child_contents.SetCoverage(coverage);
212 return child_contents.Render(renderer, entity, pass);
213 }
214
215 constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
216 constexpr Scalar width[6] = {0, 1, 0, 1, 0, 1};
217 constexpr Scalar height[6] = {0, 0, 1, 0, 1, 1};
218
219 if (blend_mode_ <= BlendMode::kModulate) {
220 // Simple Porter-Duff blends can be accomplished without a subpass.
221 using VS = PorterDuffBlendPipeline::VertexShader;
222 using FS = PorterDuffBlendPipeline::FragmentShader;
223
224 VertexBufferBuilder<VS::PerVertexData> vtx_builder;
225 vtx_builder.Reserve(texture_coords_.size() * 6);
226 const auto texture_size = texture_->GetSize();
227 auto& host_buffer = pass.GetTransientsBuffer();
228
229 for (size_t i = 0; i < texture_coords_.size(); i++) {
230 auto sample_rect = texture_coords_[i];
231 auto matrix = transforms_[i];
232 auto transformed_points =
233 Rect::MakeSize(sample_rect.size).GetTransformedPoints(matrix);
234 auto color = colors_[i].Premultiply();
235 for (size_t j = 0; j < 6; j++) {
236 VS::PerVertexData data;
237 data.vertices = transformed_points[indices[j]];
238 data.texture_coords =
239 (sample_rect.origin + Point(sample_rect.size.width * width[j],
240 sample_rect.size.height * height[j])) /
241 texture_size;
242 data.color = color;
243 vtx_builder.AppendVertex(data);
244 }
245 }
246
247 auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer);
248
249 Command cmd;
250 DEBUG_COMMAND_INFO(
251 cmd, SPrintF("DrawAtlas Blend (%s)", BlendModeToString(blend_mode_)));
252 cmd.BindVertices(vtx_buffer);
253 cmd.stencil_reference = entity.GetStencilDepth();
254 auto options = OptionsFromPass(pass);
255 cmd.pipeline = renderer.GetPorterDuffBlendPipeline(options);
256
257 FS::FragInfo frag_info;
258 VS::FrameInfo frame_info;
259
260 auto dst_sampler_descriptor = sampler_descriptor_;
261 if (renderer.GetDeviceCapabilities().SupportsDecalSamplerAddressMode()) {
262 dst_sampler_descriptor.width_address_mode = SamplerAddressMode::kDecal;
263 dst_sampler_descriptor.height_address_mode = SamplerAddressMode::kDecal;
264 }
265 auto dst_sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler(
266 dst_sampler_descriptor);
267 FS::BindTextureSamplerDst(cmd, texture_, dst_sampler);
268 frame_info.texture_sampler_y_coord_scale = texture_->GetYCoordScale();
269
270 frag_info.output_alpha = alpha_;
271 frag_info.input_alpha = 1.0;
272
273 auto inverted_blend_mode =
274 InvertPorterDuffBlend(blend_mode_).value_or(BlendMode::kSource);
275 auto blend_coefficients =
276 kPorterDuffCoefficients[static_cast<int>(inverted_blend_mode)];
277 frag_info.src_coeff = blend_coefficients[0];
278 frag_info.src_coeff_dst_alpha = blend_coefficients[1];
279 frag_info.dst_coeff = blend_coefficients[2];
280 frag_info.dst_coeff_src_alpha = blend_coefficients[3];
281 frag_info.dst_coeff_src_color = blend_coefficients[4];
282
283 FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info));
284
285 frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
286 entity.GetTransformation();
287
288 auto uniform_view = host_buffer.EmplaceUniform(frame_info);
289 VS::BindFrameInfo(cmd, uniform_view);
290
291 return pass.AddCommand(std::move(cmd));
292 }
293
294 // Advanced blends.
295
296 auto sub_atlas = GenerateSubAtlas();
297 auto sub_coverage = Rect::MakeSize(sub_atlas->size);
298
299 auto src_contents = std::make_shared<AtlasTextureContents>(*this);
300 src_contents->SetSubAtlas(sub_atlas);
301 src_contents->SetCoverage(sub_coverage);
302
303 auto dst_contents = std::make_shared<AtlasColorContents>(*this);
304 dst_contents->SetSubAtlas(sub_atlas);
305 dst_contents->SetCoverage(sub_coverage);
306
307 Entity untransformed_entity;
308 auto contents = ColorFilterContents::MakeBlend(
309 blend_mode_,
310 {FilterInput::Make(dst_contents), FilterInput::Make(src_contents)});
311 auto snapshot =
312 contents->RenderToSnapshot(renderer, // renderer
313 untransformed_entity, // entity
314 std::nullopt, // coverage_limit
315 std::nullopt, // sampler_descriptor
316 true, // msaa_enabled
317 "AtlasContents Snapshot"); // label
318 if (!snapshot.has_value()) {
319 return false;
320 }
321
322 auto child_contents = AtlasTextureContents(*this);
323 child_contents.SetAlpha(alpha_);
324 child_contents.SetCoverage(coverage);
325 child_contents.SetTexture(snapshot.value().texture);
326 child_contents.SetUseDestination(true);
327 child_contents.SetSubAtlas(sub_atlas);
328 return child_contents.Render(renderer, entity, pass);
329 }
330
331 // AtlasTextureContents
332 // ---------------------------------------------------------
333
334 AtlasTextureContents::AtlasTextureContents(const AtlasContents& parent)
335 : parent_(parent) {}
336
337 AtlasTextureContents::~AtlasTextureContents() {}
338
339 std::optional<Rect> AtlasTextureContents::GetCoverage(
340 const Entity& entity) const {
341 return coverage_.TransformBounds(entity.GetTransformation());
342 }
343
344 void AtlasTextureContents::SetAlpha(Scalar alpha) {
345 alpha_ = alpha;
346 }
347
348 void AtlasTextureContents::SetCoverage(Rect coverage) {
349 coverage_ = coverage;
350 }
351
352 void AtlasTextureContents::SetUseDestination(bool value) {
353 use_destination_ = value;
354 }
355
356 void AtlasTextureContents::SetSubAtlas(
357 const std::shared_ptr<SubAtlasResult>& subatlas) {
358 subatlas_ = subatlas;
359 }
360
361 void AtlasTextureContents::SetTexture(std::shared_ptr<Texture> texture) {
362 texture_ = std::move(texture);
363 }
364
365 bool AtlasTextureContents::Render(const ContentContext& renderer,
366 const Entity& entity,
367 RenderPass& pass) const {
368 using VS = TextureFillVertexShader;
369 using FS = TextureFillFragmentShader;
370
371 auto texture = texture_ ? texture_ : parent_.GetTexture();
372 if (texture == nullptr) {
373 return true;
374 }
375
376 std::vector<Rect> texture_coords;
377 std::vector<Matrix> transforms;
378 if (subatlas_) {
379 texture_coords = use_destination_ ? subatlas_->result_texture_coords
380 : subatlas_->sub_texture_coords;
381 transforms = use_destination_ ? subatlas_->result_transforms
382 : subatlas_->sub_transforms;
383 } else {
384 texture_coords = parent_.GetTextureCoordinates();
385 transforms = parent_.GetTransforms();
386 }
387
388 const Size texture_size(texture->GetSize());
389 VertexBufferBuilder<VS::PerVertexData> vertex_builder;
390 vertex_builder.Reserve(texture_coords.size() * 6);
391 constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
392 constexpr Scalar width[6] = {0, 1, 0, 1, 0, 1};
393 constexpr Scalar height[6] = {0, 0, 1, 0, 1, 1};
394 for (size_t i = 0; i < texture_coords.size(); i++) {
395 auto sample_rect = texture_coords[i];
396 auto matrix = transforms[i];
397 auto transformed_points =
398 Rect::MakeSize(sample_rect.size).GetTransformedPoints(matrix);
399
400 for (size_t j = 0; j < 6; j++) {
401 VS::PerVertexData data;
402 data.position = transformed_points[indices[j]];
403 data.texture_coords =
404 (sample_rect.origin + Point(sample_rect.size.width * width[j],
405 sample_rect.size.height * height[j])) /
406 texture_size;
407 vertex_builder.AppendVertex(data);
408 }
409 }
410
411 if (!vertex_builder.HasVertices()) {
412 return true;
413 }
414
415 Command cmd;
416 DEBUG_COMMAND_INFO(cmd, "AtlasTexture");
417
418 auto& host_buffer = pass.GetTransientsBuffer();
419
420 VS::FrameInfo frame_info;
421 frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
422 entity.GetTransformation();
423 frame_info.texture_sampler_y_coord_scale = texture->GetYCoordScale();
424 frame_info.alpha = alpha_;
425
426 auto options = OptionsFromPassAndEntity(pass, entity);
427 cmd.pipeline = renderer.GetTexturePipeline(options);
428 cmd.stencil_reference = entity.GetStencilDepth();
429 cmd.BindVertices(vertex_builder.CreateVertexBuffer(host_buffer));
430 VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info));
431 FS::BindTextureSampler(cmd, texture,
432 renderer.GetContext()->GetSamplerLibrary()->GetSampler(
433 parent_.GetSamplerDescriptor()));
434 return pass.AddCommand(std::move(cmd));
435 }
436
437 // AtlasColorContents
438 // ---------------------------------------------------------
439
440 AtlasColorContents::AtlasColorContents(const AtlasContents& parent)
441 : parent_(parent) {}
442
443 AtlasColorContents::~AtlasColorContents() {}
444
445 std::optional<Rect> AtlasColorContents::GetCoverage(
446 const Entity& entity) const {
447 return coverage_.TransformBounds(entity.GetTransformation());
448 }
449
450 void AtlasColorContents::SetAlpha(Scalar alpha) {
451 alpha_ = alpha;
452 }
453
454 void AtlasColorContents::SetCoverage(Rect coverage) {
455 coverage_ = coverage;
456 }
457
458 void AtlasColorContents::SetSubAtlas(
459 const std::shared_ptr<SubAtlasResult>& subatlas) {
460 subatlas_ = subatlas;
461 }
462
463 bool AtlasColorContents::Render(const ContentContext& renderer,
464 const Entity& entity,
465 RenderPass& pass) const {
466 using VS = GeometryColorPipeline::VertexShader;
467 using FS = GeometryColorPipeline::FragmentShader;
468
469 std::vector<Rect> texture_coords;
470 std::vector<Matrix> transforms;
471 std::vector<Color> colors;
472 if (subatlas_) {
473 texture_coords = subatlas_->sub_texture_coords;
474 colors = subatlas_->sub_colors;
475 transforms = subatlas_->sub_transforms;
476 } else {
477 texture_coords = parent_.GetTextureCoordinates();
478 transforms = parent_.GetTransforms();
479 colors = parent_.GetColors();
480 }
481
482 VertexBufferBuilder<VS::PerVertexData> vertex_builder;
483 vertex_builder.Reserve(texture_coords.size() * 6);
484 constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
485 for (size_t i = 0; i < texture_coords.size(); i++) {
486 auto sample_rect = texture_coords[i];
487 auto matrix = transforms[i];
488 auto transformed_points =
489 Rect::MakeSize(sample_rect.size).GetTransformedPoints(matrix);
490
491 for (size_t j = 0; j < 6; j++) {
492 VS::PerVertexData data;
493 data.position = transformed_points[indices[j]];
494 data.color = colors[i].Premultiply();
495 vertex_builder.AppendVertex(data);
496 }
497 }
498
499 if (!vertex_builder.HasVertices()) {
500 return true;
501 }
502
503 Command cmd;
504 DEBUG_COMMAND_INFO(cmd, "AtlasColors");
505
506 auto& host_buffer = pass.GetTransientsBuffer();
507
508 VS::FrameInfo frame_info;
509 frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
510 entity.GetTransformation();
511
512 FS::FragInfo frag_info;
513 frag_info.alpha = alpha_;
514
515 auto opts = OptionsFromPassAndEntity(pass, entity);
516 opts.blend_mode = BlendMode::kSourceOver;
517 cmd.pipeline = renderer.GetGeometryColorPipeline(opts);
518 cmd.stencil_reference = entity.GetStencilDepth();
519 cmd.BindVertices(vertex_builder.CreateVertexBuffer(host_buffer));
520 VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info));
521 FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info));
522 return pass.AddCommand(std::move(cmd));
523 }
524
525 } // namespace impeller
impeller::ContentContext::GetTexturePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTexturePipeline(ContentContextOptions opts) const
Definition: content_context.h:427
impeller::BlendMode
BlendMode
Definition: color.h:57
impeller::AtlasContents::SetTextureCoordinates
void SetTextureCoordinates(std::vector< Rect > texture_coords)
Definition: atlas_contents.cc:47
impeller::OptionsFromPass
ContentContextOptions OptionsFromPass(const RenderPass &pass)
Definition: contents.cc:20
impeller::Command
An object used to specify work to the GPU along with references to resources the GPU will used when d...
Definition: command.h:99
DEBUG_COMMAND_INFO
#define DEBUG_COMMAND_INFO(obj, arg)
Definition: command.h:31
impeller::BlendModeToString
const char * BlendModeToString(BlendMode blend_mode)
Definition: color.cc:47
impeller::AtlasColorContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: atlas_contents.cc:450
impeller::Entity::GetStencilDepth
uint32_t GetStencilDepth() const
Definition: entity.cc:93
impeller::TRect::size
TSize< Type > size
Definition: rect.h:24
impeller::TPoint::y
Type y
Definition: point.h:24
impeller::Scalar
float Scalar
Definition: scalar.h:15
texture_contents.h
sampler_library.h
entity.h
impeller::AtlasContents::SetSamplerDescriptor
void SetSamplerDescriptor(SamplerDescriptor desc)
Definition: atlas_contents.cc:170
impeller::AtlasColorContents
Definition: atlas_contents.h:128
impeller::TRect< Scalar >::MakeXYWH
constexpr static TRect MakeXYWH(Type x, Type y, Type width, Type height)
Definition: rect.h:47
impeller::Color
Definition: color.h:122
impeller::AtlasBlenderKey::color
Color color
Definition: atlas_contents.cc:69
impeller::FilterInput::Make
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
Definition: filter_input.cc:19
impeller::TRect::TransformBounds
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:204
formats.h
impeller::AtlasTextureContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: atlas_contents.cc:365
impeller::InvertPorterDuffBlend
std::optional< BlendMode > InvertPorterDuffBlend(BlendMode blend_mode)
Definition: blend_filter_contents.cc:28
impeller::Vector2
Point Vector2
Definition: point.h:310
impeller::RenderPipelineT::FragmentShader
FragmentShader_ FragmentShader
Definition: pipeline.h:91
impeller::AtlasColorContents::AtlasColorContents
AtlasColorContents(const AtlasContents &parent)
Definition: atlas_contents.cc:440
impeller::AtlasColorContents::SetCoverage
void SetCoverage(Rect coverage)
Definition: atlas_contents.cc:454
framebuffer_blend_contents.h
impeller::Matrix::MakeTranslation
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition: matrix.h:94
impeller::Entity::GetTransformation
const Matrix & GetTransformation() const
Definition: entity.cc:49
impeller::VertexBufferBuilder::HasVertices
bool HasVertices() const
Definition: vertex_buffer_builder.h:51
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:18
impeller::AtlasTextureContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: atlas_contents.cc:344
impeller::Entity
Definition: entity.h:21
impeller::OptionsFromPassAndEntity
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
Definition: contents.cc:30
impeller::AtlasContents::SetBlendMode
void SetBlendMode(BlendMode blend_mode)
Definition: atlas_contents.cc:60
impeller::RenderPass::GetRenderTargetSize
ISize GetRenderTargetSize() const
Definition: render_pass.cc:30
impeller::TSize
Definition: size.h:18
impeller::Point
TPoint< Scalar > Point
Definition: point.h:306
filter_contents.h
render_pass.h
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::Color::ToIColor
static constexpr uint32_t ToIColor(Color color)
Convert this color to a 32-bit representation.
Definition: color.h:159
impeller::AtlasContents::GenerateSubAtlas
std::shared_ptr< SubAtlasResult > GenerateSubAtlas() const
Compress a drawAtlas call with blending into a smaller sized atlas. This atlas has no overlapping to ...
Definition: atlas_contents.cc:89
impeller::AtlasContents::~AtlasContents
~AtlasContents() override
impeller::AtlasContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: atlas_contents.cc:190
impeller::SPrintF
std::string SPrintF(const char *format,...)
Definition: strings.cc:12
impeller::BlendMode::kDestination
@ kDestination
impeller::TRect::GetTransformedPoints
constexpr std::array< TPoint< T >, 4 > GetTransformedPoints(const Matrix &transform) const
Definition: rect.h:193
impeller::ContentContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: content_context.cc:440
impeller::VertexBufferBuilder
Definition: vertex_buffer_builder.h:23
impeller::AtlasBlenderKey
Definition: atlas_contents.cc:68
geometry.h
impeller::AtlasContents::GetTransforms
const std::vector< Matrix > & GetTransforms() const
Definition: atlas_contents.cc:178
impeller::SamplerDescriptor::width_address_mode
SamplerAddressMode width_address_mode
Definition: sampler_descriptor.h:23
impeller::AtlasContents::GetTextureCoordinates
const std::vector< Rect > & GetTextureCoordinates() const
Definition: atlas_contents.cc:182
impeller::AtlasColorContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: atlas_contents.cc:463
impeller::AtlasColorContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the screen space bounding rectangle that this contents affects.
Definition: atlas_contents.cc:445
impeller::AtlasContents::GetTexture
std::shared_ptr< Texture > GetTexture() const
Definition: atlas_contents.cc:38
impeller::AtlasBlenderKey::Hash
Definition: atlas_contents.cc:73
impeller::kPorterDuffCoefficients
constexpr std::array< std::array< Scalar, 5 >, 15 > kPorterDuffCoefficients
Definition: blend_filter_contents.h:14
impeller::AtlasBlenderKey::Equal::operator()
bool operator()(const AtlasBlenderKey &lhs, const AtlasBlenderKey &rhs) const
Definition: atlas_contents.cc:82
impeller::AtlasContents
Definition: atlas_contents.h:32
impeller::TRect::origin
TPoint< Type > origin
Definition: rect.h:23
impeller::AtlasTextureContents::SetSubAtlas
void SetSubAtlas(const std::shared_ptr< SubAtlasResult > &subatlas)
Definition: atlas_contents.cc:356
color_filter_contents.h
impeller::AtlasContents::AtlasContents
AtlasContents()
impeller::TSize::width
Type width
Definition: size.h:21
impeller::AtlasContents::SetColors
void SetColors(std::vector< Color > colors)
Definition: atlas_contents.cc:52
impeller::AtlasColorContents::~AtlasColorContents
~AtlasColorContents() override
Definition: atlas_contents.cc:443
impeller::AtlasBlenderKey::color_key
uint32_t color_key
Definition: atlas_contents.cc:71
impeller::TPoint::x
Type x
Definition: point.h:23
impeller::VertexBufferBuilder::CreateVertexBuffer
VertexBuffer CreateVertexBuffer(HostBuffer &host_buffer) const
Definition: vertex_buffer_builder.h:78
impeller::ISize
TSize< int64_t > ISize
Definition: size.h:136
impeller::AtlasTextureContents
Definition: atlas_contents.h:93
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:27
impeller::AtlasContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the screen space bounding rectangle that this contents affects.
Definition: atlas_contents.cc:149
atlas_contents.h
impeller::Command::stencil_reference
uint32_t stencil_reference
Definition: command.h:152
content_context.h
impeller::ContentContext::GetDeviceCapabilities
const Capabilities & GetDeviceCapabilities() const
Definition: content_context.cc:444
impeller::AtlasTextureContents::SetUseDestination
void SetUseDestination(bool value)
Definition: atlas_contents.cc:352
impeller::TRect< Scalar >::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:52
impeller::AtlasTextureContents::~AtlasTextureContents
~AtlasTextureContents() override
Definition: atlas_contents.cc:337
impeller::AtlasContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: atlas_contents.cc:56
impeller::AtlasTextureContents::AtlasTextureContents
AtlasTextureContents(const AtlasContents &parent)
Definition: atlas_contents.cc:334
impeller::AtlasContents::SetCullRect
void SetCullRect(std::optional< Rect > cull_rect)
Definition: atlas_contents.cc:64
impeller::BlendMode::kClear
@ kClear
impeller::Matrix::MakeOrthographic
static constexpr Matrix MakeOrthographic(TSize< T > size)
Definition: matrix.h:448
impeller::VertexBufferBuilder::AppendVertex
VertexBufferBuilder & AppendVertex(VertexType_ vertex)
Definition: vertex_buffer_builder.h:59
impeller::AtlasBlenderKey::rect
Rect rect
Definition: atlas_contents.cc:70
impeller::TRect::Union
constexpr TRect Union(const TRect &o) const
Definition: rect.h:209
color.h
impeller::AtlasContents::SetTexture
void SetTexture(std::shared_ptr< Texture > texture)
Definition: atlas_contents.cc:34
impeller::TSize::height
Type height
Definition: size.h:22
blend_filter_contents.h
impeller::Command::BindVertices
bool BindVertices(const VertexBuffer &buffer)
Specify the vertex and index buffer to use for this command.
Definition: command.cc:15
impeller::Command::pipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > pipeline
Definition: command.h:103
impeller::BlendMode::kModulate
@ kModulate
impeller::AtlasContents::SetTransforms
void SetTransforms(std::vector< Matrix > transforms)
Definition: atlas_contents.cc:42
impeller::VertexBufferBuilder::Reserve
void Reserve(size_t count)
Definition: vertex_buffer_builder.h:47
impeller::AtlasBlenderKey::Equal
Definition: atlas_contents.cc:81
impeller::Capabilities::SupportsDecalSamplerAddressMode
virtual bool SupportsDecalSamplerAddressMode() const =0
Whether the context backend supports SamplerAddressMode::Decal.
impeller::RenderPipelineT::VertexShader
VertexShader_ VertexShader
Definition: pipeline.h:90
impeller::ColorFilterContents::MakeBlend
static std::shared_ptr< ColorFilterContents > MakeBlend(BlendMode blend_mode, FilterInput::Vector inputs, std::optional< Color > foreground_color=std::nullopt)
the [inputs] are expected to be in the order of dst, src.
Definition: color_filter_contents.cc:17
impeller::AtlasTextureContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the screen space bounding rectangle that this contents affects.
Definition: atlas_contents.cc:339
impeller::RenderPass::AddCommand
bool AddCommand(Command &&command)
Record a command for subsequent encoding to the underlying command buffer. No work is encoded into th...
Definition: render_pass.cc:46
impeller
Definition: aiks_context.cc:10
impeller::AtlasContents::GetSamplerDescriptor
const SamplerDescriptor & GetSamplerDescriptor() const
Definition: atlas_contents.cc:174
impeller::ContentContext
Definition: content_context.h:344
impeller::AtlasTextureContents::SetCoverage
void SetCoverage(Rect coverage)
Definition: atlas_contents.cc:348
impeller::TRect< Scalar >
impeller::BlendMode::kSource
@ kSource
impeller::ContentContext::GetGeometryColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGeometryColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:501
impeller::RenderPass::GetTransientsBuffer
HostBuffer & GetTransientsBuffer()
Definition: render_pass.cc:34
impeller::AtlasTextureContents::SetTexture
void SetTexture(std::shared_ptr< Texture > texture)
Definition: atlas_contents.cc:361
impeller::ContentContext::GetPorterDuffBlendPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetPorterDuffBlendPipeline(ContentContextOptions opts) const
Definition: content_context.h:511
vertex_buffer_builder.h
impeller::AtlasContents::GetColors
const std::vector< Color > & GetColors() const
Definition: atlas_contents.cc:186
impeller::AtlasBlenderKey::Hash::operator()
std::size_t operator()(const AtlasBlenderKey &key) const
Definition: atlas_contents.cc:74
impeller::SamplerAddressMode::kDecal
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
impeller::AtlasColorContents::SetSubAtlas
void SetSubAtlas(const std::shared_ptr< SubAtlasResult > &subatlas)
Definition: atlas_contents.cc:458