Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ea53fdd

Browse files
committed
fixed having a content scale
1 parent 7466e0f commit ea53fdd

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

impeller/entity/contents/filters/gaussian_blur_filter_contents.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ SamplerDescriptor MakeSamplerDescriptor(MinMagFilter filter,
3636
/// @param entity_transform The local transform of the entity.
3737
/// @return A quad in uv coordinates representing the whole |subpass_size|.
3838
std::array<Point, 4> CalculateUVs(const ISize& subpass_size,
39+
const Matrix& scale,
3940
const Matrix& effect_transform,
4041
const Matrix& entity_transform) {
4142
Rect pass_rect =
42-
Rect::MakeSize(subpass_size).TransformBounds(effect_transform);
43+
Rect::MakeSize(subpass_size).TransformBounds(scale * effect_transform);
44+
Vector3 translated_origin =
45+
effect_transform * entity_transform.Invert() * Vector3(0, 0, 1);
4346
Matrix transform = Matrix::MakeScale({1.0f / pass_rect.size.width,
4447
1.0f / pass_rect.size.height, 1.0f}) *
45-
entity_transform.Invert();
48+
Matrix::MakeTranslation(translated_origin);
4649
return pass_rect.GetTransformedPoints(transform);
4750
}
4851

@@ -69,11 +72,9 @@ std::shared_ptr<Texture> MakeDownsampleSubpass(
6972
[&](const ContentContext& renderer, RenderPass& pass) {
7073
HostBuffer& host_buffer = pass.GetTransientsBuffer();
7174

72-
std::array<Point, 4> uvs =
73-
CalculateUVs(subpass_size,
74-
Matrix::MakeScale({downsample.x, downsample.y, 1.0}) *
75-
effect_transform,
76-
entity_transform);
75+
std::array<Point, 4> uvs = CalculateUVs(
76+
subpass_size, Matrix::MakeScale({downsample.x, downsample.y, 1.0}),
77+
effect_transform, entity_transform);
7778

7879
Command cmd;
7980
DEBUG_COMMAND_INFO(cmd, "Gaussian blur downsample");
@@ -128,11 +129,9 @@ std::shared_ptr<Texture> MakeBlurSubpass(
128129

129130
HostBuffer& host_buffer = pass.GetTransientsBuffer();
130131

131-
std::array<Point, 4> uvs =
132-
CalculateUVs(subpass_size,
133-
Matrix::MakeScale({downsample.x, downsample.y, 1.0}) *
134-
effect_transform,
135-
entity_transform);
132+
std::array<Point, 4> uvs = CalculateUVs(
133+
subpass_size, Matrix::MakeScale({downsample.x, downsample.y, 1.0}),
134+
effect_transform, entity_transform);
136135

137136
Command cmd;
138137
auto options = OptionsFromPass(pass);
@@ -231,6 +230,7 @@ std::optional<Entity> GaussianBlurFilterContents::RenderFilter(
231230
return std::nullopt;
232231
}
233232

233+
// TODO(gaaclarke): Scale the blur radius based on the entity transform.
234234
Scalar blur_radius = CalculateBlurRadius(sigma_);
235235
Scalar desired_scale = 1.0 / CalculateScale(blur_radius);
236236
Vector2 downsample =

0 commit comments

Comments
 (0)