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

Commit e841620

Browse files
committed
Fixes blend + color filter
1 parent 2745b87 commit e841620

File tree

3 files changed

+160
-1
lines changed

3 files changed

+160
-1
lines changed

engine.code-workspace

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,33 @@
232232
"kind": "build"
233233
}
234234
},
235+
{
236+
"type": "shell",
237+
"command": "./flutter/bin/et",
238+
"options": {
239+
"cwd": "${workspaceFolder}/.."
240+
},
241+
"problemMatcher": [
242+
"$gcc"
243+
],
244+
"presentation": {
245+
"echo": true,
246+
"reveal": "silent",
247+
"focus": false,
248+
"panel": "shared",
249+
"clear": true
250+
},
251+
"group": {
252+
"kind": "build",
253+
"isDefault": true
254+
},
255+
"label": "host_debug_unopt_arm64",
256+
"args": [
257+
"build",
258+
"-c",
259+
"host_debug_unopt_arm64"
260+
]
261+
},
235262
{
236263
"type": "shell",
237264
"command": "./flutter/bin/et",
@@ -285,6 +312,68 @@
285312
"host_debug_unopt_arm64",
286313
"//flutter/impeller/golden_tests:impeller_golden_tests"
287314
]
315+
},
316+
{
317+
"type": "shell",
318+
"command": "./flutter/bin/et",
319+
"options": {
320+
"cwd": "${workspaceFolder}/.."
321+
},
322+
"problemMatcher": [
323+
"$gcc"
324+
],
325+
"presentation": {
326+
"echo": true,
327+
"reveal": "silent",
328+
"focus": false,
329+
"panel": "shared",
330+
"clear": true
331+
},
332+
"group": {
333+
"kind": "build"
334+
},
335+
"label": "ios_debug_unopt_arm64",
336+
"args": [
337+
"build",
338+
"-c",
339+
"host_debug_unopt_arm64",
340+
"&&",
341+
"./flutter/bin/et",
342+
"build",
343+
"-c",
344+
"ios_debug_unopt"
345+
]
346+
},
347+
{
348+
"type": "shell",
349+
"command": "./flutter/bin/et",
350+
"options": {
351+
"cwd": "${workspaceFolder}/.."
352+
},
353+
"problemMatcher": [
354+
"$gcc"
355+
],
356+
"presentation": {
357+
"echo": true,
358+
"reveal": "silent",
359+
"focus": false,
360+
"panel": "shared",
361+
"clear": true
362+
},
363+
"group": {
364+
"kind": "build"
365+
},
366+
"label": "android_debug_unopt_arm64",
367+
"args": [
368+
"build",
369+
"-c",
370+
"host_debug_unopt_arm64",
371+
"&&",
372+
"./flutter/bin/et",
373+
"build",
374+
"-c",
375+
"android_debug_unopt_arm64"
376+
]
288377
}
289378
]
290379
},
@@ -374,7 +463,8 @@
374463
"name": "impeller_golden_tests_arm64",
375464
"program": "${workspaceFolder}/../out/host_debug_unopt_arm64/impeller_golden_tests",
376465
"args": [
377-
"--working_dir=~/Desktop"
466+
"--working_dir=~/Desktop",
467+
"--gtest_filter=*/Metal"
378468
],
379469
"preLaunchTask": "impeller_golden_tests_arm64"
380470
}

impeller/display_list/aiks_dl_blend_unittests.cc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,58 @@ TEST_P(AiksTest, PaintBlendModeIsRespected) {
194194
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
195195
}
196196

197+
// Compare results with https://api.flutter.dev/flutter/dart-ui/BlendMode.html
198+
TEST_P(AiksTest, ImageFilterBlend) {
199+
bool has_color_filter = true;
200+
auto callback = [&]() -> sk_sp<DisplayList> {
201+
if (AiksTest::ImGuiBegin("Controls", nullptr,
202+
ImGuiWindowFlags_AlwaysAutoResize)) {
203+
ImGui::Checkbox("has color filter", &has_color_filter);
204+
ImGui::End();
205+
}
206+
207+
DisplayListBuilder builder;
208+
builder.Scale(GetContentScale().x, GetContentScale().y);
209+
210+
auto src_image =
211+
DlImageImpeller::Make(CreateTextureForFixture("blend_mode_src.png"));
212+
auto dst_image =
213+
DlImageImpeller::Make(CreateTextureForFixture("blend_mode_dst.png"));
214+
215+
std::vector<DlBlendMode> blend_modes = {
216+
DlBlendMode::kSrc, DlBlendMode::kSrcATop, DlBlendMode::kSrcOver,
217+
DlBlendMode::kSrcIn, DlBlendMode::kSrcOut, DlBlendMode::kDst,
218+
DlBlendMode::kDstATop, DlBlendMode::kDstOver, DlBlendMode::kDstIn,
219+
DlBlendMode::kDstOut, DlBlendMode::kClear, DlBlendMode::kXor};
220+
221+
for (uint32_t i = 0; i < blend_modes.size(); ++i) {
222+
builder.Save();
223+
builder.Translate((i % 5) * 200, (i / 5) * 200);
224+
builder.Scale(0.4, 0.4);
225+
{
226+
DlPaint dstPaint;
227+
builder.DrawImage(dst_image, {0, 0}, DlImageSampling::kMipmapLinear,
228+
&dstPaint);
229+
}
230+
{
231+
DlPaint srcPaint;
232+
srcPaint.setBlendMode(blend_modes[i]);
233+
if (has_color_filter) {
234+
std::shared_ptr<const DlColorFilter> color_filter =
235+
DlBlendColorFilter::Make(DlColor::RGBA(0.9, 0.5, 0.0, 1.0),
236+
DlBlendMode::kSrcIn);
237+
srcPaint.setColorFilter(color_filter);
238+
}
239+
builder.DrawImage(src_image, {0, 0}, DlImageSampling::kMipmapLinear,
240+
&srcPaint);
241+
}
242+
builder.Restore();
243+
}
244+
return builder.Build();
245+
};
246+
ASSERT_TRUE(OpenPlaygroundHere(callback));
247+
}
248+
197249
// Bug: https://github.com/flutter/flutter/issues/142549
198250
TEST_P(AiksTest, BlendModePlusAlphaWideGamut) {
199251
EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),

tools/vscode_workspace/engine-workspace.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ tasks:
192192
clear: true
193193
group:
194194
kind: build
195+
- <<: *et-task
196+
label: host_debug_unopt_arm64
197+
args:
198+
- build
199+
- -c
200+
- host_debug_unopt_arm64
195201
- <<: *et-task
196202
label: display_list_unittests_arm64
197203
args:
@@ -217,6 +223,17 @@ tasks:
217223
- build
218224
- -c
219225
- ios_debug_unopt
226+
- <<: *et-task
227+
label: android_debug_unopt_arm64
228+
args:
229+
- build
230+
- -c
231+
- host_debug_unopt_arm64
232+
- "&&"
233+
- *et-cmd
234+
- build
235+
- -c
236+
- android_debug_unopt_arm64
220237
extensions:
221238
recommendations:
222239
# C++ TestMate

0 commit comments

Comments
 (0)