Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions impeller/display_list/aiks_dl_blend_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,19 @@ TEST_P(AiksTest, ColorFilterBlend) {

// Verification for: https://github.com/flutter/flutter/issues/155691
TEST_P(AiksTest, ColorFilterAdvancedBlend) {
std::array<const char*, 2> filter_blend_mode_names = {"SrcIn", "Multiply"};
std::array<DlBlendMode, 2> filter_blend_modes = {DlBlendMode::kSrcIn,
DlBlendMode::kMultiply};
bool has_color_filter = true;
int selected_filter_blend_mode = 0;

auto callback = [&]() -> sk_sp<DisplayList> {
if (AiksTest::ImGuiBegin("Controls", nullptr,
ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Checkbox("has color filter", &has_color_filter);
ImGui::Combo("Color filter blend mode", &selected_filter_blend_mode,
filter_blend_mode_names.data(),
filter_blend_mode_names.size());
ImGui::End();
}

Expand Down Expand Up @@ -289,8 +297,9 @@ TEST_P(AiksTest, ColorFilterAdvancedBlend) {
srcPaint.setBlendMode(blend_modes[i]);
if (has_color_filter) {
std::shared_ptr<const DlColorFilter> color_filter =
DlBlendColorFilter::Make(DlColor::RGBA(0.9, 0.5, 0.0, 1.0),
DlBlendMode::kSrcIn);
DlBlendColorFilter::Make(
DlColor::RGBA(0.9, 0.5, 0.0, 1.0),
filter_blend_modes[selected_filter_blend_mode]);
srcPaint.setColorFilter(color_filter);
}
builder.DrawImage(src_image, {0, 0}, DlImageSampling::kMipmapLinear,
Expand Down
8 changes: 5 additions & 3 deletions impeller/entity/contents/filters/blend_filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(
BlendModeToString(blend_mode)));
#endif // IMPELLER_DEBUG
pass.SetVertexBuffer(std::move(vtx_buffer));
auto options = OptionsFromPass(pass);
auto options = OptionsFromPassAndEntity(pass, entity);
options.primitive_type = PrimitiveType::kTriangleStrip;

switch (blend_mode) {
Expand Down Expand Up @@ -370,8 +370,9 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(
FS::BindTextureSamplerDst(pass, dst_snapshot->texture, dst_sampler);
frame_info.dst_y_coord_scale = dst_snapshot->texture->GetYCoordScale();

frame_info.mvp = Entity::GetShaderTransform(entity.GetShaderClipDepth(),
pass, dst_snapshot->transform);
frame_info.mvp = Entity::GetShaderTransform(
entity.GetShaderClipDepth(), pass,
entity.GetTransform() * dst_snapshot->transform);

blend_info.dst_input_alpha =
absorb_opacity == ColorFilterContents::AbsorbOpacity::kYes
Expand Down Expand Up @@ -402,6 +403,7 @@ std::optional<Entity> BlendFilterContents::CreateForegroundAdvancedBlend(

Entity sub_entity;
sub_entity.SetContents(std::move(contents));
sub_entity.SetBlendMode(entity.GetBlendMode());

return sub_entity;
}
Expand Down