Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 2060ed3

Browse files
committed
[Impeller] Reorder blend filter checks to avoid unnecessary destination snapshot
1 parent 1fd7116 commit 2060ed3

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

impeller/entity/contents/filters/blend_filter_contents.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -357,21 +357,10 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
357357
BlendMode blend_mode,
358358
std::optional<Scalar> alpha,
359359
bool absorb_opacity) const {
360-
auto dst_snapshot =
361-
input->GetSnapshot("ForegroundPorterDuffBlend", renderer, entity);
362-
if (!dst_snapshot.has_value()) {
363-
return std::nullopt;
364-
}
365-
366360
if (blend_mode == BlendMode::kClear) {
367361
return std::nullopt;
368362
}
369363

370-
if (blend_mode == BlendMode::kDestination) {
371-
return Entity::FromSnapshot(dst_snapshot, entity.GetBlendMode(),
372-
entity.GetStencilDepth());
373-
}
374-
375364
if (blend_mode == BlendMode::kSource) {
376365
auto contents = std::make_shared<SolidColorContents>();
377366
contents->SetGeometry(Geometry::MakeRect(coverage));
@@ -384,6 +373,17 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
384373
return foreground_entity;
385374
}
386375

376+
auto dst_snapshot =
377+
input->GetSnapshot("ForegroundPorterDuffBlend", renderer, entity);
378+
if (!dst_snapshot.has_value()) {
379+
return std::nullopt;
380+
}
381+
382+
if (blend_mode == BlendMode::kDestination) {
383+
return Entity::FromSnapshot(dst_snapshot, entity.GetBlendMode(),
384+
entity.GetStencilDepth());
385+
}
386+
387387
RenderProc render_proc = [foreground_color, coverage, dst_snapshot,
388388
blend_mode, absorb_opacity, alpha](
389389
const ContentContext& renderer,

0 commit comments

Comments
 (0)