Skip to content

Commit f7c08f0

Browse files
authored
[Impeller] Reorder blend filter checks to avoid unnecessary destination snapshot (flutter#42678)
Side quest of flutter#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)
1 parent 98c3632 commit f7c08f0

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

impeller/entity/contents/filters/blend_filter_contents.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -362,21 +362,10 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
362362
BlendMode blend_mode,
363363
std::optional<Scalar> alpha,
364364
bool absorb_opacity) const {
365-
auto dst_snapshot =
366-
input->GetSnapshot("ForegroundPorterDuffBlend", renderer, entity);
367-
if (!dst_snapshot.has_value()) {
368-
return std::nullopt;
369-
}
370-
371365
if (blend_mode == BlendMode::kClear) {
372366
return std::nullopt;
373367
}
374368

375-
if (blend_mode == BlendMode::kDestination) {
376-
return Entity::FromSnapshot(dst_snapshot, entity.GetBlendMode(),
377-
entity.GetStencilDepth());
378-
}
379-
380369
if (blend_mode == BlendMode::kSource) {
381370
auto contents = std::make_shared<SolidColorContents>();
382371
contents->SetGeometry(Geometry::MakeRect(coverage));
@@ -389,6 +378,17 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
389378
return foreground_entity;
390379
}
391380

381+
auto dst_snapshot =
382+
input->GetSnapshot("ForegroundPorterDuffBlend", renderer, entity);
383+
if (!dst_snapshot.has_value()) {
384+
return std::nullopt;
385+
}
386+
387+
if (blend_mode == BlendMode::kDestination) {
388+
return Entity::FromSnapshot(dst_snapshot, entity.GetBlendMode(),
389+
entity.GetStencilDepth());
390+
}
391+
392392
RenderProc render_proc = [foreground_color, coverage, dst_snapshot,
393393
blend_mode, absorb_opacity, alpha](
394394
const ContentContext& renderer,

0 commit comments

Comments
 (0)