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