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 = pass.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  Command cmd;
240  cmd, SPrintF("DrawAtlas Blend (%s)", BlendModeToString(blend_mode_)));
241  cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer));
242  cmd.stencil_reference = entity.GetClipDepth();
243  auto options = OptionsFromPass(pass);
244  cmd.pipeline = renderer.GetPorterDuffBlendPipeline(options);
245 
246  FS::FragInfo frag_info;
247  VS::FrameInfo frame_info;
248 
249  auto dst_sampler_descriptor = sampler_descriptor_;
251  dst_sampler_descriptor.width_address_mode = SamplerAddressMode::kDecal;
252  dst_sampler_descriptor.height_address_mode = SamplerAddressMode::kDecal;
253  }
254  auto dst_sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler(
255  dst_sampler_descriptor);
256  FS::BindTextureSamplerDst(cmd, texture_, dst_sampler);
257  frame_info.texture_sampler_y_coord_scale = texture_->GetYCoordScale();
258 
259  frag_info.output_alpha = alpha_;
260  frag_info.input_alpha = 1.0;
261 
262  auto inverted_blend_mode =
263  InvertPorterDuffBlend(blend_mode_).value_or(BlendMode::kSource);
264  auto blend_coefficients =
265  kPorterDuffCoefficients[static_cast<int>(inverted_blend_mode)];
266  frag_info.src_coeff = blend_coefficients[0];
267  frag_info.src_coeff_dst_alpha = blend_coefficients[1];
268  frag_info.dst_coeff = blend_coefficients[2];
269  frag_info.dst_coeff_src_alpha = blend_coefficients[3];
270  frag_info.dst_coeff_src_color = blend_coefficients[4];
271 
272  FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info));
273 
274  frame_info.mvp = pass.GetOrthographicTransform() * entity.GetTransform();
275 
276  auto uniform_view = host_buffer.EmplaceUniform(frame_info);
277  VS::BindFrameInfo(cmd, uniform_view);
278 
279  return pass.AddCommand(std::move(cmd));
280  }
281 
282  // Advanced blends.
283 
284  auto sub_atlas = GenerateSubAtlas();
285  auto sub_coverage = Rect::MakeSize(sub_atlas->size);
286 
287  auto src_contents = std::make_shared<AtlasTextureContents>(*this);
288  src_contents->SetSubAtlas(sub_atlas);
289  src_contents->SetCoverage(sub_coverage);
290 
291  auto dst_contents = std::make_shared<AtlasColorContents>(*this);
292  dst_contents->SetSubAtlas(sub_atlas);
293  dst_contents->SetCoverage(sub_coverage);
294 
295  Entity untransformed_entity;
296  auto contents = ColorFilterContents::MakeBlend(
297  blend_mode_,
298  {FilterInput::Make(dst_contents), FilterInput::Make(src_contents)});
299  auto snapshot =
300  contents->RenderToSnapshot(renderer, // renderer
301  untransformed_entity, // entity
302  std::nullopt, // coverage_limit
303  std::nullopt, // sampler_descriptor
304  true, // msaa_enabled
305  "AtlasContents Snapshot"); // label
306  if (!snapshot.has_value()) {
307  return false;
308  }
309 
310  auto child_contents = AtlasTextureContents(*this);
311  child_contents.SetAlpha(alpha_);
312  child_contents.SetCoverage(coverage);
313  child_contents.SetTexture(snapshot.value().texture);
314  child_contents.SetUseDestination(true);
315  child_contents.SetSubAtlas(sub_atlas);
316  return child_contents.Render(renderer, entity, pass);
317 }
318 
319 // AtlasTextureContents
320 // ---------------------------------------------------------
321 
323  : parent_(parent) {}
324 
326 
328  const Entity& entity) const {
329  return coverage_.TransformBounds(entity.GetTransform());
330 }
331 
333  alpha_ = alpha;
334 }
335 
337  coverage_ = coverage;
338 }
339 
341  use_destination_ = value;
342 }
343 
345  const std::shared_ptr<SubAtlasResult>& subatlas) {
346  subatlas_ = subatlas;
347 }
348 
349 void AtlasTextureContents::SetTexture(std::shared_ptr<Texture> texture) {
350  texture_ = std::move(texture);
351 }
352 
354  const Entity& entity,
355  RenderPass& pass) const {
356  using VS = TextureFillVertexShader;
357  using FS = TextureFillFragmentShader;
358 
359  auto texture = texture_ ? texture_ : parent_.GetTexture();
360  if (texture == nullptr) {
361  return true;
362  }
363 
364  std::vector<Rect> texture_coords;
365  std::vector<Matrix> transforms;
366  if (subatlas_) {
367  texture_coords = use_destination_ ? subatlas_->result_texture_coords
368  : subatlas_->sub_texture_coords;
369  transforms = use_destination_ ? subatlas_->result_transforms
370  : subatlas_->sub_transforms;
371  } else {
372  texture_coords = parent_.GetTextureCoordinates();
373  transforms = parent_.GetTransforms();
374  }
375 
376  const Size texture_size(texture->GetSize());
378  vertex_builder.Reserve(texture_coords.size() * 6);
379  constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
380  for (size_t i = 0; i < texture_coords.size(); i++) {
381  auto sample_rect = texture_coords[i];
382  auto matrix = transforms[i];
383  auto points = sample_rect.GetPoints();
384  auto transformed_points =
385  Rect::MakeSize(sample_rect.GetSize()).GetTransformedPoints(matrix);
386 
387  for (size_t j = 0; j < 6; j++) {
388  VS::PerVertexData data;
389  data.position = transformed_points[indices[j]];
390  data.texture_coords = points[indices[j]] / texture_size;
391  vertex_builder.AppendVertex(data);
392  }
393  }
394 
395  if (!vertex_builder.HasVertices()) {
396  return true;
397  }
398 
399  Command cmd;
400  DEBUG_COMMAND_INFO(cmd, "AtlasTexture");
401 
402  auto& host_buffer = pass.GetTransientsBuffer();
403 
404  VS::FrameInfo frame_info;
405  frame_info.mvp = pass.GetOrthographicTransform() * entity.GetTransform();
406  frame_info.texture_sampler_y_coord_scale = texture->GetYCoordScale();
407  frame_info.alpha = alpha_;
408 
409  auto options = OptionsFromPassAndEntity(pass, entity);
410  cmd.pipeline = renderer.GetTexturePipeline(options);
411  cmd.stencil_reference = entity.GetClipDepth();
412  cmd.BindVertices(vertex_builder.CreateVertexBuffer(host_buffer));
413  VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info));
414  FS::BindTextureSampler(cmd, texture,
415  renderer.GetContext()->GetSamplerLibrary()->GetSampler(
416  parent_.GetSamplerDescriptor()));
417  return pass.AddCommand(std::move(cmd));
418 }
419 
420 // AtlasColorContents
421 // ---------------------------------------------------------
422 
424  : parent_(parent) {}
425 
427 
429  const Entity& entity) const {
430  return coverage_.TransformBounds(entity.GetTransform());
431 }
432 
434  alpha_ = alpha;
435 }
436 
438  coverage_ = coverage;
439 }
440 
442  const std::shared_ptr<SubAtlasResult>& subatlas) {
443  subatlas_ = subatlas;
444 }
445 
447  const Entity& entity,
448  RenderPass& pass) const {
451 
452  std::vector<Rect> texture_coords;
453  std::vector<Matrix> transforms;
454  std::vector<Color> colors;
455  if (subatlas_) {
456  texture_coords = subatlas_->sub_texture_coords;
457  colors = subatlas_->sub_colors;
458  transforms = subatlas_->sub_transforms;
459  } else {
460  texture_coords = parent_.GetTextureCoordinates();
461  transforms = parent_.GetTransforms();
462  colors = parent_.GetColors();
463  }
464 
466  vertex_builder.Reserve(texture_coords.size() * 6);
467  constexpr size_t indices[6] = {0, 1, 2, 1, 2, 3};
468  for (size_t i = 0; i < texture_coords.size(); i++) {
469  auto sample_rect = texture_coords[i];
470  auto matrix = transforms[i];
471  auto transformed_points =
472  Rect::MakeSize(sample_rect.GetSize()).GetTransformedPoints(matrix);
473 
474  for (size_t j = 0; j < 6; j++) {
475  VS::PerVertexData data;
476  data.position = transformed_points[indices[j]];
477  data.color = colors[i].Premultiply();
478  vertex_builder.AppendVertex(data);
479  }
480  }
481 
482  if (!vertex_builder.HasVertices()) {
483  return true;
484  }
485 
486  Command cmd;
487  DEBUG_COMMAND_INFO(cmd, "AtlasColors");
488 
489  auto& host_buffer = pass.GetTransientsBuffer();
490 
491  VS::FrameInfo frame_info;
492  frame_info.mvp = pass.GetOrthographicTransform() * entity.GetTransform();
493 
494  FS::FragInfo frag_info;
495  frag_info.alpha = alpha_;
496 
497  auto opts = OptionsFromPassAndEntity(pass, entity);
498  opts.blend_mode = BlendMode::kSourceOver;
499  cmd.pipeline = renderer.GetGeometryColorPipeline(opts);
500  cmd.stencil_reference = entity.GetClipDepth();
501  cmd.BindVertices(vertex_builder.CreateVertexBuffer(host_buffer));
502  VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info));
503  FS::BindFragInfo(cmd, host_buffer.EmplaceUniform(frag_info));
504  return pass.AddCommand(std::move(cmd));
505 }
506 
507 } // namespace impeller
impeller::ContentContext::GetTexturePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTexturePipeline(ContentContextOptions opts) const
Definition: content_context.h:415
impeller::AtlasContents::SetTextureCoordinates
void SetTextureCoordinates(std::vector< Rect > texture_coords)
Definition: atlas_contents.cc:41
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:92
DEBUG_COMMAND_INFO
#define DEBUG_COMMAND_INFO(obj, arg)
Definition: command.h:28
impeller::BlendModeToString
const char * BlendModeToString(BlendMode blend_mode)
Definition: color.cc:47
impeller::AtlasColorContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: atlas_contents.cc:433
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:34
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:264
formats.h
impeller::AtlasTextureContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: atlas_contents.cc:353
impeller::InvertPorterDuffBlend
std::optional< BlendMode > InvertPorterDuffBlend(BlendMode blend_mode)
Definition: blend_filter_contents.cc:26
impeller::Vector2
Point Vector2
Definition: point.h:312
impeller::RenderPipelineT::FragmentShader
FragmentShader_ FragmentShader
Definition: pipeline.h:93
impeller::AtlasColorContents::AtlasColorContents
AtlasColorContents(const AtlasContents &parent)
Definition: atlas_contents.cc:423
impeller::TRect::GetX
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
Definition: rect.h:163
impeller::TRect::GetHeight
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition: rect.h:175
impeller::AtlasColorContents::SetCoverage
void SetCoverage(Rect coverage)
Definition: atlas_contents.cc:437
impeller::Matrix::MakeTranslation
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition: matrix.h:95
impeller::RenderPass::GetOrthographicTransform
const Matrix & GetOrthographicTransform() const
Definition: render_pass.cc:51
impeller::BlendMode::kModulate
@ kModulate
impeller::VertexBufferBuilder::HasVertices
bool HasVertices() const
Definition: vertex_buffer_builder.h:52
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:15
impeller::AtlasTextureContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: atlas_contents.cc:332
impeller::Entity
Definition: entity.h:21
impeller::OptionsFromPassAndEntity
ContentContextOptions OptionsFromPassAndEntity(const RenderPass &pass, const Entity &entity)
Definition: contents.cc:28
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:253
impeller::BlendMode::kClear
@ kClear
impeller::ContentContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: content_context.cc:479
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:171
impeller::AtlasBlenderKey
Definition: atlas_contents.cc:62
impeller::AtlasContents::GetTransforms
const std::vector< Matrix > & GetTransforms() const
Definition: atlas_contents.cc:173
impeller::Command::BindVertices
bool BindVertices(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
Definition: command.cc:15
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:446
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:428
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:344
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:426
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:29
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:93
atlas_contents.h
impeller::Command::stencil_reference
uint32_t stencil_reference
Definition: command.h:122
content_context.h
impeller::ContentContext::GetDeviceCapabilities
const Capabilities & GetDeviceCapabilities() const
Definition: content_context.cc:483
impeller::AtlasTextureContents::SetUseDestination
void SetUseDestination(bool value)
Definition: atlas_contents.cc:340
impeller::TRect< Scalar >::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:44
impeller::AtlasTextureContents::~AtlasTextureContents
~AtlasTextureContents() override
Definition: atlas_contents.cc:325
impeller::AtlasContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: atlas_contents.cc:50
impeller::AtlasTextureContents::AtlasTextureContents
AtlasTextureContents(const AtlasContents &parent)
Definition: atlas_contents.cc:322
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:302
color.h
impeller::AtlasContents::SetTexture
void SetTexture(std::shared_ptr< Texture > texture)
Definition: atlas_contents.cc:28
blend_filter_contents.h
impeller::Command::pipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > pipeline
Definition: command.h:96
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:92
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:327
impeller::TRect::GetY
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
Definition: rect.h:167
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:67
impeller
Definition: aiks_context.cc:10
impeller::AtlasContents::GetSamplerDescriptor
const SamplerDescriptor & GetSamplerDescriptor() const
Definition: atlas_contents.cc:169
impeller::ContentContext
Definition: content_context.h:332
impeller::AtlasTextureContents::SetCoverage
void SetCoverage(Rect coverage)
Definition: atlas_contents.cc:336
impeller::TRect< Scalar >
impeller::ContentContext::GetGeometryColorPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetGeometryColorPipeline(ContentContextOptions opts) const
Definition: content_context.h:506
impeller::RenderPass::GetTransientsBuffer
HostBuffer & GetTransientsBuffer()
Definition: render_pass.cc:55
impeller::AtlasTextureContents::SetTexture
void SetTexture(std::shared_ptr< Texture > texture)
Definition: atlas_contents.cc:349
impeller::BlendMode::kSourceOver
@ kSourceOver
impeller::ContentContext::GetPorterDuffBlendPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetPorterDuffBlendPipeline(ContentContextOptions opts) const
Definition: content_context.h:516
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:441