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);
515 auto command_buffer = GetContext()->CreateCommandBuffer();
516 auto blit_pass = command_buffer->CreateBlitPass();
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()));
595 auto context = MakeContext();
596 std::weak_ptr<Texture> weak_texture;
599 auto texture = CreateTextureForFixture(
"table_mountain_nx.png");
603 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
609 DlImageSampling::kLinear,
nullptr));
613 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
624 ASSERT_TRUE(weak_texture.expired()) <<
"When the texture is no longer in use "
625 "by the backend, it should be "
631 auto callback = [&]() -> sk_sp<DisplayList> {
633 ImGuiWindowFlags_AlwaysAutoResize)) {
634 ImGui::SliderFloat(
"Scale", &scale, 1, 2);
638 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
655 return builder.
Build();
658 ASSERT_TRUE(OpenPlaygroundHere(
callback));
663 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
665 auto test = [&builder](
const std::shared_ptr<DlImageFilter>& filter) {
718 const float m[20] = {
724 auto rgb_swap_filter =
726 test(rgb_swap_filter);
734 test(rotate_filter->makeWithLocalMatrix(
739 test(rgb_swap_filter->makeWithLocalMatrix(
747 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
756 builder.
SaveLayer(std::nullopt,
nullptr);
774 auto backdrop_filter =
776 builder.
SaveLayer(std::nullopt,
nullptr, backdrop_filter.get());
781 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
790 builder.
SaveLayer(std::nullopt,
nullptr);
806 builder.
SaveLayer(std::nullopt, &save_paint);
816 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
821 std::vector<DlPoint> point = {
832 builder.
Scale(0.000001, 0.000001);
834 builder.
DrawPoints(DlPointMode::kPoints, point.size(), point.data(), paint);
836 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
841 std::vector<DlPoint> point = {
852 builder.
Scale(1000000, 1000000);
854 builder.
DrawPoints(DlPointMode::kPoints, point.size(), point.data(), paint);
855 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
861 builder.
Scale(1.618, 1.618);
867 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
875 auto display_list = sub_builder.
Build();
884 builder.
Scale(2.0, 2.0);
889 0.8, -0.2, -0.1, -0.0,
892 63.2, 65.3, 48.6, 1.1
898 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
920 auto backdrop_filter =
922 builder.
SaveLayer(std::nullopt,
nullptr, backdrop_filter.get());
931 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
955 ASSERT_TRUE(OpenPlaygroundHere(canvas.
Build()));
981 ASSERT_TRUE(OpenPlaygroundHere(recorder_builder.
Build()));
993 .setDrawStyle(DlDrawStyle::kStroke)
998 std::vector<DlPoint>
points = {
1009 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1021 .setDrawStyle(DlDrawStyle::kStroke)
1022 .setStrokeWidth(5));
1026 std::vector<DlPoint>
points = {
1037 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
1056 desc.
size =
texture->GetTextureDescriptor().GetByteSizeOfBaseMipLevel();
1060 auto device_buffer = GetContext()->GetResourceAllocator()->CreateBuffer(desc);
1062 auto cmd_buffer = GetContext()->CreateCommandBuffer();
1063 auto blit_pass = cmd_buffer->CreateBlitPass();
1065 blit_pass->AddCopy(
texture, device_buffer);
1066 blit_pass->EncodeCommands();
1068 auto latch = std::make_shared<fml::CountDownLatch>(1u);
1069 GetContext()->GetCommandQueue()->Submit(
1076 auto reupload_texture =
1077 GetContext()->GetResourceAllocator()->CreateTexture(tex_desc);
1081 auto cmd_buffer = GetContext()->CreateCommandBuffer();
1082 auto blit_pass = cmd_buffer->CreateBlitPass();
1085 blit_pass->ConvertTextureToShaderRead(
texture);
1086 blit_pass->EncodeCommands();
1088 auto latch = std::make_shared<fml::CountDownLatch>(1u);
1089 GetContext()->GetCommandQueue()->Submit(
1102 DlImageSampling::kNearestNeighbor, &paint);
1108 DlImageSampling::kNearestNeighbor, &paint);
1109 OpenPlaygroundHere(canvas.
Build());
1128 std::shared_ptr<DlImageFilter> filter =
1130 builder.
SaveLayer(std::nullopt,
nullptr, filter.get());
1140 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)
ContentContext & GetContentContext() const
std::shared_ptr< Context > GetContext() const
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
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)
Render the provided display list to a texture with the given size.
constexpr float k1OverSqrt2
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