@@ -629,18 +629,6 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
629629 return EntityPass::EntityResult::Skip ();
630630 }
631631
632- // RoundOut the subpass coverage to ensure the new subpass texture will be
633- // perfectly pixel aligned in the common case. By default, we draw subpass
634- // textures with nearest sampling, perfectly aligned with the parent pass
635- // render target. So integer aligning the subpass coverage rectangle is
636- // important for:
637- // 1. Correct visual subpixel placement/antialiasing of subpass elements.
638- // 2. Avoiding visual nearest sampling errors caused by limited floating
639- // point precision when straddling a half pixel boundary.
640- if (subpass_coverage.has_value ()) {
641- subpass_coverage = Rect::RoundOut (subpass_coverage.value ());
642- }
643-
644632 auto subpass_size = ISize (subpass_coverage->GetSize ());
645633 if (subpass_size.IsEmpty ()) {
646634 return EntityPass::EntityResult::Skip ();
@@ -706,12 +694,28 @@ EntityPass::EntityResult EntityPass::GetEntityForElement(
706694 // right thing.
707695 return EntityPass::EntityResult::Failure ();
708696 }
697+
698+ // Round the subpass texture position for pixel alignment with the parent
699+ // pass render target. By default, we draw subpass textures with nearest
700+ // sampling, so aligning here is important for avoiding visual nearest
701+ // sampling errors caused by limited floating point precision when
702+ // straddling a half pixel boundary.
703+ //
704+ // We do this in lieu of expanding/rounding out the subpass coverage in
705+ // order to keep the bounds wrapping consistently tight around subpass
706+ // elements. Which is necessary to avoid intense flickering in cases
707+ // where a subpass texture has a large blur filter with clamp sampling.
708+ //
709+ // See also this bug: https://github.com/flutter/flutter/issues/144213
710+ Point subpass_texture_position =
711+ (subpass_coverage->GetOrigin () - global_pass_position).Round ();
712+
709713 Entity element_entity;
710714 element_entity.SetClipDepth (subpass->clip_depth_ );
711715 element_entity.SetContents (std::move (offscreen_texture_contents));
712716 element_entity.SetBlendMode (subpass->blend_mode_ );
713- element_entity.SetTransform (Matrix::MakeTranslation (
714- Vector3 (subpass_coverage-> GetOrigin () - global_pass_position )));
717+ element_entity.SetTransform (
718+ Matrix::MakeTranslation ( Vector3 (subpass_texture_position )));
715719
716720 return EntityPass::EntityResult::Success (std::move (element_entity));
717721 }
0 commit comments