@@ -28,6 +28,17 @@ void MatrixFilterContents::SetSamplerDescriptor(SamplerDescriptor desc) {
2828 sampler_descriptor_ = std::move (desc);
2929}
3030
31+ namespace {
32+ Matrix CalculateSubpassTransform (const Matrix& entity_transform,
33+ const Matrix& effect_transform,
34+ const Matrix& matrix) {
35+ return entity_transform * //
36+ effect_transform * //
37+ matrix * //
38+ effect_transform.Invert ();
39+ }
40+ } // namespace
41+
3142std::optional<Entity> MatrixFilterContents::RenderFilter (
3243 const FilterInput::Vector& inputs,
3344 const ContentContext& renderer,
@@ -68,11 +79,8 @@ std::optional<Entity> MatrixFilterContents::RenderFilter(
6879 // backdrop texture (as mentioned above). And so we sneak the subpass's
6980 // captured CTM in through the effect transform.
7081 //
71-
72- snapshot->transform = snapshot->transform * //
73- effect_transform * //
74- matrix_ * //
75- effect_transform.Invert ();
82+ snapshot->transform = CalculateSubpassTransform (snapshot->transform ,
83+ effect_transform, matrix_);
7684 } else {
7785 snapshot->transform = entity.GetTransform () * //
7886 matrix_ * //
@@ -107,23 +115,21 @@ std::optional<Rect> MatrixFilterContents::GetFilterCoverage(
107115 return std::nullopt ;
108116 }
109117
110- auto coverage = inputs[0 ]->GetCoverage (entity);
118+ std::optional<Rect> coverage = inputs[0 ]->GetCoverage (entity);
111119 if (!coverage.has_value ()) {
112120 return std::nullopt ;
113121 }
114122
115- auto input_transform = inputs[0 ]->GetTransform (entity);
123+ Matrix input_transform = inputs[0 ]->GetTransform (entity);
116124 if (rendering_mode_ == Entity::RenderingMode::kSubpass ) {
117- auto coverage_bounds = coverage->TransformBounds (input_transform.Invert ());
118- auto transform = input_transform * //
119- effect_transform * //
120- matrix_ * //
121- effect_transform.Invert (); //
125+ Rect coverage_bounds = coverage->TransformBounds (input_transform.Invert ());
126+ Matrix transform =
127+ CalculateSubpassTransform (input_transform, effect_transform, matrix_);
122128 return coverage_bounds.TransformBounds (transform);
123129 } else {
124- auto transform = input_transform * //
125- matrix_ * //
126- input_transform.Invert (); //
130+ Matrix transform = input_transform * //
131+ matrix_ * //
132+ input_transform.Invert (); //
127133 return coverage->TransformBounds (transform);
128134 }
129135}
0 commit comments