Flutter Impeller
gaussian_blur_filter_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 
6 
7 #include <cmath>
8 
10 #include "impeller/entity/texture_fill.frag.h"
11 #include "impeller/entity/texture_fill.vert.h"
15 
16 namespace impeller {
17 
20 
21 namespace {
22 
23 SamplerDescriptor MakeSamplerDescriptor(MinMagFilter filter,
24  SamplerAddressMode address_mode) {
25  SamplerDescriptor sampler_desc;
26  sampler_desc.min_filter = filter;
27  sampler_desc.mag_filter = filter;
28  sampler_desc.width_address_mode = address_mode;
29  sampler_desc.height_address_mode = address_mode;
30  return sampler_desc;
31 }
32 
33 template <typename T>
34 void BindVertices(Command& cmd,
35  HostBuffer& host_buffer,
36  std::initializer_list<typename T::PerVertexData>&& vertices) {
38  vtx_builder.AddVertices(vertices);
39  cmd.BindVertices(vtx_builder.CreateVertexBuffer(host_buffer));
40 }
41 
42 void SetTileMode(SamplerDescriptor* descriptor,
43  const ContentContext& renderer,
44  Entity::TileMode tile_mode) {
45  switch (tile_mode) {
50  }
51  break;
55  break;
59  break;
63  break;
64  }
65 }
66 
67 /// Makes a subpass that will render the scaled down input and add the
68 /// transparent gutter required for the blur halo.
69 fml::StatusOr<RenderTarget> MakeDownsampleSubpass(
70  const ContentContext& renderer,
71  std::shared_ptr<Texture> input_texture,
72  const SamplerDescriptor& sampler_descriptor,
73  const Quad& uvs,
74  const ISize& subpass_size,
75  Entity::TileMode tile_mode) {
76  ContentContext::SubpassCallback subpass_callback =
77  [&](const ContentContext& renderer, RenderPass& pass) {
78  HostBuffer& host_buffer = pass.GetTransientsBuffer();
79 
80  Command cmd;
81  DEBUG_COMMAND_INFO(cmd, "Gaussian blur downsample");
82  auto pipeline_options = OptionsFromPass(pass);
83  pipeline_options.primitive_type = PrimitiveType::kTriangleStrip;
84  cmd.pipeline = renderer.GetTexturePipeline(pipeline_options);
85 
86  TextureFillVertexShader::FrameInfo frame_info;
87  frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));
88  frame_info.texture_sampler_y_coord_scale = 1.0;
89  frame_info.alpha = 1.0;
90 
91  BindVertices<TextureFillVertexShader>(cmd, host_buffer,
92  {
93  {Point(0, 0), uvs[0]},
94  {Point(1, 0), uvs[1]},
95  {Point(0, 1), uvs[2]},
96  {Point(1, 1), uvs[3]},
97  });
98 
99  SamplerDescriptor linear_sampler_descriptor = sampler_descriptor;
100  SetTileMode(&linear_sampler_descriptor, renderer, tile_mode);
101  linear_sampler_descriptor.mag_filter = MinMagFilter::kLinear;
102  linear_sampler_descriptor.min_filter = MinMagFilter::kLinear;
103  TextureFillVertexShader::BindFrameInfo(
104  cmd, host_buffer.EmplaceUniform(frame_info));
105  TextureFillFragmentShader::BindTextureSampler(
106  cmd, input_texture,
107  renderer.GetContext()->GetSamplerLibrary()->GetSampler(
108  linear_sampler_descriptor));
109 
110  pass.AddCommand(std::move(cmd));
111 
112  return true;
113  };
114  fml::StatusOr<RenderTarget> render_target = renderer.MakeSubpass(
115  "Gaussian Blur Filter", subpass_size, subpass_callback);
116  return render_target;
117 }
118 
119 fml::StatusOr<RenderTarget> MakeBlurSubpass(
120  const ContentContext& renderer,
121  const RenderTarget& input_pass,
122  const SamplerDescriptor& sampler_descriptor,
123  Entity::TileMode tile_mode,
124  const BlurParameters& blur_info,
125  std::optional<RenderTarget> destination_target,
126  const Quad& blur_uvs) {
127  if (blur_info.blur_sigma < kEhCloseEnough) {
128  return input_pass;
129  }
130 
131  std::shared_ptr<Texture> input_texture = input_pass.GetRenderTargetTexture();
132 
133  // TODO(gaaclarke): This blurs the whole image, but because we know the clip
134  // region we could focus on just blurring that.
135  ISize subpass_size = input_texture->GetSize();
136  ContentContext::SubpassCallback subpass_callback =
137  [&](const ContentContext& renderer, RenderPass& pass) {
138  GaussianBlurVertexShader::FrameInfo frame_info{
139  .mvp = Matrix::MakeOrthographic(ISize(1, 1)),
140  .texture_sampler_y_coord_scale = 1.0};
141 
142  HostBuffer& host_buffer = pass.GetTransientsBuffer();
143 
144  Command cmd;
145  ContentContextOptions options = OptionsFromPass(pass);
147 
148  if (tile_mode == Entity::TileMode::kDecal &&
149  !renderer.GetDeviceCapabilities()
151  cmd.pipeline = renderer.GetKernelDecalPipeline(options);
152  } else {
153  cmd.pipeline = renderer.GetKernelPipeline(options);
154  }
155 
156  BindVertices<GaussianBlurVertexShader>(cmd, host_buffer,
157  {
158  {blur_uvs[0], blur_uvs[0]},
159  {blur_uvs[1], blur_uvs[1]},
160  {blur_uvs[2], blur_uvs[2]},
161  {blur_uvs[3], blur_uvs[3]},
162  });
163 
164  SamplerDescriptor linear_sampler_descriptor = sampler_descriptor;
165  linear_sampler_descriptor.mag_filter = MinMagFilter::kLinear;
166  linear_sampler_descriptor.min_filter = MinMagFilter::kLinear;
167  GaussianBlurFragmentShader::BindTextureSampler(
168  cmd, input_texture,
169  renderer.GetContext()->GetSamplerLibrary()->GetSampler(
170  linear_sampler_descriptor));
171  GaussianBlurVertexShader::BindFrameInfo(
172  cmd, host_buffer.EmplaceUniform(frame_info));
173  GaussianBlurFragmentShader::BindKernelSamples(
174  cmd, host_buffer.EmplaceUniform(GenerateBlurInfo(blur_info)));
175  pass.AddCommand(std::move(cmd));
176 
177  return true;
178  };
179  if (destination_target.has_value()) {
180  return renderer.MakeSubpass("Gaussian Blur Filter",
181  destination_target.value(), subpass_callback);
182  } else {
183  return renderer.MakeSubpass("Gaussian Blur Filter", subpass_size,
184  subpass_callback);
185  }
186 }
187 
188 /// Returns `rect` relative to `reference`, where Rect::MakeXYWH(0,0,1,1) will
189 /// be returned when `rect` == `reference`.
190 Rect MakeReferenceUVs(const Rect& reference, const Rect& rect) {
191  Rect result = Rect::MakeOriginSize(rect.GetOrigin() - reference.GetOrigin(),
192  rect.GetSize());
193  return result.Scale(1.0f / Vector2(reference.GetSize()));
194 }
195 
196 } // namespace
197 
199  Scalar sigma_x,
200  Scalar sigma_y,
201  Entity::TileMode tile_mode)
202  : sigma_x_(sigma_x), sigma_y_(sigma_y), tile_mode_(tile_mode) {}
203 
204 // This value was extracted from Skia, see:
205 // * https://github.com/google/skia/blob/d29cc3fe182f6e8a8539004a6a4ee8251677a6fd/src/gpu/ganesh/GrBlurUtils.cpp#L2561-L2576
206 // * https://github.com/google/skia/blob/d29cc3fe182f6e8a8539004a6a4ee8251677a6fd/src/gpu/BlurUtils.h#L57
208  if (sigma <= 4) {
209  return 1.0;
210  }
211  return 4.0 / sigma;
212 };
213 
215  const Matrix& effect_transform,
216  const Rect& output_limit) const {
217  Vector2 scaled_sigma = {ScaleSigma(sigma_x_), ScaleSigma(sigma_y_)};
218  Vector2 blur_radius = {CalculateBlurRadius(scaled_sigma.x),
219  CalculateBlurRadius(scaled_sigma.y)};
220  Vector3 blur_radii =
221  effect_transform.Basis() * Vector3{blur_radius.x, blur_radius.y, 0.0};
222  return output_limit.Expand(Point(blur_radii.x, blur_radii.y));
223 }
224 
226  const FilterInput::Vector& inputs,
227  const Entity& entity,
228  const Matrix& effect_transform) const {
229  if (inputs.empty()) {
230  return {};
231  }
232 
233  std::optional<Rect> input_coverage = inputs[0]->GetCoverage(entity);
234  if (!input_coverage.has_value()) {
235  return {};
236  }
237 
238  Vector2 scaled_sigma = {ScaleSigma(sigma_x_), ScaleSigma(sigma_y_)};
239  Vector2 blur_radius = {CalculateBlurRadius(scaled_sigma.x),
240  CalculateBlurRadius(scaled_sigma.y)};
241  Vector3 blur_radii =
242  (inputs[0]->GetTransform(entity).Basis() * effect_transform.Basis() *
243  Vector3{blur_radius.x, blur_radius.y, 0.0})
244  .Abs();
245  return input_coverage.value().Expand(Point(blur_radii.x, blur_radii.y));
246 }
247 
248 std::optional<Entity> GaussianBlurFilterContents::RenderFilter(
249  const FilterInput::Vector& inputs,
250  const ContentContext& renderer,
251  const Entity& entity,
252  const Matrix& effect_transform,
253  const Rect& coverage,
254  const std::optional<Rect>& coverage_hint) const {
255  if (inputs.empty()) {
256  return std::nullopt;
257  }
258 
259  Vector2 scaled_sigma = {ScaleSigma(sigma_x_), ScaleSigma(sigma_y_)};
260  Vector2 blur_radius = {CalculateBlurRadius(scaled_sigma.x),
261  CalculateBlurRadius(scaled_sigma.y)};
262  Vector2 padding(ceil(blur_radius.x), ceil(blur_radius.y));
263  Vector2 local_padding =
264  (entity.GetTransform().Basis() * effect_transform.Basis() * padding)
265  .Abs();
266 
267  // Apply as much of the desired padding as possible from the source. This may
268  // be ignored so must be accounted for in the downsample pass by adding a
269  // transparent gutter.
270  std::optional<Rect> expanded_coverage_hint;
271  if (coverage_hint.has_value()) {
272  expanded_coverage_hint = coverage_hint->Expand(local_padding);
273  }
274 
275  std::optional<Snapshot> input_snapshot =
276  inputs[0]->GetSnapshot("GaussianBlur", renderer, entity,
277  /*coverage_limit=*/expanded_coverage_hint);
278  if (!input_snapshot.has_value()) {
279  return std::nullopt;
280  }
281 
282  if (scaled_sigma.x < kEhCloseEnough && scaled_sigma.y < kEhCloseEnough) {
283  return Entity::FromSnapshot(input_snapshot.value(), entity.GetBlendMode(),
284  entity.GetClipDepth()); // No blur to render.
285  }
286 
287  Scalar desired_scalar =
288  std::min(CalculateScale(scaled_sigma.x), CalculateScale(scaled_sigma.y));
289  // TODO(jonahwilliams): If desired_scalar is 1.0 and we fully acquired the
290  // gutter from the expanded_coverage_hint, we can skip the downsample pass.
291  // pass.
292  Vector2 downsample_scalar(desired_scalar, desired_scalar);
293  Rect source_rect = Rect::MakeSize(input_snapshot->texture->GetSize());
294  Rect source_rect_padded = source_rect.Expand(padding);
295  Matrix padding_snapshot_adjustment = Matrix::MakeTranslation(-padding);
296  // TODO(gaaclarke): The padding could be removed if we know it's not needed or
297  // resized to account for the expanded_clip_coverage. There doesn't appear
298  // to be the math to make those calculations though. The following
299  // optimization works, but causes a shimmer as a result of
300  // https://github.com/flutter/flutter/issues/140193 so it isn't applied.
301  //
302  // !input_snapshot->GetCoverage()->Expand(-local_padding)
303  // .Contains(coverage_hint.value()))
304  Vector2 downsampled_size = source_rect_padded.GetSize() * downsample_scalar;
305  ISize subpass_size =
306  ISize(round(downsampled_size.x), round(downsampled_size.y));
307  Vector2 effective_scalar =
308  Vector2(subpass_size) / source_rect_padded.GetSize();
309 
310  Quad uvs = CalculateUVs(inputs[0], entity, source_rect_padded,
311  input_snapshot->texture->GetSize());
312 
313  fml::StatusOr<RenderTarget> pass1_out = MakeDownsampleSubpass(
314  renderer, input_snapshot->texture, input_snapshot->sampler_descriptor,
315  uvs, subpass_size, tile_mode_);
316 
317  if (!pass1_out.ok()) {
318  return std::nullopt;
319  }
320 
321  Vector2 pass1_pixel_size =
322  1.0 / Vector2(pass1_out.value().GetRenderTargetTexture()->GetSize());
323 
324  std::optional<Rect> input_snapshot_coverage = input_snapshot->GetCoverage();
325  Quad blur_uvs = {Point(0, 0), Point(1, 0), Point(0, 1), Point(1, 1)};
326  if (expanded_coverage_hint.has_value() &&
327  input_snapshot_coverage.has_value() &&
328  // TODO(https://github.com/flutter/flutter/issues/140890): Remove this
329  // condition. There is some flaw in coverage stopping us from using this
330  // today. I attempted to use source coordinates to calculate the uvs,
331  // but that didn't work either.
332  input_snapshot.has_value() &&
333  input_snapshot.value().transform.IsTranslationScaleOnly()) {
334  // Only process the uvs where the blur is happening, not the whole texture.
335  std::optional<Rect> uvs = MakeReferenceUVs(input_snapshot_coverage.value(),
336  expanded_coverage_hint.value())
337  .Intersection(Rect::MakeSize(Size(1, 1)));
338  FML_DCHECK(uvs.has_value());
339  if (uvs.has_value()) {
340  blur_uvs[0] = uvs->GetLeftTop();
341  blur_uvs[1] = uvs->GetRightTop();
342  blur_uvs[2] = uvs->GetLeftBottom();
343  blur_uvs[3] = uvs->GetRightBottom();
344  }
345  }
346 
347  fml::StatusOr<RenderTarget> pass2_out = MakeBlurSubpass(
348  renderer, /*input_pass=*/pass1_out.value(),
349  input_snapshot->sampler_descriptor, tile_mode_,
350  BlurParameters{
351  .blur_uv_offset = Point(0.0, pass1_pixel_size.y),
352  .blur_sigma = scaled_sigma.y * effective_scalar.y,
353  .blur_radius =
354  static_cast<int>(std::round(blur_radius.y * effective_scalar.y)),
355  .step_size = 1,
356  },
357  /*destination_target=*/std::nullopt, blur_uvs);
358 
359  if (!pass2_out.ok()) {
360  return std::nullopt;
361  }
362 
363  // Only ping pong if the first pass actually created a render target.
364  auto pass3_destination = pass2_out.value().GetRenderTargetTexture() !=
365  pass1_out.value().GetRenderTargetTexture()
366  ? std::optional<RenderTarget>(pass1_out.value())
367  : std::optional<RenderTarget>(std::nullopt);
368 
369  fml::StatusOr<RenderTarget> pass3_out = MakeBlurSubpass(
370  renderer, /*input_pass=*/pass2_out.value(),
371  input_snapshot->sampler_descriptor, tile_mode_,
372  BlurParameters{
373  .blur_uv_offset = Point(pass1_pixel_size.x, 0.0),
374  .blur_sigma = scaled_sigma.x * effective_scalar.x,
375  .blur_radius =
376  static_cast<int>(std::round(blur_radius.x * effective_scalar.x)),
377  .step_size = 1,
378  },
379  pass3_destination, blur_uvs);
380 
381  if (!pass3_out.ok()) {
382  return std::nullopt;
383  }
384 
385  // The ping-pong approach requires that each render pass output has the same
386  // size.
387  FML_DCHECK((pass1_out.value().GetRenderTargetSize() ==
388  pass2_out.value().GetRenderTargetSize()) &&
389  (pass2_out.value().GetRenderTargetSize() ==
390  pass3_out.value().GetRenderTargetSize()));
391 
392  SamplerDescriptor sampler_desc = MakeSamplerDescriptor(
394 
395  return Entity::FromSnapshot(
396  Snapshot{.texture = pass3_out.value().GetRenderTargetTexture(),
397  .transform = input_snapshot->transform *
398  padding_snapshot_adjustment *
399  Matrix::MakeScale(1 / effective_scalar),
400  .sampler_descriptor = sampler_desc,
401  .opacity = input_snapshot->opacity},
402  entity.GetBlendMode(), entity.GetClipDepth());
403 }
404 
406  return static_cast<Radius>(Sigma(sigma)).radius;
407 }
408 
410  const std::shared_ptr<FilterInput>& filter_input,
411  const Entity& entity,
412  const Rect& source_rect,
413  const ISize& texture_size) {
414  Matrix input_transform = filter_input->GetLocalTransform(entity);
415  Quad coverage_quad = source_rect.GetTransformedPoints(input_transform);
416 
417  Matrix uv_transform = Matrix::MakeScale(
418  {1.0f / texture_size.width, 1.0f / texture_size.height, 1.0f});
419  return uv_transform.Transform(coverage_quad);
420 }
421 
422 // This function was calculated by observing Skia's behavior. Its blur at 500
423 // seemed to be 0.15. Since we clamp at 500 I solved the quadratic equation
424 // that puts the minima there and a f(0)=1.
426  // Limit the kernel size to 1000x1000 pixels, like Skia does.
427  Scalar clamped = std::min(sigma, 500.0f);
428  constexpr Scalar a = 3.4e-06;
429  constexpr Scalar b = -3.4e-3;
430  constexpr Scalar c = 1.f;
431  Scalar scalar = c + b * clamped + a * clamped * clamped;
432  return clamped * scalar;
433 }
434 
435 KernelPipeline::FragmentShader::KernelSamples GenerateBlurInfo(
436  BlurParameters parameters) {
437  KernelPipeline::FragmentShader::KernelSamples result;
438  result.sample_count =
439  ((2 * parameters.blur_radius) / parameters.step_size) + 1;
440  FML_CHECK(result.sample_count < 24);
441 
442  Scalar tally = 0.0f;
443  for (int i = 0; i < result.sample_count; ++i) {
444  int x = (i * parameters.step_size) - parameters.blur_radius;
445  result.samples[i] = KernelPipeline::FragmentShader::KernelSample{
446  .uv_offset = parameters.blur_uv_offset * x,
447  .coefficient = expf(-0.5f * (x * x) /
448  (parameters.blur_sigma * parameters.blur_sigma)) /
449  (sqrtf(2.0f * M_PI) * parameters.blur_sigma),
450  };
451  tally += result.samples[i].coefficient;
452  }
453 
454  // Make sure everything adds up to 1.
455  for (auto& sample : result.samples) {
456  sample.coefficient /= tally;
457  }
458 
459  return result;
460 }
461 
462 } // namespace impeller
impeller::ContentContext::GetTexturePipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetTexturePipeline(ContentContextOptions opts) const
Definition: content_context.h:415
impeller::Entity::TileMode::kClamp
@ kClamp
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::ContentContext::GetKernelDecalPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetKernelDecalPipeline(ContentContextOptions opts) const
Definition: content_context.h:456
impeller::TPoint::y
Type y
Definition: point.h:26
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::Entity::GetTransform
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition: entity.cc:49
impeller::BlurParameters::blur_uv_offset
Point blur_uv_offset
Definition: gaussian_blur_filter_contents.h:15
impeller::kEhCloseEnough
constexpr float kEhCloseEnough
Definition: constants.h:56
impeller::SamplerAddressMode
SamplerAddressMode
Definition: formats.h:420
impeller::HostBuffer
Definition: host_buffer.h:20
impeller::Entity::TileMode::kDecal
@ kDecal
impeller::ContentContext::MakeSubpass
fml::StatusOr< RenderTarget > MakeSubpass(const std::string &label, ISize texture_size, const SubpassCallback &subpass_callback, bool msaa_enabled=true) const
Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing t...
Definition: content_context.cc:410
impeller::Vector2
Point Vector2
Definition: point.h:312
impeller::RenderPipelineT::FragmentShader
FragmentShader_ FragmentShader
Definition: pipeline.h:93
impeller::VertexBufferBuilder::AddVertices
VertexBufferBuilder & AddVertices(std::initializer_list< VertexType_ > vertices)
Definition: vertex_buffer_builder.h:70
impeller::SamplerAddressMode::kClampToEdge
@ kClampToEdge
gaussian_blur_filter_contents.h
impeller::Size
TSize< Scalar > Size
Definition: size.h:137
impeller::GaussianBlurFilterContents::CalculateBlurRadius
static Scalar CalculateBlurRadius(Scalar sigma)
Definition: gaussian_blur_filter_contents.cc:405
impeller::Entity::TileMode::kRepeat
@ kRepeat
impeller::Matrix::MakeTranslation
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition: matrix.h:95
impeller::ContentContext::GetKernelPipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > GetKernelPipeline(ContentContextOptions opts) const
Definition: content_context.h:461
impeller::GenerateBlurInfo
KernelPipeline::FragmentShader::KernelSamples GenerateBlurInfo(BlurParameters parameters)
Definition: gaussian_blur_filter_contents.cc:435
impeller::TRect::GetOrigin
constexpr TPoint< Type > GetOrigin() const
Returns the upper left corner of the rectangle as specified when it was constructed.
Definition: rect.h:154
impeller::Vector3::x
Scalar x
Definition: vector.h:23
impeller::Entity::TileMode::kMirror
@ kMirror
impeller::SamplerDescriptor::mag_filter
MinMagFilter mag_filter
Definition: sampler_descriptor.h:17
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:15
impeller::GaussianBlurFilterContents::GetFilterCoverage
std::optional< Rect > GetFilterCoverage(const FilterInput::Vector &inputs, const Entity &entity, const Matrix &effect_transform) const override
Internal utility method for |GetLocalCoverage| that computes the output coverage of this filter acros...
Definition: gaussian_blur_filter_contents.cc:225
impeller::BlurParameters::blur_radius
int blur_radius
Definition: gaussian_blur_filter_contents.h:17
impeller::Entity
Definition: entity.h:21
command.h
impeller::Matrix::Basis
constexpr Matrix Basis() const
The Matrix without its w components (without translation).
Definition: matrix.h:224
impeller::TSize< int64_t >
impeller::PrimitiveType::kTriangleStrip
@ kTriangleStrip
impeller::SamplerDescriptor::min_filter
MinMagFilter min_filter
Definition: sampler_descriptor.h:16
impeller::Point
TPoint< Scalar > Point
Definition: point.h:308
impeller::Quad
std::array< Point, 4 > Quad
Definition: point.h:313
render_pass.h
impeller::RenderTarget::GetRenderTargetTexture
std::shared_ptr< Texture > GetRenderTargetTexture() const
Definition: render_target.cc:155
impeller::GaussianBlurFilterContents::GaussianBlurFilterContents
GaussianBlurFilterContents(Scalar sigma_x, Scalar sigma_y, Entity::TileMode tile_mode)
Definition: gaussian_blur_filter_contents.cc:198
impeller::Radius
For convolution filters, the "radius" is the size of the convolution kernel to use on the local space...
Definition: sigma.h:48
impeller::TRect::GetTransformedPoints
constexpr std::array< TPoint< T >, 4 > GetTransformedPoints(const Matrix &transform) const
Definition: rect.h:253
impeller::ContentContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: content_context.cc:479
impeller::VertexBufferBuilder
Definition: vertex_buffer_builder.h:24
impeller::MinMagFilter::kLinear
@ kLinear
impeller::GaussianBlurFilterContents::GetFilterSourceCoverage
std::optional< Rect > GetFilterSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const override
Internal utility method for |GetSourceCoverage| that computes the inverse effect of this transform on...
Definition: gaussian_blur_filter_contents.cc:214
impeller::TRect< Scalar >::MakeOriginSize
constexpr static TRect MakeOriginSize(const TPoint< Type > &origin, const TSize< Type > &size)
Definition: rect.h:38
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::BlurParameters::step_size
int step_size
Definition: gaussian_blur_filter_contents.h:18
impeller::Sigma
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
Definition: sigma.h:32
impeller::TRect::Scale
constexpr TRect Scale(Type scale) const
Definition: rect.h:108
impeller::MinMagFilter
MinMagFilter
Definition: formats.h:404
impeller::RenderTarget
Definition: render_target.h:49
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:488
impeller::GaussianBlurFragmentShader
KernelPipeline::FragmentShader GaussianBlurFragmentShader
Definition: gaussian_blur_filter_contents.cc:19
impeller::Vector3::y
Scalar y
Definition: vector.h:24
impeller::BlurParameters
Definition: gaussian_blur_filter_contents.h:14
impeller::Entity::TileMode
TileMode
Definition: entity.h:40
impeller::TSize::width
Type width
Definition: size.h:22
impeller::Entity::GetBlendMode
BlendMode GetBlendMode() const
Definition: entity.cc:105
impeller::Matrix::Transform
constexpr Quad Transform(const Quad &quad) const
Definition: matrix.h:449
impeller::TPoint::x
Type x
Definition: point.h:25
impeller::ContentContextOptions::primitive_type
PrimitiveType primitive_type
Definition: content_context.h:281
impeller::VertexBufferBuilder::CreateVertexBuffer
VertexBuffer CreateVertexBuffer(HostBuffer &host_buffer) const
Definition: vertex_buffer_builder.h:84
impeller::ContentContext::SubpassCallback
std::function< bool(const ContentContext &, RenderPass &)> SubpassCallback
Definition: content_context.h:708
impeller::ISize
TSize< int64_t > ISize
Definition: size.h:138
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:29
impeller::Entity::GetClipDepth
uint32_t GetClipDepth() const
Definition: entity.cc:93
content_context.h
impeller::TRect::GetSize
constexpr TSize< Type > GetSize() const
Returns the size of the rectangle as specified when it was constructed and which may be negative in e...
Definition: rect.h:159
impeller::ContentContext::GetDeviceCapabilities
const Capabilities & GetDeviceCapabilities() const
Definition: content_context.cc:483
impeller::SamplerAddressMode::kMirror
@ kMirror
impeller::TRect< Scalar >::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:44
std
Definition: comparable.h:95
impeller::TPoint< Scalar >
impeller::HostBuffer::EmplaceUniform
BufferView EmplaceUniform(const UniformType &uniform)
Emplace uniform data onto the host buffer. Ensure that backend specific uniform alignment requirement...
Definition: host_buffer.h:41
impeller::Matrix::MakeOrthographic
static constexpr Matrix MakeOrthographic(TSize< T > size)
Definition: matrix.h:459
impeller::GaussianBlurFilterContents::CalculateScale
static Scalar CalculateScale(Scalar sigma)
Definition: gaussian_blur_filter_contents.cc:207
impeller::TSize::height
Type height
Definition: size.h:23
impeller::GaussianBlurFilterContents::CalculateUVs
static Quad CalculateUVs(const std::shared_ptr< FilterInput > &filter_input, const Entity &entity, const Rect &source_rect, const ISize &texture_size)
Definition: gaussian_blur_filter_contents.cc:409
impeller::Command::pipeline
std::shared_ptr< Pipeline< PipelineDescriptor > > pipeline
Definition: command.h:96
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
impeller::Entity::FromSnapshot
static std::optional< Entity > FromSnapshot(const std::optional< Snapshot > &snapshot, BlendMode blend_mode=BlendMode::kSourceOver, uint32_t clip_depth=0)
Create an entity that can be used to render a given snapshot.
Definition: entity.cc:21
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::ContentContextOptions
Definition: content_context.h:276
impeller::SamplerDescriptor::height_address_mode
SamplerAddressMode height_address_mode
Definition: sampler_descriptor.h:21
impeller
Definition: aiks_context.cc:10
impeller::Matrix::MakeScale
static constexpr Matrix MakeScale(const Vector3 &s)
Definition: matrix.h:104
impeller::BlurParameters::blur_sigma
Scalar blur_sigma
Definition: gaussian_blur_filter_contents.h:16
impeller::ContentContext
Definition: content_context.h:332
impeller::TRect
Definition: rect.h:22
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::Vector3
Definition: vector.h:20
impeller::TRect::Expand
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
Definition: rect.h:373
vertex_buffer_builder.h
impeller::GaussianBlurFilterContents::ScaleSigma
static Scalar ScaleSigma(Scalar sigma)
Definition: gaussian_blur_filter_contents.cc:425
impeller::SamplerAddressMode::kRepeat
@ kRepeat
impeller::GaussianBlurVertexShader
KernelPipeline::VertexShader GaussianBlurVertexShader
Definition: gaussian_blur_filter_contents.cc:18
impeller::SamplerAddressMode::kDecal
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...