Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] adds a plus advanced blend for f16 pixel formats #51589

Merged
merged 25 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ed6da6a
[Impeller] adds wide gamut golden tests
gaaclarke Mar 15, 2024
b51b9a2
updated golden
gaaclarke Mar 18, 2024
55135b8
moved to a magic name
gaaclarke Mar 26, 2024
509f20b
[Impeller] fixes alpha blend for plus blend mode
gaaclarke Mar 15, 2024
47498e1
[Impeller] made plus an advanced blend
gaaclarke Mar 21, 2024
c2a9d68
fixed the blending math (jasons test passes now)
gaaclarke Mar 22, 2024
d3e714e
fixed ColorBlendReturnsExpectedResults test
gaaclarke Mar 25, 2024
85e93d7
refactored the geometry tests to not be dependent on order
gaaclarke Mar 25, 2024
dacb1e4
removed single plus test, renamed the overlapping one
gaaclarke Mar 25, 2024
418c811
fixed Play/AiksTest.PaintBlendModeIsRespected/OpenGLES
gaaclarke Mar 25, 2024
c3aa8cc
moved the test to the new magic name, removed the blending test
gaaclarke Mar 26, 2024
5b5e6ca
gave golden image tests the magic name feature
gaaclarke Mar 26, 2024
7953bd7
resurrected the old blend
gaaclarke Mar 26, 2024
eb03810
added switch for the advancedblend
gaaclarke Mar 26, 2024
9a8ee6f
added tests for the magic test name
gaaclarke Mar 27, 2024
7ca79f6
renamed some variables
gaaclarke Mar 27, 2024
337876d
moved things to match how they were
gaaclarke Mar 27, 2024
669a096
factored out the shared blend function
gaaclarke Mar 27, 2024
cc8ab6a
factored out shared function
gaaclarke Mar 27, 2024
90330f4
added skip for non metal tests
gaaclarke Mar 27, 2024
2650ee0
fixed opengl run
gaaclarke Mar 27, 2024
afa7908
updated goldens
gaaclarke Mar 27, 2024
7081ef7
updated goldens
gaaclarke Mar 27, 2024
5025ec1
added support for colorfilters
gaaclarke Mar 27, 2024
202f56d
format
gaaclarke Mar 27, 2024
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
Prev Previous commit
Next Next commit
[Impeller] fixes alpha blend for plus blend mode
added test

fixed screenshoter

fix dl_test_surface

limited the new blend to only wide gamut contexts

tidy

updated golden
  • Loading branch information
gaaclarke committed Mar 27, 2024
commit 509f20be4233c85e15057e4ebf0aebefb2bf1152
21 changes: 21 additions & 0 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,27 @@ TEST_P(AiksTest, PaintBlendModeIsRespected) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

// Bug: https://github.com/flutter/flutter/issues/142549
TEST_P(AiksTest, BlendModePlusAlpha) {
auto texture = CreateTextureForFixture("airplane.jpg",
/*enable_mipmapping=*/true);

Canvas canvas;
canvas.Scale(GetContentScale());
canvas.DrawPaint({.color = Color(0.9, 1.0, 0.9, 1.0)});
canvas.SaveLayer({});
Paint paint;
paint.blend_mode = BlendMode::kPlus;
paint.color = Color::Red();
canvas.DrawRect(Rect::MakeXYWH(100, 100, 400, 400), paint);
paint.color = Color::White();
canvas.DrawImageRect(
std::make_shared<Image>(texture), Rect::MakeSize(texture->GetSize()),
Rect::MakeXYWH(100, 100, 400, 400).Expand(-100, -100), paint);
canvas.Restore();
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, ColorWheel) {
// Compare with https://fiddle.skia.org/c/@BlendModes

Expand Down
10 changes: 9 additions & 1 deletion impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@

namespace impeller {

bool IsAlphaClampedToOne(PixelFormat pixel_format) {
return !(pixel_format == PixelFormat::kR32G32B32A32Float ||
pixel_format == PixelFormat::kR16G16B16A16Float);
}

void ContentContextOptions::ApplyToPipelineDescriptor(
PipelineDescriptor& desc) const {
auto pipeline_blend = blend_mode;
Expand Down Expand Up @@ -124,7 +129,10 @@ void ContentContextOptions::ApplyToPipelineDescriptor(
color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha;
break;
case BlendMode::kPlus:
color0.dst_alpha_blend_factor = BlendFactor::kOne;
color0.dst_alpha_blend_factor =
IsAlphaClampedToOne(color_attachment_pixel_format)
? BlendFactor::kOne
: BlendFactor::kOneMinusSourceAlpha;
color0.dst_color_blend_factor = BlendFactor::kOne;
color0.src_alpha_blend_factor = BlendFactor::kOne;
color0.src_color_blend_factor = BlendFactor::kOne;
Expand Down