23#include "gtest/gtest.h"
51 builder.
SaveLayer(std::nullopt, &save_paint);
57 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
70 builder.
SaveLayer(std::nullopt,
nullptr, filter.get());
76 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
83 const float matrix[20] = {
102 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
119 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
136 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
148 builder.
SaveLayer(std::nullopt, &save_paint);
152 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
176 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
191 builder.
SaveLayer(std::nullopt, &save_paint);
198 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
214 builder.
SaveLayer(std::nullopt, &save_paint);
222 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
227 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
232 builder.
SaveLayer(std::nullopt, &save_paint);
247 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
262 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
271 const float matrix[20] = {
284 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
293 const float matrix[20] = {
306 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
310 TranslucentSaveLayerWithColorFilterAndImageFilterDrawsCorrectly) {
316 const float matrix[20] = {
332 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
345 builder.
SaveLayer(std::nullopt, &save_paint);
352 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
380 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
395 builder.
SaveLayer(std::nullopt, &save_paint);
402 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
406 std::vector<DlPoint>
points = {
438 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
443 CreateTextureForFixture(
"table_mountain_nx.png",
446 std::vector<DlPoint>
points = {
478 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
483 texture_descriptor.
size =
ISize{1024, 1024};
488 std::vector<uint8_t> bytes(4194304);
489 bool alternate =
false;
490 for (
auto i = 0u;
i < 4194304;
i += 4) {
502 alternate = !alternate;
506 auto mapping = std::make_shared<fml::NonOwnedMapping>(
511 GetContext()->GetResourceAllocator()->CreateTexture(texture_descriptor);
514 GetContext()->GetResourceAllocator()->CreateBufferWithCopy(*mapping);
520 blit_pass->GenerateMipmap(
texture);
521 EXPECT_TRUE(blit_pass->EncodeCommands());
522 EXPECT_TRUE(GetContext()->GetCommandQueue()->Submit({
command_buffer}).ok());
532 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
557 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
561 auto bridge = CreateTextureForFixture(
"bay_bridge.jpg");
564 std::vector<uint8_t> bytes(100 * 100 * 4);
565 for (
auto i = 0u;
i < bytes.size();
i += 4) {
572 std::make_shared<fml::NonOwnedMapping>(bytes.data(), bytes.size());
574 GetContext()->GetResourceAllocator()->CreateBufferWithCopy(*mapping);
575 auto cmd_buffer = GetContext()->CreateCommandBuffer();
576 auto blit_pass = cmd_buffer->CreateBlitPass();
581 blit_pass->EncodeCommands() &&
582 GetContext()->GetCommandQueue()->Submit({std::move(cmd_buffer)}).ok();
583 ASSERT_TRUE(did_submit);
590 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
597 EnsureContextIsUnique();
600 std::weak_ptr<Texture> weak_texture;
603 auto texture = CreateTextureForFixture(
"table_mountain_nx.png");
607 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
613 DlImageSampling::kLinear,
nullptr));
617 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
628 ASSERT_TRUE(weak_texture.expired()) <<
"When the texture is no longer in use "
629 "by the backend, it should be "
635 auto callback = [&]() -> sk_sp<DisplayList> {
637 ImGuiWindowFlags_AlwaysAutoResize)) {
638 ImGui::SliderFloat(
"Scale", &scale, 1, 2);
642 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
659 return builder.
Build();
662 ASSERT_TRUE(OpenPlaygroundHere(
callback));
667 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
669 auto test = [&builder](
const std::shared_ptr<DlImageFilter>& filter) {
722 const float m[20] = {
728 auto rgb_swap_filter =
730 test(rgb_swap_filter);
738 test(rotate_filter->makeWithLocalMatrix(
743 test(rgb_swap_filter->makeWithLocalMatrix(
751 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
760 builder.
SaveLayer(std::nullopt,
nullptr);
778 auto backdrop_filter =
780 builder.
SaveLayer(std::nullopt,
nullptr, backdrop_filter.get());
785 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
794 builder.
SaveLayer(std::nullopt,
nullptr);
810 builder.
SaveLayer(std::nullopt, &save_paint);
820 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
825 std::vector<DlPoint> point = {
836 builder.
Scale(0.000001, 0.000001);
838 builder.
DrawPoints(DlPointMode::kPoints, point.size(), point.data(), paint);
840 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
845 std::vector<DlPoint> point = {
856 builder.
Scale(1000000, 1000000);
858 builder.
DrawPoints(DlPointMode::kPoints, point.size(), point.data(), paint);
859 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
865 builder.
Scale(1.618, 1.618);
871 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
879 auto display_list = sub_builder.
Build();
883 context.GetContentContext().GetRenderTargetCache()->CreateOffscreen(
884 *
context.GetContext(), {2400, 1800}, 1);
888 builder.
Scale(2.0, 2.0);
893 0.8, -0.2, -0.1, -0.0,
896 63.2, 65.3, 48.6, 1.1
902 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
924 auto backdrop_filter =
926 builder.
SaveLayer(std::nullopt,
nullptr, backdrop_filter.get());
935 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
959 ASSERT_TRUE(OpenPlaygroundHere(canvas.
Build()));
985 ASSERT_TRUE(OpenPlaygroundHere(recorder_builder.
Build()));
997 .setDrawStyle(DlDrawStyle::kStroke)
1002 std::vector<DlPoint>
points = {
1013 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1025 .setDrawStyle(DlDrawStyle::kStroke)
1026 .setStrokeWidth(5));
1030 std::vector<DlPoint>
points = {
1041 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1060 desc.
size =
texture->GetTextureDescriptor().GetByteSizeOfBaseMipLevel();
1064 auto device_buffer = GetContext()->GetResourceAllocator()->CreateBuffer(desc);
1066 auto cmd_buffer = GetContext()->CreateCommandBuffer();
1067 auto blit_pass = cmd_buffer->CreateBlitPass();
1069 blit_pass->AddCopy(
texture, device_buffer);
1070 blit_pass->EncodeCommands();
1072 auto latch = std::make_shared<fml::CountDownLatch>(1u);
1073 GetContext()->GetCommandQueue()->Submit(
1080 auto reupload_texture =
1081 GetContext()->GetResourceAllocator()->CreateTexture(tex_desc);
1085 auto cmd_buffer = GetContext()->CreateCommandBuffer();
1086 auto blit_pass = cmd_buffer->CreateBlitPass();
1089 blit_pass->ConvertTextureToShaderRead(
texture);
1090 blit_pass->EncodeCommands();
1092 auto latch = std::make_shared<fml::CountDownLatch>(1u);
1093 GetContext()->GetCommandQueue()->Submit(
1106 DlImageSampling::kNearestNeighbor, &paint);
1112 DlImageSampling::kNearestNeighbor, &paint);
1113 OpenPlaygroundHere(canvas.
Build());
1132 std::shared_ptr<DlImageFilter> filter =
1134 builder.
SaveLayer(std::nullopt,
nullptr, filter.get());
1144 EXPECT_FALSE(
texture->NeedsMipmapGeneration());
void ClipRect(const DlRect &rect, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void DrawImageRect(const sk_sp< DlImage > &image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, DlSrcRectConstraint constraint=DlSrcRectConstraint::kFast) override
void RestoreToCount(int restore_count) override
void DrawShadow(const DlPath &path, const DlColor color, const DlScalar elevation, bool transparent_occluder, DlScalar dpr) override
Draws the shadow of the given |path| rendered in the provided |color| (which is only consulted for it...
void DrawImage(const sk_sp< DlImage > &image, const DlPoint &point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
void DrawCircle(const DlPoint ¢er, DlScalar radius, const DlPaint &paint) override
void SaveLayer(const std::optional< DlRect > &bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt) override
void Rotate(DlScalar degrees) override
void Scale(DlScalar sx, DlScalar sy) override
void DrawDisplayList(const sk_sp< DisplayList > display_list, DlScalar opacity=SK_Scalar1) override
void Translate(DlScalar tx, DlScalar ty) override
void DrawPaint(const DlPaint &paint) override
sk_sp< DisplayList > Build()
void DrawPath(const DlPath &path, const DlPaint &paint) override
void ClipPath(const DlPath &path, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void DrawPoints(DlPointMode mode, uint32_t count, const DlPoint pts[], const DlPaint &paint) override
int GetSaveCount() const override
void TransformFullPerspective(DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt, DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt, DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt) override
void DrawRect(const DlRect &rect, const DlPaint &paint) override
static std::shared_ptr< const DlColorFilter > MakeBlend(DlColor color, DlBlendMode mode)
static std::shared_ptr< const DlColorFilter > MakeLinearToSrgbGamma()
static std::shared_ptr< const DlColorFilter > MakeMatrix(const float matrix[20])
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< DlImageFilter > MakeDilate(DlScalar radius_x, DlScalar radius_y)
static std::shared_ptr< DlImageFilter > MakeBlur(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode)
static std::shared_ptr< DlImageFilter > MakeColorFilter(const std::shared_ptr< const DlColorFilter > &filter)
static std::shared_ptr< DlImageFilter > MakeMatrix(const DlMatrix &matrix, DlImageSampling sampling)
static std::shared_ptr< DlImageFilter > MakeCompose(const std::shared_ptr< DlImageFilter > &outer, const std::shared_ptr< DlImageFilter > &inner)
static std::shared_ptr< DlImageFilter > MakeErode(DlScalar radius_x, DlScalar radius_y)
DlPaint & setColor(DlColor color)
DlPaint & setStrokeCap(DlStrokeCap cap)
DlPaint & setStrokeWidth(float width)
DlPaint & setAlpha(uint8_t alpha)
DlPaint & setBlendMode(DlBlendMode mode)
DlPaint & setImageFilter(std::nullptr_t filter)
DlPaint & setDrawStyle(DlDrawStyle style)
DlPaint & setColorFilter(std::nullptr_t filter)
DlPaint & setColorSource(std::nullptr_t source)
DlPathBuilder & LineTo(DlPoint p2)
Draw a line from the current point to the indicated point p2.
DlPathBuilder & MoveTo(DlPoint p2)
Start a new contour that will originate at the indicated point p2.
const DlPath TakePath()
Returns the path constructed by this path builder and resets its internal state to the default state ...
DlPathBuilder & Close()
The path is closed back to the location of the most recent MoveTo call. Contours that are filled are ...
static DlPath MakeLine(const DlPoint a, const DlPoint b)
static DlPath MakeCircle(const DlPoint center, DlScalar radius)
static DlPath MakeArc(const DlRect &bounds, DlDegrees start, DlDegrees sweep, bool use_center)
static DlPath MakeRect(const DlRect &rect)
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
FlutterVulkanImage * image
FlutterDesktopBinaryReply callback
impeller::Degrees DlDegrees
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
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 float k1OverSqrt2
std::shared_ptr< ContextGLES > context
std::shared_ptr< CommandBuffer > command_buffer
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor RGBA(DlScalar r, DlScalar g, DlScalar b, DlScalar a)
Construct a 32 bit color from floating point R, G, B, and A color channels.
static constexpr DlColor kBlack()
static constexpr DlColor kYellow()
static constexpr DlColor kCornflowerBlue()
static constexpr DlColor kTransparent()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
DlColor withAlpha(uint8_t alpha) const
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static Matrix MakeRotationZ(Radians r)
static constexpr Matrix MakeScale(const Vector3 &s)
static constexpr TPoint< Type > MakeXY(Type x, Type y)
static constexpr TRect MakeWH(Type width, Type height)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TRect MakeSize(const TSize< U > &size)
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
constexpr size_t MipCount() const
Return the mip count of the texture.
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
constexpr size_t GetByteSizeOfBaseMipLevel() const
std::vector< Point > points