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