mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fixes blend + color filter (flutter/engine#55411)
fixes https://github.com/flutter/flutter/issues/155456 Thanks @jason-simmons for identifying the fix. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
This commit is contained in:
parent
f425edfbf7
commit
ad894bd2f0
@ -194,6 +194,58 @@ TEST_P(AiksTest, PaintBlendModeIsRespected) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
// Compare results with https://api.flutter.dev/flutter/dart-ui/BlendMode.html
|
||||
TEST_P(AiksTest, ImageFilterBlend) {
|
||||
bool has_color_filter = true;
|
||||
auto callback = [&]() -> sk_sp<DisplayList> {
|
||||
if (AiksTest::ImGuiBegin("Controls", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::Checkbox("has color filter", &has_color_filter);
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
DisplayListBuilder builder;
|
||||
builder.Scale(GetContentScale().x, GetContentScale().y);
|
||||
|
||||
auto src_image =
|
||||
DlImageImpeller::Make(CreateTextureForFixture("blend_mode_src.png"));
|
||||
auto dst_image =
|
||||
DlImageImpeller::Make(CreateTextureForFixture("blend_mode_dst.png"));
|
||||
|
||||
std::vector<DlBlendMode> blend_modes = {
|
||||
DlBlendMode::kSrc, DlBlendMode::kSrcATop, DlBlendMode::kSrcOver,
|
||||
DlBlendMode::kSrcIn, DlBlendMode::kSrcOut, DlBlendMode::kDst,
|
||||
DlBlendMode::kDstATop, DlBlendMode::kDstOver, DlBlendMode::kDstIn,
|
||||
DlBlendMode::kDstOut, DlBlendMode::kClear, DlBlendMode::kXor};
|
||||
|
||||
for (uint32_t i = 0; i < blend_modes.size(); ++i) {
|
||||
builder.Save();
|
||||
builder.Translate((i % 5) * 200, (i / 5) * 200);
|
||||
builder.Scale(0.4, 0.4);
|
||||
{
|
||||
DlPaint dstPaint;
|
||||
builder.DrawImage(dst_image, {0, 0}, DlImageSampling::kMipmapLinear,
|
||||
&dstPaint);
|
||||
}
|
||||
{
|
||||
DlPaint srcPaint;
|
||||
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);
|
||||
srcPaint.setColorFilter(color_filter);
|
||||
}
|
||||
builder.DrawImage(src_image, {0, 0}, DlImageSampling::kMipmapLinear,
|
||||
&srcPaint);
|
||||
}
|
||||
builder.Restore();
|
||||
}
|
||||
return builder.Build();
|
||||
};
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
// Bug: https://github.com/flutter/flutter/issues/142549
|
||||
TEST_P(AiksTest, BlendModePlusAlphaWideGamut) {
|
||||
EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
|
||||
|
||||
@ -454,7 +454,7 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
|
||||
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;
|
||||
pass.SetPipeline(renderer.GetPorterDuffBlendPipeline(options));
|
||||
|
||||
@ -505,6 +505,7 @@ std::optional<Entity> BlendFilterContents::CreateForegroundPorterDuffBlend(
|
||||
|
||||
Entity sub_entity;
|
||||
sub_entity.SetContents(std::move(contents));
|
||||
sub_entity.SetBlendMode(entity.GetBlendMode());
|
||||
|
||||
return sub_entity;
|
||||
}
|
||||
|
||||
@ -711,6 +711,9 @@ impeller_Play_AiksTest_GradientStrokesRenderCorrectly_Vulkan.png
|
||||
impeller_Play_AiksTest_ImageColorSourceEffectTransform_Metal.png
|
||||
impeller_Play_AiksTest_ImageColorSourceEffectTransform_OpenGLES.png
|
||||
impeller_Play_AiksTest_ImageColorSourceEffectTransform_Vulkan.png
|
||||
impeller_Play_AiksTest_ImageFilterBlend_Metal.png
|
||||
impeller_Play_AiksTest_ImageFilterBlend_OpenGLES.png
|
||||
impeller_Play_AiksTest_ImageFilterBlend_Vulkan.png
|
||||
impeller_Play_AiksTest_ImageFilteredSaveLayerWithUnboundedContents_Metal.png
|
||||
impeller_Play_AiksTest_ImageFilteredSaveLayerWithUnboundedContents_OpenGLES.png
|
||||
impeller_Play_AiksTest_ImageFilteredSaveLayerWithUnboundedContents_Vulkan.png
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user