[Impeller] Reorder blend filter checks to avoid unnecessary destination snapshot (flutter/engine#42678)

Side quest of https://github.com/flutter/flutter/issues/127232.

Tiny reordering to avoid unnecessary input resolution. :) Happened to notice we were hitting this case while going through some frame captures of reported fidelity issues.

Before:
![Screenshot 2023-06-08 at 1 45 48 PM](https://github.com/flutter/engine/assets/919017/aae28b7d-985d-4f16-9801-c689f8dc6f18)

After:
![Screenshot 2023-06-08 at 1 48 49 PM](https://github.com/flutter/engine/assets/919017/b667a4cd-bcf7-4e3a-98f7-0ed182b7a227)
This commit is contained in:
Brandon DeRosier
2023-06-08 15:00:56 -07:00
committed by GitHub
parent 81a4a5e34b
commit 3dd6e55e45

View File

@@ -362,21 +362,10 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
BlendMode blend_mode,
std::optional<Scalar> alpha,
bool absorb_opacity) const {
auto dst_snapshot =
input->GetSnapshot("ForegroundPorterDuffBlend", renderer, entity);
if (!dst_snapshot.has_value()) {
return std::nullopt;
}
if (blend_mode == BlendMode::kClear) {
return std::nullopt;
}
if (blend_mode == BlendMode::kDestination) {
return Entity::FromSnapshot(dst_snapshot, entity.GetBlendMode(),
entity.GetStencilDepth());
}
if (blend_mode == BlendMode::kSource) {
auto contents = std::make_shared<SolidColorContents>();
contents->SetGeometry(Geometry::MakeRect(coverage));
@@ -389,6 +378,17 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
return foreground_entity;
}
auto dst_snapshot =
input->GetSnapshot("ForegroundPorterDuffBlend", renderer, entity);
if (!dst_snapshot.has_value()) {
return std::nullopt;
}
if (blend_mode == BlendMode::kDestination) {
return Entity::FromSnapshot(dst_snapshot, entity.GetBlendMode(),
entity.GetStencilDepth());
}
RenderProc render_proc = [foreground_color, coverage, dst_snapshot,
blend_mode, absorb_opacity, alpha](
const ContentContext& renderer,