[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:  After: 
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user