26std::shared_ptr<DlVertices> MakeVertices(
28 std::vector<DlPoint> vertices,
29 std::vector<uint16_t> indices,
30 std::vector<DlPoint> texture_coordinates,
31 std::vector<DlColor> colors) {
33 {{texture_coordinates.size() > 0, colors.size() > 0}});
35 if (colors.size() > 0) {
36 builder.store_colors(colors.data());
38 if (texture_coordinates.size() > 0) {
39 builder.store_texture_coordinates(texture_coordinates.data());
41 if (indices.size() > 0) {
42 builder.store_indices(indices.data());
44 builder.store_vertices(vertices.data());
45 return builder.build();
55 auto size =
image->impeller_texture()->GetSize();
60 std::vector<DlPoint> vertex_coordinates = {
65 auto vertices = MakeVertices(DlVertexMode::kTriangleStrip, vertex_coordinates,
68 builder.
DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
69 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
78 auto size =
image->impeller_texture()->GetSize();
83 DlImageSampling::kLinear, &matrix));
85 std::vector<DlPoint> positions = {
91 MakeVertices(DlVertexMode::kTriangleStrip, positions, {0, 1, 2}, {}, {});
93 builder.
DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
94 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
103 auto size =
image->impeller_texture()->GetSize();
108 std::vector<DlPoint> positions = {
113 std::vector<DlColor> colors = {
120 MakeVertices(DlVertexMode::kTriangles, positions, {}, {}, colors);
122 builder.
DrawVertices(vertices, DlBlendMode::kDstOver, paint);
123 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
131 auto size =
image->impeller_texture()->GetSize();
136 std::vector<DlPoint> positions = {
141 std::vector<DlColor> colors = {
151 MakeVertices(DlVertexMode::kTriangles, positions, {}, {}, colors);
153 builder.
DrawVertices(vertices, DlBlendMode::kColorBurn, paint);
154 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
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;
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)
181 builder.
DrawVertices(dl_vertices, flutter::DlBlendMode::kSrcOver, paint);
182 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
188 std::vector<DlPoint> positions = {
199 nullptr, colors.data());
205 builder.
Scale(-1, -1);
206 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
208 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
212 std::vector<DlPoint> positions = {
224 const float stops[2] = {0.0, 1.0};
227 {100.0, 100.0}, {300.0, 300.0}, 2, colors.data(), stops,
234 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
236 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
240 std::vector<DlPoint> positions = {
245 std::vector<DlPoint> texture_coordinates = {
253 texture_coordinates.data(),
nullptr);
257 const float stops[2] = {0.0, 1.0};
260 {100.0, 100.0}, {300.0, 300.0}, 2, colors.data(), stops,
267 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
269 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
273 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
275 std::vector<DlPoint> positions = {
280 std::vector<DlPoint> texture_coordinates = {
288 texture_coordinates.data(),
nullptr);
297 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
299 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
303 DrawVerticesImageSourceWithTextureCoordinatesAndColorBlending) {
304 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
306 std::vector<DlPoint> positions = {
314 std::vector<DlPoint> texture_coordinates = {
322 texture_coordinates.data(), colors.data());
331 builder.
DrawVertices(vertices, flutter::DlBlendMode::kModulate, paint);
333 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
337 std::vector<DlPoint> positions = {
343 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3};
347 nullptr,
nullptr, indices.size(),
354 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
356 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
360 std::vector<DlPoint> positions = {
367 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3};
368 std::vector<flutter::DlColor> colors = {color, color, color, color};
372 nullptr, colors.data(), indices.size(),
381 builder.
DrawVertices(vertices, flutter::DlBlendMode::kDst, paint);
383 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
387 std::vector<DlPoint> positions = {
393 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3, 99, 100, 101};
397 nullptr,
nullptr, indices.size(),
408 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrc, paint);
411 std::shared_ptr<Texture>
image =
419 std::vector<DlPoint> positions_lt = {
429 positions_lt.data(),
nullptr,
433 std::vector<DlPoint> positions_rt = {
443 positions_rt.data(),
nullptr,
447 std::vector<DlPoint> positions_lb = {
457 positions_lb.data(),
nullptr,
461 std::vector<DlPoint> positions_rb = {
471 positions_rb.data(),
nullptr,
480 auto runtime_stages =
481 OpenAssetAsRuntimeStage(
"runtime_stage_simple.frag.iplr");
485 ASSERT_TRUE(runtime_stage);
488 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
490 runtime_effect, {}, uniform_data);
494 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
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);
503 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
509 DrawVerticesTextureCoordinatesWithFragmentShaderNonZeroOrigin) {
510 std::vector<DlPoint> positions_lt = {
520 positions_lt.data(),
nullptr,
529 auto runtime_stages =
530 OpenAssetAsRuntimeStage(
"runtime_stage_position.frag.iplr");
534 ASSERT_TRUE(runtime_stage);
537 auto rect_data = std::vector<Rect>{
Rect::MakeLTRB(200, 200, 250, 250)};
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());
544 runtime_effect, {}, uniform_data);
548 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
550 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
552 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
561 std::vector<DlPoint> vertex_coordinates = {
566 auto vertices = MakeVertices(DlVertexMode::kTriangleStrip, vertex_coordinates,
569 builder.
DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
570 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
void DrawVertices(const std::shared_ptr< DlVertices > &vertices, DlBlendMode mode, const DlPaint &paint) override
void Scale(DlScalar sx, DlScalar sy) override
sk_sp< DisplayList > Build()
void DrawRect(const DlRect &rect, const DlPaint &paint) override
static std::shared_ptr< DlMaskFilter > Make(DlBlurStyle style, SkScalar sigma, bool respect_ctm=true)
static std::shared_ptr< DlColorSource > MakeImage(const sk_sp< const DlImage > &image, DlTileMode horizontal_tile_mode, DlTileMode vertical_tile_mode, DlImageSampling sampling=DlImageSampling::kLinear, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeLinear(const DlPoint start_point, const DlPoint end_point, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeRuntimeEffect(sk_sp< DlRuntimeEffect > runtime_effect, std::vector< std::shared_ptr< DlColorSource > > samplers, std::shared_ptr< std::vector< uint8_t > > uniform_data)
DlPaint & setColor(DlColor color)
DlPaint & setBlendMode(DlBlendMode mode)
DlPaint & setMaskFilter(std::nullptr_t filter)
DlPaint & setColorSource(std::nullptr_t source)
static sk_sp< DlRuntimeEffect > Make(std::shared_ptr< impeller::RuntimeStage > runtime_stage)
A utility class to build up a |DlVertices| object one set of data at a time.
static std::shared_ptr< DlVertices > Make(DlVertexMode mode, int vertex_count, const DlPoint vertices[], const DlPoint texture_coordinates[], const DlColor colors[], int index_count=0, const uint16_t indices[]=nullptr, const DlRect *bounds=nullptr)
Constructs a DlVector with compact inline storage for all of its required and optional lists of data.
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
FlutterVulkanImage * image
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
DlVertexMode
Defines the way in which the vertices of a DlVertices object are separated into triangles into which ...
@ kTriangles
The vertices are taken 3 at a time to form a triangle.
TEST_P(AiksTest, DrawAtlasNoColor)
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.
constexpr RuntimeStageBackend PlaygroundBackendToRuntimeStageBackend(PlaygroundBackend backend)
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
static constexpr DlColor kDarkGrey()
DlColor withAlpha(uint8_t alpha) const
constexpr DlColor modulateOpacity(DlScalar opacity) const
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
flags to indicate/promise which of the optional texture coordinates or colors will be supplied during...