| Flutter Impeller |

aiks_dl_vertices_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "display_list/dl_sampling_options.h"
6 #include "display_list/dl_tile_mode.h"
7 #include "display_list/dl_vertices.h"
8 #include "display_list/effects/dl_mask_filter.h"
9 #include "flutter/impeller/display_list/aiks_unittests.h"
10
11 #include "flutter/display_list/dl_blend_mode.h"
12 #include "flutter/display_list/dl_builder.h"
13 #include "flutter/display_list/dl_color.h"
14 #include "flutter/display_list/dl_paint.h"
15 #include "flutter/testing/testing.h"
16 #include "impeller/display_list/dl_dispatcher.h"
17 #include "impeller/display_list/dl_image_impeller.h"
18 #include "impeller/display_list/dl_runtime_effect_impeller.h"
19
20 namespace impeller {
21 namespace testing {
22
23 using namespace flutter;
24
25 namespace {
26 std::shared_ptr<DlVertices> MakeVertices(
27 DlVertexMode mode,
28 std::vector<DlPoint> vertices,
29 std::vector<uint16_t> indices,
30 std::vector<DlPoint> texture_coordinates,
31 std::vector<DlColor> colors) {
32 DlVertices::Builder::Flags flags(
33 {{texture_coordinates.size() > 0, colors.size() > 0}});
34 DlVertices::Builder builder(mode, vertices.size(), flags, indices.size());
35 if (colors.size() > 0) {
36 builder.store_colors(colors.data());
37 }
38 if (texture_coordinates.size() > 0) {
39 builder.store_texture_coordinates(texture_coordinates.data());
40 }
41 if (indices.size() > 0) {
42 builder.store_indices(indices.data());
43 }
44 builder.store_vertices(vertices.data());
45 return builder.build();
46 }
47 }; // namespace
48
49 // Regression test for https://github.com/flutter/flutter/issues/135441 .
50 TEST_P(AiksTest, VerticesGeometryUVPositionData) {
51 DisplayListBuilder builder;
52 DlPaint paint;
53 auto image =
54 DlImageImpeller::Make(CreateTextureForFixture("table_mountain_nx.png"));
55 auto size = image->impeller_texture()->GetSize();
56
57 paint.setColorSource(
58 DlColorSource::MakeImage(image, DlTileMode::kClamp, DlTileMode::kClamp));
59
60 std::vector<DlPoint> vertex_coordinates = {
61 DlPoint(0, 0),
62 DlPoint(size.width, 0),
63 DlPoint(0, size.height),
64 };
65 auto vertices = MakeVertices(DlVertexMode::kTriangleStrip, vertex_coordinates,
66 {0, 1, 2}, {}, {});
67
68 builder.DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
69 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
70 }
71
72 // Regression test for https://github.com/flutter/flutter/issues/135441 .
73 TEST_P(AiksTest, VerticesGeometryUVPositionDataWithTranslate) {
74 DisplayListBuilder builder;
75 DlPaint paint;
76 auto image =
77 DlImageImpeller::Make(CreateTextureForFixture("table_mountain_nx.png"));
78 auto size = image->impeller_texture()->GetSize();
79
80 DlMatrix matrix = DlMatrix::MakeTranslation({100, 100});
81 paint.setColorSource(
82 DlColorSource::MakeImage(image, DlTileMode::kClamp, DlTileMode::kClamp,
83 DlImageSampling::kLinear, &matrix));
84
85 std::vector<DlPoint> positions = {
86 DlPoint(0, 0),
87 DlPoint(size.width, 0),
88 DlPoint(0, size.height),
89 };
90 auto vertices =
91 MakeVertices(DlVertexMode::kTriangleStrip, positions, {0, 1, 2}, {}, {});
92
93 builder.DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
94 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
95 }
96
97 // Regression test for https://github.com/flutter/flutter/issues/145707
98 TEST_P(AiksTest, VerticesGeometryColorUVPositionData) {
99 DisplayListBuilder builder;
100 DlPaint paint;
101 auto image =
102 DlImageImpeller::Make(CreateTextureForFixture("table_mountain_nx.png"));
103 auto size = image->impeller_texture()->GetSize();
104
105 paint.setColorSource(
106 DlColorSource::MakeImage(image, DlTileMode::kClamp, DlTileMode::kClamp));
107
108 std::vector<DlPoint> positions = {
109 DlPoint(0, 0), DlPoint(size.width, 0),
110 DlPoint(0, size.height), DlPoint(size.width, 0),
111 DlPoint(0, 0), DlPoint(size.width, size.height),
112 };
113 std::vector<DlColor> colors = {
114 DlColor::kRed().withAlpha(128), DlColor::kBlue().withAlpha(128),
115 DlColor::kGreen().withAlpha(128), DlColor::kRed().withAlpha(128),
116 DlColor::kBlue().withAlpha(128), DlColor::kGreen().withAlpha(128),
117 };
118
119 auto vertices =
120 MakeVertices(DlVertexMode::kTriangles, positions, {}, {}, colors);
121
122 builder.DrawVertices(vertices, DlBlendMode::kDstOver, paint);
123 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
124 }
125
126 TEST_P(AiksTest, VerticesGeometryColorUVPositionDataAdvancedBlend) {
127 DisplayListBuilder builder;
128 DlPaint paint;
129 auto image =
130 DlImageImpeller::Make(CreateTextureForFixture("table_mountain_nx.png"));
131 auto size = image->impeller_texture()->GetSize();
132
133 paint.setColorSource(
134 DlColorSource::MakeImage(image, DlTileMode::kClamp, DlTileMode::kClamp));
135
136 std::vector<DlPoint> positions = {
137 DlPoint(0, 0), DlPoint(size.width, 0),
138 DlPoint(0, size.height), DlPoint(size.width, 0),
139 DlPoint(0, 0), DlPoint(size.width, size.height),
140 };
141 std::vector<DlColor> colors = {
142 DlColor::kRed().modulateOpacity(0.5),
143 DlColor::kBlue().modulateOpacity(0.5),
144 DlColor::kGreen().modulateOpacity(0.5),
145 DlColor::kRed().modulateOpacity(0.5),
146 DlColor::kBlue().modulateOpacity(0.5),
147 DlColor::kGreen().modulateOpacity(0.5),
148 };
149
150 auto vertices =
151 MakeVertices(DlVertexMode::kTriangles, positions, {}, {}, colors);
152
153 builder.DrawVertices(vertices, DlBlendMode::kColorBurn, paint);
154 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
155 }
156
157 // Draw a hexagon using triangle fan
158 TEST_P(AiksTest, CanConvertTriangleFanToTriangles) {
159 constexpr Scalar hexagon_radius = 125;
160 auto hex_start = Point(200.0, -hexagon_radius + 200.0);
161 auto center_to_flat = 1.73 / 2 * hexagon_radius;
162
163 // clang-format off
164 std::vector<DlPoint> vertices = {
165 DlPoint(hex_start.x, hex_start.y),
166 DlPoint(hex_start.x + center_to_flat, hex_start.y + 0.5 * hexagon_radius),
167 DlPoint(hex_start.x + center_to_flat, hex_start.y + 1.5 * hexagon_radius),
168 DlPoint(hex_start.x + center_to_flat, hex_start.y + 1.5 * hexagon_radius),
169 DlPoint(hex_start.x, hex_start.y + 2 * hexagon_radius),
170 DlPoint(hex_start.x, hex_start.y + 2 * hexagon_radius),
171 DlPoint(hex_start.x - center_to_flat, hex_start.y + 1.5 * hexagon_radius),
172 DlPoint(hex_start.x - center_to_flat, hex_start.y + 1.5 * hexagon_radius),
173 DlPoint(hex_start.x - center_to_flat, hex_start.y + 0.5 * hexagon_radius)
174 };
175 // clang-format on
176 auto paint = flutter::DlPaint(flutter::DlColor::kDarkGrey());
177 auto dl_vertices = flutter::DlVertices::Make(
178 flutter::DlVertexMode::kTriangleFan, vertices.size(), vertices.data(),
179 nullptr, nullptr);
180 flutter::DisplayListBuilder builder;
181 builder.DrawVertices(dl_vertices, flutter::DlBlendMode::kSrcOver, paint);
182 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
183 }
184
185 TEST_P(AiksTest, DrawVerticesSolidColorTrianglesWithoutIndices) {
186 // Use negative coordinates and then scale the transform by -1, -1 to make
187 // sure coverage is taking the transform into account.
188 std::vector<DlPoint> positions = {
189 DlPoint(-100, -300),
190 DlPoint(-200, -100),
191 DlPoint(-300, -300),
192 };
193 std::vector<flutter::DlColor> colors = {flutter::DlColor::kWhite(),
194 flutter::DlColor::kGreen(),
195 flutter::DlColor::kWhite()};
196
197 auto vertices = flutter::DlVertices::Make(
198 flutter::DlVertexMode::kTriangles, 3, positions.data(),
199 /*texture_coordinates=*/nullptr, colors.data());
200
201 flutter::DisplayListBuilder builder;
202 flutter::DlPaint paint;
203
204 paint.setColor(flutter::DlColor::kRed().modulateOpacity(0.5));
205 builder.Scale(-1, -1);
206 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
207
208 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
209 }
210
211 TEST_P(AiksTest, DrawVerticesLinearGradientWithoutIndices) {
212 std::vector<DlPoint> positions = {
213 DlPoint(100, 300),
214 DlPoint(200, 100),
215 DlPoint(300, 300),
216 };
217
218 auto vertices = flutter::DlVertices::Make(
219 flutter::DlVertexMode::kTriangles, 3, positions.data(),
220 /*texture_coordinates=*/nullptr, /*colors=*/nullptr);
221
222 std::vector<flutter::DlColor> colors = {flutter::DlColor::kBlue(),
223 flutter::DlColor::kRed()};
224 const float stops[2] = {0.0, 1.0};
225
226 auto linear = flutter::DlColorSource::MakeLinear(
227 {100.0, 100.0}, {300.0, 300.0}, 2, colors.data(), stops,
228 flutter::DlTileMode::kRepeat);
229
230 flutter::DisplayListBuilder builder;
231 flutter::DlPaint paint;
232
233 paint.setColorSource(linear);
234 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
235
236 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
237 }
238
239 TEST_P(AiksTest, DrawVerticesLinearGradientWithTextureCoordinates) {
240 std::vector<DlPoint> positions = {
241 DlPoint(100, 300),
242 DlPoint(200, 100),
243 DlPoint(300, 300),
244 };
245 std::vector<DlPoint> texture_coordinates = {
246 DlPoint(300, 100),
247 DlPoint(100, 200),
248 DlPoint(300, 300),
249 };
250
251 auto vertices = flutter::DlVertices::Make(
252 flutter::DlVertexMode::kTriangles, 3, positions.data(),
253 texture_coordinates.data(), /*colors=*/nullptr);
254
255 std::vector<flutter::DlColor> colors = {flutter::DlColor::kBlue(),
256 flutter::DlColor::kRed()};
257 const float stops[2] = {0.0, 1.0};
258
259 auto linear = flutter::DlColorSource::MakeLinear(
260 {100.0, 100.0}, {300.0, 300.0}, 2, colors.data(), stops,
261 flutter::DlTileMode::kRepeat);
262
263 flutter::DisplayListBuilder builder;
264 flutter::DlPaint paint;
265
266 paint.setColorSource(linear);
267 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
268
269 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
270 }
271
272 TEST_P(AiksTest, DrawVerticesImageSourceWithTextureCoordinates) {
273 auto texture = CreateTextureForFixture("embarcadero.jpg");
274 auto dl_image = DlImageImpeller::Make(texture);
275 std::vector<DlPoint> positions = {
276 DlPoint(100, 300),
277 DlPoint(200, 100),
278 DlPoint(300, 300),
279 };
280 std::vector<DlPoint> texture_coordinates = {
281 DlPoint(0, 0),
282 DlPoint(100, 200),
283 DlPoint(200, 100),
284 };
285
286 auto vertices = flutter::DlVertices::Make(
287 flutter::DlVertexMode::kTriangles, 3, positions.data(),
288 texture_coordinates.data(), /*colors=*/nullptr);
289
290 flutter::DisplayListBuilder builder;
291 flutter::DlPaint paint;
292
293 auto image_source = flutter::DlColorSource::MakeImage(
294 dl_image, flutter::DlTileMode::kRepeat, flutter::DlTileMode::kRepeat);
295
296 paint.setColorSource(image_source);
297 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
298
299 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
300 }
301
302 TEST_P(AiksTest,
303 DrawVerticesImageSourceWithTextureCoordinatesAndColorBlending) {
304 auto texture = CreateTextureForFixture("embarcadero.jpg");
305 auto dl_image = DlImageImpeller::Make(texture);
306 std::vector<DlPoint> positions = {
307 DlPoint(100, 300),
308 DlPoint(200, 100),
309 DlPoint(300, 300),
310 };
311 std::vector<flutter::DlColor> colors = {flutter::DlColor::kWhite(),
312 flutter::DlColor::kGreen(),
313 flutter::DlColor::kWhite()};
314 std::vector<DlPoint> texture_coordinates = {
315 DlPoint(0, 0),
316 DlPoint(100, 200),
317 DlPoint(200, 100),
318 };
319
320 auto vertices = flutter::DlVertices::Make(
321 flutter::DlVertexMode::kTriangles, 3, positions.data(),
322 texture_coordinates.data(), colors.data());
323
324 flutter::DisplayListBuilder builder;
325 flutter::DlPaint paint;
326
327 auto image_source = flutter::DlColorSource::MakeImage(
328 dl_image, flutter::DlTileMode::kRepeat, flutter::DlTileMode::kRepeat);
329
330 paint.setColorSource(image_source);
331 builder.DrawVertices(vertices, flutter::DlBlendMode::kModulate, paint);
332
333 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
334 }
335
336 TEST_P(AiksTest, DrawVerticesSolidColorTrianglesWithIndices) {
337 std::vector<DlPoint> positions = {
338 DlPoint(100, 300),
339 DlPoint(200, 100),
340 DlPoint(300, 300),
341 DlPoint(200, 500),
342 };
343 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3};
344
345 auto vertices = flutter::DlVertices::Make(
346 flutter::DlVertexMode::kTriangles, positions.size(), positions.data(),
347 /*texture_coordinates=*/nullptr, /*colors=*/nullptr, indices.size(),
348 indices.data());
349
350 flutter::DisplayListBuilder builder;
351 flutter::DlPaint paint;
352
353 paint.setColor(flutter::DlColor::kRed());
354 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
355
356 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
357 }
358
359 TEST_P(AiksTest, DrawVerticesPremultipliesColors) {
360 std::vector<DlPoint> positions = {
361 DlPoint(100, 300),
362 DlPoint(200, 100),
363 DlPoint(300, 300),
364 DlPoint(200, 500),
365 };
366 auto color = flutter::DlColor::kBlue().withAlpha(0x99);
367 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3};
368 std::vector<flutter::DlColor> colors = {color, color, color, color};
369
370 auto vertices = flutter::DlVertices::Make(
371 flutter::DlVertexMode::kTriangles, positions.size(), positions.data(),
372 /*texture_coordinates=*/nullptr, colors.data(), indices.size(),
373 indices.data());
374
375 flutter::DisplayListBuilder builder;
376 flutter::DlPaint paint;
377 paint.setBlendMode(flutter::DlBlendMode::kSrcOver);
378 paint.setColor(flutter::DlColor::kRed());
379
380 builder.DrawRect(DlRect::MakeLTRB(0, 0, 400, 400), paint);
381 builder.DrawVertices(vertices, flutter::DlBlendMode::kDst, paint);
382
383 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
384 }
385
386 TEST_P(AiksTest, DrawVerticesWithInvalidIndices) {
387 std::vector<DlPoint> positions = {
388 DlPoint(100, 300),
389 DlPoint(200, 100),
390 DlPoint(300, 300),
391 DlPoint(200, 500),
392 };
393 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3, 99, 100, 101};
394
395 auto vertices = flutter::DlVertices::Make(
396 flutter::DlVertexMode::kTriangles, positions.size(), positions.data(),
397 /*texture_coordinates=*/nullptr, /*colors=*/nullptr, indices.size(),
398 indices.data());
399
400 EXPECT_EQ(vertices->GetBounds(), DlRect::MakeLTRB(100, 100, 300, 500));
401
402 flutter::DisplayListBuilder builder;
403 flutter::DlPaint paint;
404 paint.setBlendMode(flutter::DlBlendMode::kSrcOver);
405 paint.setColor(flutter::DlColor::kRed());
406
407 builder.DrawRect(DlRect::MakeLTRB(0, 0, 400, 400), paint);
408 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrc, paint);
409
410 AiksContext renderer(GetContext(), nullptr);
411 std::shared_ptr<Texture> image =
412 DisplayListToTexture(builder.Build(), {1024, 768}, renderer);
413 EXPECT_TRUE(image);
414 }
415
416 // All four vertices should form a solid red rectangle with no gaps.
417 // The blue rectangle drawn under them should not be visible.
418 TEST_P(AiksTest, DrawVerticesTextureCoordinatesWithFragmentShader) {
419 std::vector<DlPoint> positions_lt = {
420 DlPoint(0, 0), //
421 DlPoint(50, 0), //
422 DlPoint(0, 50), //
423 DlPoint(50, 50), //
424 };
425
426 auto vertices_lt = flutter::DlVertices::Make(
427 flutter::DlVertexMode::kTriangleStrip, positions_lt.size(),
428 positions_lt.data(),
429 /*texture_coordinates=*/positions_lt.data(), /*colors=*/nullptr,
430 /*index_count=*/0,
431 /*indices=*/nullptr);
432
433 std::vector<DlPoint> positions_rt = {
434 DlPoint(50, 0), //
435 DlPoint(100, 0), //
436 DlPoint(50, 50), //
437 DlPoint(100, 50), //
438 };
439
440 auto vertices_rt = flutter::DlVertices::Make(
441 flutter::DlVertexMode::kTriangleStrip, positions_rt.size(),
442 positions_rt.data(),
443 /*texture_coordinates=*/positions_rt.data(), /*colors=*/nullptr,
444 /*index_count=*/0,
445 /*indices=*/nullptr);
446
447 std::vector<DlPoint> positions_lb = {
448 DlPoint(0, 50), //
449 DlPoint(50, 50), //
450 DlPoint(0, 100), //
451 DlPoint(50, 100), //
452 };
453
454 auto vertices_lb = flutter::DlVertices::Make(
455 flutter::DlVertexMode::kTriangleStrip, positions_lb.size(),
456 positions_lb.data(),
457 /*texture_coordinates=*/positions_lb.data(), /*colors=*/nullptr,
458 /*index_count=*/0,
459 /*indices=*/nullptr);
460
461 std::vector<DlPoint> positions_rb = {
462 DlPoint(50, 50), //
463 DlPoint(100, 50), //
464 DlPoint(50, 100), //
465 DlPoint(100, 100), //
466 };
467
468 auto vertices_rb = flutter::DlVertices::Make(
469 flutter::DlVertexMode::kTriangleStrip, positions_rb.size(),
470 positions_rb.data(),
471 /*texture_coordinates=*/positions_rb.data(), /*colors=*/nullptr,
472 /*index_count=*/0,
473 /*indices=*/nullptr);
474
475 flutter::DisplayListBuilder builder;
476 flutter::DlPaint paint;
477 flutter::DlPaint rect_paint;
478 rect_paint.setColor(DlColor::kBlue());
479
480 auto runtime_stages =
481 OpenAssetAsRuntimeStage("runtime_stage_simple.frag.iplr");
482
483 auto runtime_stage =
484 runtime_stages[PlaygroundBackendToRuntimeStageBackend(GetBackend())];
485 ASSERT_TRUE(runtime_stage);
486
487 auto runtime_effect = DlRuntimeEffectImpeller::Make(runtime_stage);
488 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
489 auto color_source = flutter::DlColorSource::MakeRuntimeEffect(
490 runtime_effect, {}, uniform_data);
491
492 paint.setColorSource(color_source);
493
494 builder.Scale(GetContentScale().x, GetContentScale().y);
495 builder.Save();
496 builder.DrawRect(DlRect::MakeLTRB(0, 0, 100, 100), rect_paint);
497 builder.DrawVertices(vertices_lt, flutter::DlBlendMode::kSrcOver, paint);
498 builder.DrawVertices(vertices_rt, flutter::DlBlendMode::kSrcOver, paint);
499 builder.DrawVertices(vertices_lb, flutter::DlBlendMode::kSrcOver, paint);
500 builder.DrawVertices(vertices_rb, flutter::DlBlendMode::kSrcOver, paint);
501 builder.Restore();
502
503 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
504 }
505
506 // The vertices should form a solid red rectangle with no gaps.
507 // The blue rectangle drawn under them should not be visible.
508 TEST_P(AiksTest,
509 DrawVerticesTextureCoordinatesWithFragmentShaderNonZeroOrigin) {
510 std::vector<DlPoint> positions_lt = {
511 DlPoint(200, 200), //
512 DlPoint(250, 200), //
513 DlPoint(200, 250), //
514 DlPoint(250, 250), //
515 };
516
517 auto vertices = flutter::DlVertices::Make(
518 flutter::DlVertexMode::kTriangleStrip, positions_lt.size(),
519 positions_lt.data(),
520 /*texture_coordinates=*/positions_lt.data(), /*colors=*/nullptr,
521 /*index_count=*/0,
522 /*indices=*/nullptr);
523
524 flutter::DisplayListBuilder builder;
525 flutter::DlPaint paint;
526 flutter::DlPaint rect_paint;
527 rect_paint.setColor(DlColor::kBlue());
528
529 auto runtime_stages =
530 OpenAssetAsRuntimeStage("runtime_stage_position.frag.iplr");
531
532 auto runtime_stage =
533 runtime_stages[PlaygroundBackendToRuntimeStageBackend(GetBackend())];
534 ASSERT_TRUE(runtime_stage);
535
536 auto runtime_effect = DlRuntimeEffectImpeller::Make(runtime_stage);
537 auto rect_data = std::vector<Rect>{Rect::MakeLTRB(200, 200, 250, 250)};
538
539 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
540 uniform_data->resize(rect_data.size() * sizeof(Rect));
541 memcpy(uniform_data->data(), rect_data.data(), uniform_data->size());
542
543 auto color_source = flutter::DlColorSource::MakeRuntimeEffect(
544 runtime_effect, {}, uniform_data);
545
546 paint.setColorSource(color_source);
547
548 builder.Scale(GetContentScale().x, GetContentScale().y);
549 builder.DrawRect(DlRect::MakeLTRB(200, 200, 250, 250), rect_paint);
550 builder.DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
551
552 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
553 }
554
555 // Regression test for https://github.com/flutter/flutter/issues/170480 .
556 TEST_P(AiksTest, VerticesGeometryWithMaskFilter) {
557 DisplayListBuilder builder;
558 DlPaint paint;
559 paint.setMaskFilter(DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 10));
560
561 std::vector<DlPoint> vertex_coordinates = {
562 DlPoint(0, 0),
563 DlPoint(400, 0),
564 DlPoint(0, 400),
565 };
566 auto vertices = MakeVertices(DlVertexMode::kTriangleStrip, vertex_coordinates,
567 {0, 1, 2}, {}, {});
568
569 builder.DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
570 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
571 }
572
573 } // namespace testing
574 } // namespace impeller
aiks_unittests.h
flutter::DlRuntimeEffectImpeller::Make
static sk_sp< DlRuntimeEffect > Make(std::shared_ptr< impeller::RuntimeStage > runtime_stage)
Definition: dl_runtime_effect_impeller.cc:14
impeller::AiksContext
Definition: aiks_context.h:20
impeller::AiksPlayground
Definition: aiks_playground.h:16
impeller::DlImageImpeller::Make
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
Definition: dl_image_impeller.cc:23
dl_dispatcher.h
x
int32_t x
Definition: dl_golden_unittests.cc:458
dl_image_impeller.h
dl_runtime_effect_impeller.h
flutter
Definition: dl_golden_blur_unittests.cc:16
impeller::testing::TEST_P
TEST_P(AiksTest, DrawAtlasNoColor)
Definition: aiks_dl_atlas_unittests.cc:59
impeller
Definition: allocation.cc:12
impeller::DisplayListToTexture
std::shared_ptr< Texture > DisplayListToTexture(const sk_sp< flutter::DisplayList > &display_list, ISize size, AiksContext &context, bool reset_host_buffer, bool generate_mips)
Render the provided display list to a texture with the given size.
Definition: dl_dispatcher.cc:1214
impeller::Scalar
float Scalar
Definition: scalar.h:19
impeller::PlaygroundBackendToRuntimeStageBackend
constexpr RuntimeStageBackend PlaygroundBackendToRuntimeStageBackend(PlaygroundBackend backend)
Definition: playground.h:33
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:788
impeller::Point
TPoint< Scalar > Point
Definition: point.h:327
impeller::DlPoint
flutter::DlPoint DlPoint
Definition: dl_dispatcher.h:24
impeller::TRect< Scalar >::MakeLTRB
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129