19#include "third_party/abseil-cpp/absl/status/status_matchers.h"
27std::shared_ptr<DlVertices> MakeVertices(
29 std::vector<DlPoint> vertices,
30 std::vector<uint16_t> indices,
31 std::vector<DlPoint> texture_coordinates,
32 std::vector<DlColor> colors) {
34 {{texture_coordinates.size() > 0, colors.size() > 0}});
36 if (colors.size() > 0) {
37 builder.store_colors(colors.data());
39 if (texture_coordinates.size() > 0) {
40 builder.store_texture_coordinates(texture_coordinates.data());
42 if (indices.size() > 0) {
43 builder.store_indices(indices.data());
45 builder.store_vertices(vertices.data());
46 return builder.build();
56 auto size =
image->impeller_texture()->GetSize();
61 std::vector<DlPoint> vertex_coordinates = {
66 auto vertices = MakeVertices(DlVertexMode::kTriangleStrip, vertex_coordinates,
69 builder.
DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
70 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
79 auto size =
image->impeller_texture()->GetSize();
84 DlImageSampling::kLinear, &matrix));
86 std::vector<DlPoint> positions = {
92 MakeVertices(DlVertexMode::kTriangleStrip, positions, {0, 1, 2}, {}, {});
94 builder.
DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
95 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
104 auto size =
image->impeller_texture()->GetSize();
109 std::vector<DlPoint> positions = {
114 std::vector<DlColor> colors = {
121 MakeVertices(DlVertexMode::kTriangles, positions, {}, {}, colors);
123 builder.
DrawVertices(vertices, DlBlendMode::kDstOver, paint);
124 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
132 auto size =
image->impeller_texture()->GetSize();
137 std::vector<DlPoint> positions = {
142 std::vector<DlColor> colors = {
152 MakeVertices(DlVertexMode::kTriangles, positions, {}, {}, colors);
154 builder.
DrawVertices(vertices, DlBlendMode::kColorBurn, paint);
155 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
160 constexpr Scalar hexagon_radius = 125;
161 auto hex_start =
Point(200.0, -hexagon_radius + 200.0);
162 auto center_to_flat = 1.73 / 2 * hexagon_radius;
165 std::vector<DlPoint> vertices = {
166 DlPoint(hex_start.x, hex_start.y),
167 DlPoint(hex_start.x + center_to_flat, hex_start.y + 0.5 * hexagon_radius),
168 DlPoint(hex_start.x + center_to_flat, hex_start.y + 1.5 * hexagon_radius),
169 DlPoint(hex_start.x + center_to_flat, hex_start.y + 1.5 * hexagon_radius),
170 DlPoint(hex_start.x, hex_start.y + 2 * hexagon_radius),
171 DlPoint(hex_start.x, hex_start.y + 2 * 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 + 1.5 * hexagon_radius),
174 DlPoint(hex_start.x - center_to_flat, hex_start.y + 0.5 * hexagon_radius)
182 builder.
DrawVertices(dl_vertices, flutter::DlBlendMode::kSrcOver, paint);
183 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
189 std::vector<DlPoint> positions = {
200 nullptr, colors.data());
206 builder.
Scale(-1, -1);
207 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
209 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
213 std::vector<DlPoint> positions = {
225 const float stops[2] = {0.0, 1.0};
228 {100.0, 100.0}, {300.0, 300.0}, 2, colors.data(), stops,
235 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
237 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
241 std::vector<DlPoint> positions = {
246 std::vector<DlPoint> texture_coordinates = {
254 texture_coordinates.data(),
nullptr);
258 const float stops[2] = {0.0, 1.0};
261 {100.0, 100.0}, {300.0, 300.0}, 2, colors.data(), stops,
268 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
270 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
274 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
276 std::vector<DlPoint> positions = {
281 std::vector<DlPoint> texture_coordinates = {
289 texture_coordinates.data(),
nullptr);
298 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
300 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
304 DrawVerticesImageSourceWithTextureCoordinatesAndColorBlending) {
305 auto texture = CreateTextureForFixture(
"embarcadero.jpg");
307 std::vector<DlPoint> positions = {
315 std::vector<DlPoint> texture_coordinates = {
323 texture_coordinates.data(), colors.data());
332 builder.
DrawVertices(vertices, flutter::DlBlendMode::kModulate, paint);
334 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
338 std::vector<DlPoint> positions = {
344 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3};
348 nullptr,
nullptr, indices.size(),
355 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
357 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
361 std::vector<DlPoint> positions = {
368 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3};
369 std::vector<flutter::DlColor> colors = {color, color, color, color};
373 nullptr, colors.data(), indices.size(),
382 builder.
DrawVertices(vertices, flutter::DlBlendMode::kDst, paint);
384 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
388 std::vector<DlPoint> positions = {
394 std::vector<uint16_t> indices = {0, 1, 2, 0, 2, 3, 99, 100, 101};
398 nullptr,
nullptr, indices.size(),
409 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrc, paint);
412 std::shared_ptr<Texture>
image =
420 std::vector<DlPoint> positions_lt = {
430 positions_lt.data(),
nullptr,
434 std::vector<DlPoint> positions_rt = {
444 positions_rt.data(),
nullptr,
448 std::vector<DlPoint> positions_lb = {
458 positions_lb.data(),
nullptr,
462 std::vector<DlPoint> positions_rb = {
472 positions_rb.data(),
nullptr,
481 auto runtime_stages_result =
482 OpenAssetAsRuntimeStage(
"runtime_stage_simple.frag.iplr");
483 ABSL_ASSERT_OK(runtime_stages_result);
484 std::shared_ptr<RuntimeStage> runtime_stage =
485 runtime_stages_result
487 ASSERT_TRUE(runtime_stage);
490 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
492 runtime_effect, {}, uniform_data);
496 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
499 builder.
DrawVertices(vertices_lt, flutter::DlBlendMode::kSrcOver, paint);
500 builder.
DrawVertices(vertices_rt, flutter::DlBlendMode::kSrcOver, paint);
501 builder.
DrawVertices(vertices_lb, flutter::DlBlendMode::kSrcOver, paint);
502 builder.
DrawVertices(vertices_rb, flutter::DlBlendMode::kSrcOver, paint);
505 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
511 DrawVerticesTextureCoordinatesWithFragmentShaderNonZeroOrigin) {
512 std::vector<DlPoint> positions_lt = {
522 positions_lt.data(),
nullptr,
531 auto runtime_stages_result =
532 OpenAssetAsRuntimeStage(
"runtime_stage_position.frag.iplr");
533 ABSL_ASSERT_OK(runtime_stages_result);
534 std::shared_ptr<RuntimeStage> runtime_stage =
535 runtime_stages_result
537 ASSERT_TRUE(runtime_stage);
540 auto rect_data = std::vector<Rect>{
Rect::MakeLTRB(200, 200, 250, 250)};
542 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
543 uniform_data->resize(rect_data.size() *
sizeof(
Rect));
544 memcpy(uniform_data->data(), rect_data.data(), uniform_data->size());
547 runtime_effect, {}, uniform_data);
551 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
553 builder.
DrawVertices(vertices, flutter::DlBlendMode::kSrcOver, paint);
555 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
564 std::vector<DlPoint> vertex_coordinates = {
569 auto vertices = MakeVertices(DlVertexMode::kTriangleStrip, vertex_coordinates,
572 builder.
DrawVertices(vertices, DlBlendMode::kSrcOver, paint);
573 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, std::optional< PixelFormat > target_pixel_format)
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...