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

Commit e5210b3

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

File tree

3 files changed

+157
-0
lines changed

3 files changed

+157
-0
lines changed

engine.code-workspace

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,32 @@
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+
},
254+
"label": "host_debug_unopt_arm64",
255+
"args": [
256+
"build",
257+
"-c",
258+
"host_debug_unopt_arm64"
259+
]
260+
},
235261
{
236262
"type": "shell",
237263
"command": "./flutter/bin/et",
@@ -285,6 +311,68 @@
285311
"host_debug_unopt_arm64",
286312
"//flutter/impeller/golden_tests:impeller_golden_tests"
287313
]
314+
},
315+
{
316+
"type": "shell",
317+
"command": "./flutter/bin/et",
318+
"options": {
319+
"cwd": "${workspaceFolder}/.."
320+
},
321+
"problemMatcher": [
322+
"$gcc"
323+
],
324+
"presentation": {
325+
"echo": true,
326+
"reveal": "silent",
327+
"focus": false,
328+
"panel": "shared",
329+
"clear": true
330+
},
331+
"group": {
332+
"kind": "build"
333+
},
334+
"label": "ios_debug_unopt_arm64",
335+
"args": [
336+
"build",
337+
"-c",
338+
"host_debug_unopt_arm64",
339+
"&&",
340+
"./flutter/bin/et",
341+
"build",
342+
"-c",
343+
"ios_debug_unopt"
344+
]
345+
},
346+
{
347+
"type": "shell",
348+
"command": "./flutter/bin/et",
349+
"options": {
350+
"cwd": "${workspaceFolder}/.."
351+
},
352+
"problemMatcher": [
353+
"$gcc"
354+
],
355+
"presentation": {
356+
"echo": true,
357+
"reveal": "silent",
358+
"focus": false,
359+
"panel": "shared",
360+
"clear": true
361+
},
362+
"group": {
363+
"kind": "build"
364+
},
365+
"label": "android_debug_unopt_arm64",
366+
"args": [
367+
"build",
368+
"-c",
369+
"host_debug_unopt_arm64",
370+
"&&",
371+
"./flutter/bin/et",
372+
"build",
373+
"-c",
374+
"android_debug_unopt_arm64"
375+
]
288376
}
289377
]
290378
},

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)