13#include "impeller/entity/texture_downsample.frag.h"
14#include "impeller/entity/texture_downsample_bounded.frag.h"
15#include "impeller/entity/texture_fill.frag.h"
16#include "impeller/entity/texture_fill.vert.h"
28constexpr Scalar kMaxSigma = 500.0f;
66 return Vector2(std::clamp(vec2.
x, min, max),
67 std::clamp(vec2.
y, min, max));
94BlurInfo CalculateBlurInfo(
const Entity& entity,
95 const Matrix& effect_transform,
102 ExtractScale(entity.GetTransform().Basis());
104 Vector2(entity.GetTransform().m[12], entity.GetTransform().m[13]);
129std::optional<Snapshot> GetSnapshot(
const std::shared_ptr<FilterInput>&
input,
130 const ContentContext& renderer,
131 const Entity& entity,
132 const std::optional<Rect>& coverage_hint) {
133 std::optional<Snapshot> input_snapshot =
134 input->GetSnapshot(
"GaussianBlur", renderer, entity,
136 if (!input_snapshot.has_value()) {
140 return input_snapshot;
145Rect MakeReferenceUVs(
const Rect& reference,
const Rect& rect) {
148 return result.Scale(1.0f /
Vector2(reference.GetSize()));
151Quad MakeReferenceUVs(
const Rect& reference,
const Quad& target_quad) {
154 1.0f / reference.GetHeight(), 1.0f)) *
156 Vector3(-reference.GetLeft(), -reference.GetTop(), 0));
160Quad CalculateSnapshotUVs(
161 const Snapshot& input_snapshot,
162 const std::optional<Rect>& source_expanded_coverage_hint) {
163 std::optional<Rect> input_snapshot_coverage = input_snapshot.GetCoverage();
165 FML_DCHECK(input_snapshot.transform.IsTranslationScaleOnly());
166 if (source_expanded_coverage_hint.has_value() &&
167 input_snapshot_coverage.has_value()) {
169 std::optional<Rect>
uvs =
170 MakeReferenceUVs(input_snapshot_coverage.value(),
171 source_expanded_coverage_hint.value())
174 if (
uvs.has_value()) {
175 blur_uvs[0] =
uvs->GetLeftTop();
176 blur_uvs[1] =
uvs->GetRightTop();
177 blur_uvs[2] =
uvs->GetLeftBottom();
178 blur_uvs[3] =
uvs->GetRightBottom();
185 if (divisor == 0.0f) {
189 Scalar remainder = fmod(val, divisor);
190 if (remainder != 0.0f) {
191 return val + (divisor - remainder);
198 if (divisor == 0.0f) {
202 Scalar remainder = fmod(val, divisor);
203 if (remainder != 0.0f) {
204 return val - remainder;
229Matrix PrecomputeQuadLineParameters(
const Quad& bounds) {
230 auto computeLine = [](
const Point& p0,
const Point&
p1) -> Vector4 {
244 Scalar C = -(A * p0.x + B * p0.y);
245 return Vector4(A, B, C, 0.0);
248 const Point& topLeft = bounds[0];
249 const Point& topRight = bounds[1];
250 const Point& botLeft = bounds[2];
251 const Point& botRight = bounds[3];
254 result.vec[0] = computeLine(topLeft, topRight);
255 result.vec[1] = computeLine(topRight, botRight);
256 result.vec[2] = computeLine(botRight, botLeft);
257 result.vec[3] = computeLine(botLeft, topLeft);
261struct DownsamplePassArgs {
284DownsamplePassArgs CalculateDownsamplePassArgs(
287 const Snapshot& input_snapshot,
288 const std::optional<Rect>& source_expanded_coverage_hint,
289 const std::optional<Quad>& source_bounds,
290 const std::shared_ptr<FilterInput>&
input,
291 const Entity& snapshot_entity) {
299 Vector2 downsample_scalar(desired_scalar, desired_scalar);
309 std::optional<Rect> snapshot_coverage = input_snapshot.GetCoverage();
310 if (input_snapshot.transform.Equals(snapshot_entity.GetTransform()) &&
311 source_expanded_coverage_hint.has_value() &&
312 snapshot_coverage.has_value() &&
313 snapshot_coverage->Contains(source_expanded_coverage_hint.value())) {
322 int32_t divisor = std::round(1.0f / desired_scalar);
324 FloorToDivisible(source_expanded_coverage_hint->GetLeft(), divisor),
325 FloorToDivisible(source_expanded_coverage_hint->GetTop(), divisor),
326 source_expanded_coverage_hint->GetRight(),
327 source_expanded_coverage_hint->GetBottom());
329 aligned_coverage_hint.GetX(), aligned_coverage_hint.GetY(),
330 CeilToDivisible(aligned_coverage_hint.GetWidth(), divisor),
331 CeilToDivisible(aligned_coverage_hint.GetHeight(), divisor));
332 ISize source_size =
ISize(aligned_coverage_hint.GetSize().width,
333 aligned_coverage_hint.GetSize().height);
334 Vector2 downsampled_size = source_size * downsample_scalar;
336 FML_DCHECK(std::modf(downsampled_size.x, &int_part) == 0.0f);
337 FML_DCHECK(std::modf(downsampled_size.y, &int_part) == 0.0f);
343 Quad uvs = CalculateSnapshotUVs(input_snapshot, aligned_coverage_hint);
345 if (source_bounds.has_value()) {
346 uv_bounds = MakeReferenceUVs(input_snapshot.GetCoverage().value(),
347 source_bounds.value());
355 {aligned_coverage_hint.GetX(), aligned_coverage_hint.GetY(), 0})};
358 auto input_snapshot_size = input_snapshot.texture->GetSize();
361 Vector2 downsampled_size = source_rect_padded.GetSize() * downsample_scalar;
363 ISize(ceil(downsampled_size.x), ceil(downsampled_size.y));
364 Vector2 divisible_size(CeilToDivisible(source_rect_padded.GetSize().width,
365 1.0 / downsample_scalar.x),
366 CeilToDivisible(source_rect_padded.GetSize().height,
367 1.0 / downsample_scalar.y));
373 (divisible_size.x - source_rect_padded.GetSize().width) / 2.0
377 (divisible_size.
y - source_rect_padded.GetSize().
height) / 2.0
379 source_rect_padded = source_rect.Expand(divisible_padding);
384 input, snapshot_entity, source_rect_padded, input_snapshot_size);
386 if (source_bounds.has_value()) {
389 input_snapshot.transform.Invert().Transform(source_bounds.value()));
397 .transform = input_snapshot.transform *
406 const ContentContext& renderer,
408 const std::shared_ptr<Texture>& input_texture,
409 const SamplerDescriptor& sampler_descriptor,
410 const DownsamplePassArgs& pass_args,
412 using VS = TextureFillVertexShader;
419 bool may_reuse_mipmap =
420 !pass_args.uv_bounds.has_value() &&
421 (pass_args.effective_scalar.x >= 0.5f ||
422 (!input_texture->NeedsMipmapGeneration() &&
423 input_texture->GetTextureDescriptor().mip_count > 1));
424 if (may_reuse_mipmap) {
426 [&](
const ContentContext& renderer, RenderPass& pass) {
427 HostBuffer& data_host_buffer = renderer.GetTransientsDataBuffer();
429 pass.SetCommandLabel(
"Gaussian blur downsample");
432 pass.SetPipeline(renderer.GetTexturePipeline(pipeline_options));
434 TextureFillVertexShader::FrameInfo frame_info;
437 TextureFillFragmentShader::FragInfo frag_info;
438 frag_info.alpha = 1.0;
440 const Quad&
uvs = pass_args.uvs;
441 std::array<VS::PerVertexData, 4> vertices = {
442 VS::PerVertexData{
Point(0, 0),
uvs[0]},
443 VS::PerVertexData{
Point(1, 0),
uvs[1]},
444 VS::PerVertexData{
Point(0, 1),
uvs[2]},
445 VS::PerVertexData{
Point(1, 1),
uvs[3]},
449 SamplerDescriptor linear_sampler_descriptor = sampler_descriptor;
450 SetTileMode(&linear_sampler_descriptor, renderer, tile_mode);
453 TextureFillVertexShader::BindFrameInfo(
454 pass, data_host_buffer.EmplaceUniform(frame_info));
455 TextureFillFragmentShader::BindFragInfo(
456 pass, data_host_buffer.EmplaceUniform(frag_info));
457 TextureFillFragmentShader::BindTextureSampler(
459 renderer.GetContext()->GetSamplerLibrary()->GetSampler(
460 linear_sampler_descriptor));
462 return pass.Draw().ok();
464 return renderer.MakeSubpass(
"Gaussian Blur Filter", pass_args.subpass_size,
472 if (pass_args.effective_scalar.x <= 0.0625f) {
474 ratio = 1.0f / 64.0f;
475 }
else if (pass_args.effective_scalar.x <= 0.125f) {
477 ratio = 1.0f / 16.0f;
480 [&](
const ContentContext& renderer, RenderPass& pass) {
481 HostBuffer& data_host_buffer = renderer.GetTransientsDataBuffer();
483 pass.SetCommandLabel(
"Gaussian blur downsample");
486 if (pass_args.uv_bounds.has_value()) {
488 renderer.GetDownsampleBoundedPipeline(pipeline_options));
490 TextureDownsampleBoundedFragmentShader::BoundInfo bound_info;
491 bound_info.quad_line_params =
492 PrecomputeQuadLineParameters(pass_args.uv_bounds.value());
493 TextureDownsampleBoundedFragmentShader::BindBoundInfo(
494 pass, data_host_buffer.EmplaceUniform(bound_info));
496#ifdef IMPELLER_ENABLE_OPENGLES
499 if (renderer.GetDeviceCapabilities()
500 .SupportsDecalSamplerAddressMode() ||
503 renderer.GetDownsamplePipeline(pipeline_options));
506 renderer.GetDownsampleTextureGlesPipeline(pipeline_options));
509 pass.SetPipeline(renderer.GetDownsamplePipeline(pipeline_options));
513 TextureFillVertexShader::FrameInfo frame_info;
516 TextureDownsampleFragmentShader::FragInfo frag_info;
517 frag_info.edge = edge;
518 frag_info.ratio = ratio;
519 frag_info.pixel_size =
Vector2(1.0f /
Size(input_texture->GetSize()));
521 const Quad&
uvs = pass_args.uvs;
522 std::array<VS::PerVertexData, 4> vertices = {
523 VS::PerVertexData{
Point(0, 0),
uvs[0]},
524 VS::PerVertexData{
Point(1, 0),
uvs[1]},
525 VS::PerVertexData{
Point(0, 1),
uvs[2]},
526 VS::PerVertexData{
Point(1, 1),
uvs[3]},
530 SamplerDescriptor linear_sampler_descriptor = sampler_descriptor;
531 SetTileMode(&linear_sampler_descriptor, renderer, tile_mode);
534 TextureFillVertexShader::BindFrameInfo(
535 pass, data_host_buffer.EmplaceUniform(frame_info));
536 TextureDownsampleFragmentShader::BindFragInfo(
537 pass, data_host_buffer.EmplaceUniform(frag_info));
538 TextureDownsampleFragmentShader::BindTextureSampler(
540 renderer.GetContext()->GetSamplerLibrary()->GetSampler(
541 linear_sampler_descriptor));
543 return pass.Draw().ok();
545 return renderer.MakeSubpass(
"Gaussian Blur Filter", pass_args.subpass_size,
553 const ContentContext& renderer,
555 const RenderTarget& input_pass,
556 const SamplerDescriptor& sampler_descriptor,
557 const BlurParameters& blur_info,
558 std::optional<RenderTarget> destination_target,
559 const Quad& blur_uvs) {
566 const std::shared_ptr<Texture>& input_texture =
567 input_pass.GetRenderTargetTexture();
573 [&](
const ContentContext& renderer, RenderPass& pass) {
574 GaussianBlurVertexShader::FrameInfo frame_info;
577 HostBuffer& data_host_buffer = renderer.GetTransientsDataBuffer();
581 pass.SetPipeline(renderer.GetGaussianBlurPipeline(options));
583 GaussianBlurFragmentShader::FragInfo frag_info;
584 frag_info.unpremultiply = blur_info.apply_unpremultiply;
585 GaussianBlurFragmentShader::BindFragInfo(
586 pass, data_host_buffer.EmplaceUniform(frag_info));
588 std::array<VS::PerVertexData, 4> vertices = {
589 VS::PerVertexData{blur_uvs[0], blur_uvs[0]},
590 VS::PerVertexData{blur_uvs[1], blur_uvs[1]},
591 VS::PerVertexData{blur_uvs[2], blur_uvs[2]},
592 VS::PerVertexData{blur_uvs[3], blur_uvs[3]},
596 SamplerDescriptor linear_sampler_descriptor = sampler_descriptor;
599 GaussianBlurFragmentShader::BindTextureSampler(
601 renderer.GetContext()->GetSamplerLibrary()->GetSampler(
602 linear_sampler_descriptor));
603 GaussianBlurVertexShader::BindFrameInfo(
604 pass, data_host_buffer.EmplaceUniform(frame_info));
605 GaussianBlurFragmentShader::BindKernelSamples(
606 pass, data_host_buffer.EmplaceUniform(
608 return pass.Draw().ok();
610 if (destination_target.has_value()) {
611 return renderer.MakeSubpass(
"Gaussian Blur Filter",
615 return renderer.MakeSubpass(
622 return static_cast<int>(std::round(radius * scalar));
626 const Entity& entity,
627 const std::shared_ptr<FilterInput>&
input,
628 const Snapshot& input_snapshot,
630 const Geometry* geometry) {
631 Matrix entity_transform = entity.GetTransform();
632 Matrix blur_transform = blur_entity.GetTransform();
636 entity_transform, blur_transform, geometry](
637 const ContentContext& renderer,
638 const Entity& entity, RenderPass& pass)
mutable {
640 clipper.SetClipDepth(entity.GetClipDepth());
641 clipper.SetTransform(entity.GetTransform() * entity_transform);
643 auto geom_result = geometry->GetPositionBuffer(renderer, clipper, pass);
645 ClipContents clip_contents(geometry->GetCoverage(clipper.GetTransform())
646 .value_or(Rect::MakeLTRB(0, 0, 0, 0)),
648 clip_contents.SetClipOperation(clip_operation);
649 clip_contents.SetGeometry(std::move(geom_result));
651 if (!clip_contents.Render(renderer, pass, entity.GetClipDepth())) {
654 blur_entity.SetClipDepth(entity.GetClipDepth());
655 blur_entity.SetTransform(entity.GetTransform() * blur_transform);
657 return blur_entity.Render(renderer, pass);
661 blur_transform](
const Entity& entity)
mutable {
662 blur_entity.SetTransform(entity.GetTransform() * blur_transform);
663 return blur_entity.GetCoverage();
671 const Entity& entity,
672 const std::shared_ptr<FilterInput>&
input,
673 const Snapshot& input_snapshot,
675 const Geometry* geometry,
678 switch (blur_style) {
683 input, input_snapshot,
684 std::move(blur_entity), geometry);
688 input, input_snapshot,
689 std::move(blur_entity), geometry);
691 Entity snapshot_entity =
694 Matrix blurred_transform = blur_entity.GetTransform();
695 Matrix snapshot_transform =
696 entity.GetTransform() *
699 input_snapshot.transform;
702 blurred_transform, snapshot_transform,
703 snapshot_entity = std::move(snapshot_entity)](
704 const ContentContext& renderer,
705 const Entity& entity,
706 RenderPass& pass)
mutable {
707 snapshot_entity.SetTransform(entity.GetTransform() *
709 snapshot_entity.SetClipDepth(entity.GetClipDepth());
710 if (!snapshot_entity.Render(renderer, pass)) {
713 blur_entity.SetClipDepth(entity.GetClipDepth());
714 blur_entity.SetTransform(entity.GetTransform() * blurred_transform);
715 return blur_entity.Render(renderer, pass);
718 blurred_transform](
const Entity& entity)
mutable {
719 blur_entity.SetTransform(entity.GetTransform() * blurred_transform);
720 return blur_entity.GetCoverage();
728GaussianBlurFilterContents::GaussianBlurFilterContents(
732 std::optional<Rect> bounds,
735 : sigma_(sigma_x, sigma_y),
736 tile_mode_(tile_mode),
738 mask_blur_style_(mask_blur_style),
739 mask_geometry_(mask_geometry) {
751 Scalar raw_result = 4.0 / sigma;
753 Scalar exponent = round(log2f(raw_result));
755 exponent = std::max(-4.0f, exponent);
756 Scalar rounded = powf(2.0f, exponent);
760 if (rounded < 0.125f) {
761 Scalar rounded_plus = powf(2.0f, exponent + 1);
763 int kernel_size_plus = (ScaleBlurRadius(
blur_radius, rounded_plus) * 2) + 1;
767 static constexpr int32_t kEighthDownsampleKernalWidthMax = 41;
768 result = kernel_size_plus <= kEighthDownsampleKernalWidthMax ? rounded_plus
775 const Matrix& effect_transform,
776 const Rect& output_limit)
const {
783 return output_limit.
Expand(
Point(blur_radii.
x, blur_radii.
y));
789 const Matrix& effect_transform)
const {
790 if (inputs.empty()) {
793 std::optional<Rect> input_coverage = inputs[0]->GetCoverage(entity);
794 if (!input_coverage.has_value()) {
798 BlurInfo blur_info = CalculateBlurInfo(entity, effect_transform, sigma_);
799 return input_coverage.value().Expand(
800 Point(blur_info.local_padding.x, blur_info.local_padding.y));
803std::optional<Entity> GaussianBlurFilterContents::RenderFilter(
807 const Matrix& effect_transform,
808 const Rect& coverage,
809 const std::optional<Rect>& coverage_hint)
const {
810 if (inputs.empty()) {
814 BlurInfo blur_info = CalculateBlurInfo(entity, effect_transform, sigma_);
819 std::optional<Rect> expanded_coverage_hint;
820 if (coverage_hint.has_value()) {
821 expanded_coverage_hint = coverage_hint->Expand(blur_info.local_padding);
824 Entity snapshot_entity = entity.
Clone();
829 std::optional<Rect> source_expanded_coverage_hint;
830 if (expanded_coverage_hint.has_value()) {
831 source_expanded_coverage_hint = expanded_coverage_hint->TransformBounds(
835 std::optional<Snapshot> input_snapshot = GetSnapshot(
836 inputs[0], renderer, snapshot_entity, source_expanded_coverage_hint);
837 if (!input_snapshot.has_value()) {
841 std::optional<Quad> source_bounds;
842 if (bounds_.has_value()) {
843 Matrix
transform = snapshot_entity.GetTransform() * effect_transform;
844 source_bounds = bounds_->GetTransformedPoints(
transform);
856 input_snapshot->transform);
866 std::shared_ptr<CommandBuffer> command_buffer_1 =
868 if (!command_buffer_1) {
872 DownsamplePassArgs downsample_pass_args = CalculateDownsamplePassArgs(
873 blur_info.scaled_sigma, blur_info.padding, input_snapshot.value(),
874 source_expanded_coverage_hint, source_bounds, inputs[0], snapshot_entity);
877 renderer, command_buffer_1, input_snapshot->texture,
878 input_snapshot->sampler_descriptor, downsample_pass_args, tile_mode_);
880 if (!pass1_out.
ok()) {
885 1.0 /
Vector2(pass1_out.
value().GetRenderTargetTexture()->GetSize());
889 std::shared_ptr<CommandBuffer> command_buffer_2 =
891 if (!command_buffer_2) {
896 renderer, command_buffer_2, pass1_out.
value(),
897 input_snapshot->sampler_descriptor,
899 .blur_uv_offset = Point(0.0, pass1_pixel_size.y),
900 .blur_sigma = blur_info.scaled_sigma.y *
901 downsample_pass_args.effective_scalar.y,
902 .blur_radius = ScaleBlurRadius(
903 blur_info.blur_radius.y, downsample_pass_args.effective_scalar.y),
905 .apply_unpremultiply = false,
907 std::nullopt, blur_uvs);
909 if (!pass2_out.
ok()) {
913 std::shared_ptr<CommandBuffer> command_buffer_3 =
915 if (!command_buffer_3) {
920 auto pass3_destination = pass2_out.
value().GetRenderTargetTexture() !=
921 pass1_out.
value().GetRenderTargetTexture()
922 ? std::optional<RenderTarget>(pass1_out.
value())
923 :
std::optional<RenderTarget>(
std::nullopt);
926 renderer, command_buffer_3, pass2_out.
value(),
927 input_snapshot->sampler_descriptor,
929 .blur_uv_offset = Point(pass1_pixel_size.x, 0.0),
930 .blur_sigma = blur_info.scaled_sigma.x *
931 downsample_pass_args.effective_scalar.x,
932 .blur_radius = ScaleBlurRadius(
933 blur_info.blur_radius.x, downsample_pass_args.effective_scalar.x),
935 .apply_unpremultiply = bounds_.has_value(),
937 pass3_destination, blur_uvs);
939 if (!pass3_out.
ok()) {
943 if (!(renderer.
GetContext()->EnqueueCommandBuffer(
944 std::move(command_buffer_1)) &&
946 std::move(command_buffer_2)) &&
948 std::move(command_buffer_3)))) {
955 pass2_out.
value().GetRenderTargetSize()) &&
956 (pass2_out.
value().GetRenderTargetSize() ==
957 pass3_out.
value().GetRenderTargetSize()));
959 SamplerDescriptor sampler_desc = MakeSamplerDescriptor(
963 Snapshot{.texture = pass3_out.
value().GetRenderTargetTexture(),
968 downsample_pass_args.transform *
970 .sampler_descriptor = sampler_desc,
971 .opacity = input_snapshot->opacity,
972 .needs_rasterization_for_runtime_effects =
true},
975 return ApplyBlurStyle(mask_blur_style_, entity, inputs[0],
976 input_snapshot.value(), std::move(blur_output_entity),
977 mask_geometry_, blur_info.source_space_scalar,
978 blur_info.source_space_offset);
986 const std::shared_ptr<FilterInput>& filter_input,
988 const Rect& source_rect,
989 const ISize& texture_size) {
990 Matrix input_transform = filter_input->GetLocalTransform(entity);
994 {1.0f / texture_size.
width, 1.0f / texture_size.
height, 1.0f});
995 return uv_transform.
Transform(coverage_quad);
1003 Scalar clamped = std::min(sigma, kMaxSigma);
1004 constexpr Scalar a = 3.4e-06;
1005 constexpr Scalar b = -3.4e-3;
1007 Scalar scalar =
c + b * clamped + a * clamped * clamped;
1008 return clamped * scalar;
1041 .coefficient = expf(-0.5f * (
x *
x) /
1043 (sqrtf(2.0f * M_PI) * parameters.
blur_sigma),
1049 for (
auto& sample : result.
samples) {
1050 sample.coefficient /= tally;
1060 GaussianBlurPipeline::FragmentShader::KernelSamples result = {};
1062 int32_t middle = result.sample_count / 2;
1065 static_assert(
sizeof(result.sample_data) ==
1066 sizeof(std::array<Vector4, kGaussianBlurMaxKernelSize>));
1068 for (
int i = 0;
i < result.sample_count;
i++) {
1078 result.sample_data[
i].z = left.coefficient + right.coefficient;
1080 Point uv = (left.uv_offset * left.coefficient +
1081 right.uv_offset * right.coefficient) /
1082 (left.coefficient + right.coefficient);
1083 result.sample_data[
i].
x = uv.
x;
1084 result.sample_data[
i].y = uv.
y;
virtual bool SupportsDecalSamplerAddressMode() const =0
Whether the context backend supports SamplerAddressMode::Decal.
const Capabilities & GetDeviceCapabilities() const
std::function< bool(const ContentContext &, RenderPass &)> SubpassCallback
std::shared_ptr< Context > GetContext() const
static std::shared_ptr< Contents > MakeAnonymous(RenderProc render_proc, CoverageProc coverage_proc)
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
BlendMode GetBlendMode() const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
static Entity FromSnapshot(const Snapshot &snapshot, BlendMode blend_mode=BlendMode::kSrcOver)
Create an entity that can be used to render a given snapshot.
@ kNormal
Blurred inside and outside.
@ kOuter
Nothing inside, blurred outside.
@ kInner
Blurred inside, nothing outside.
@ kSolid
Solid inside, blurred outside.
static Scalar CalculateBlurRadius(Scalar sigma)
static Scalar ScaleSigma(Scalar sigma)
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...
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...
static Scalar CalculateScale(Scalar sigma)
static Quad CalculateUVs(const std::shared_ptr< FilterInput > &filter_input, const Entity &entity, const Rect &source_rect, const ISize &texture_size)
#define FML_DCHECK(condition)
Vector2 local_padding
Padding in unrotated local space.
Vector2 blur_radius
Blur radius in source pixels based on scaled_sigma.
ISize subpass_size
The output size of the down-sampling pass.
Vector2 source_space_offset
Vector2 source_space_scalar
The scalar that is used to get from source space to unrotated local space.
Vector2 padding
The halo padding in source space.
std::optional< Quad > uv_bounds
Vector2 scaled_sigma
Sigma when considering an entity's scale and the effect transform.
internal::CopyableLambda< T > MakeCopyable(T lambda)
static constexpr int32_t kGaussianBlurMaxKernelSize
@ kDecal
decal sampling mode is only supported on devices that pass the Capabilities.SupportsDecalSamplerAddre...
constexpr float kEhCloseEnough
VertexBuffer CreateVertexBuffer(std::array< VertexType, size > input, HostBuffer &data_host_buffer)
Create an index-less vertex buffer from a fixed size array.
LinePipeline::VertexShader VS
KernelSamples GenerateBlurInfo(BlurParameters parameters)
ContentContextOptions OptionsFromPass(const RenderPass &pass)
MinMagFilter
Describes how the texture should be sampled when the texture is being shrunk (minified) or expanded (...
std::array< Point, 4 > Quad
GaussianBlurPipeline::FragmentShader GaussianBlurFragmentShader
GaussianBlurPipeline::FragmentShader::KernelSamples LerpHackKernelSamples(KernelSamples parameters)
GaussianBlurPipeline::VertexShader GaussianBlurVertexShader
std::shared_ptr< CommandBuffer > command_buffer
static constexpr int kMaxKernelSize
KernelSample samples[kMaxKernelSize]
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeOrthographic(TSize< T > size)
static constexpr Matrix MakeTranslation(const Vector3 &t)
constexpr Matrix Basis() const
The Matrix without its w components (without translation).
constexpr Quad Transform(const Quad &quad) const
static constexpr Matrix MakeScale(const Vector3 &s)
For convolution filters, the "radius" is the size of the convolution kernel to use on the local space...
SamplerAddressMode width_address_mode
SamplerAddressMode height_address_mode
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
constexpr Scalar GetLength() const
static constexpr TRect MakeOriginSize(const TPoint< Type > &origin, const TSize< Type > &size)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
constexpr std::array< TPoint< T >, 4 > GetTransformedPoints(const Matrix &transform) const
static constexpr TRect MakeSize(const TSize< U > &size)
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)