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

Commit a31c346

Browse files
committed
made the downsample scalar fixed by adjusting the padding
1 parent 8bf0a56 commit a31c346

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

impeller/entity/contents/filters/gaussian_blur_filter_contents.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,27 @@ DownsamplePassArgs CalculateDownsamplePassArgs(
303303
Rect source_rect_padded = source_rect.Expand(padding);
304304
Vector2 downsampled_size = source_rect_padded.GetSize() * downsample_scalar;
305305
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();
306+
ISize(ceil(downsampled_size.x), ceil(downsampled_size.y));
307+
Vector2 divisible_size(CeilToDivisible(source_rect_padded.GetSize().width,
308+
1.0 / downsample_scalar.x),
309+
CeilToDivisible(source_rect_padded.GetSize().height,
310+
1.0 / downsample_scalar.y));
311+
Vector2 divisible_padding(
312+
padding.x +
313+
(divisible_size.x - source_rect_padded.GetSize().width) / 2.0,
314+
padding.y +
315+
(divisible_size.y - source_rect_padded.GetSize().height) / 2.0);
316+
source_rect_padded = source_rect.Expand(divisible_padding);
317+
318+
Vector2 effective_scalar = downsample_scalar;
309319
Quad uvs = GaussianBlurFilterContents::CalculateUVs(
310320
input, snapshot_entity, source_rect_padded, input_snapshot_size);
311321
return {
312322
.subpass_size = subpass_size,
313323
.uvs = uvs,
314324
.effective_scalar = effective_scalar,
315-
.transform =
316-
input_snapshot.transform * Matrix::MakeTranslation(-padding),
325+
.transform = input_snapshot.transform *
326+
Matrix::MakeTranslation(-divisible_padding),
317327
};
318328
}
319329
}

0 commit comments

Comments
 (0)