Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 0 additions & 99 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3013,105 +3013,6 @@ TEST_P(AiksTest, TextForegroundShaderWithTransform) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanCanvasDrawPicture) {
Canvas subcanvas;
subcanvas.DrawRect(Rect::MakeLTRB(-100, -50, 100, 50),
{.color = Color::CornflowerBlue()});
auto picture = subcanvas.EndRecordingAsPicture();

Canvas canvas;
canvas.Translate({200, 200});
canvas.Rotate(Radians(kPi / 4));
canvas.DrawPicture(picture);

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanCanvasDrawPictureWithAdvancedBlend) {
Canvas subcanvas;
subcanvas.DrawRect(
Rect::MakeLTRB(-100, -50, 100, 50),
{.color = Color::CornflowerBlue(), .blend_mode = BlendMode::kColorDodge});
auto picture = subcanvas.EndRecordingAsPicture();

Canvas canvas;
canvas.DrawPaint({.color = Color::Black()});
canvas.DrawCircle(Point::MakeXY(150, 150), 25, {.color = Color::Red()});
canvas.DrawPicture(picture);

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanCanvasDrawPictureWithBackdropFilter) {
Canvas subcanvas;
subcanvas.SaveLayer({}, {},
ImageFilter::MakeBlur(Sigma(20.0), Sigma(20.0),
FilterContents::BlurStyle::kNormal,
Entity::TileMode::kDecal));
auto image = std::make_shared<Image>(CreateTextureForFixture("kalimba.jpg"));
Paint paint;
paint.color = Color::Red().WithAlpha(0.5);
subcanvas.DrawImage(image, Point::MakeXY(100.0, 100.0), paint);

auto picture = subcanvas.EndRecordingAsPicture();

Canvas canvas;
canvas.DrawPaint({.color = Color::Black()});
canvas.DrawCircle(Point::MakeXY(150, 150), 25, {.color = Color::Red()});
canvas.DrawPicture(picture);

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, DrawPictureWithText) {
Canvas subcanvas;
ASSERT_TRUE(RenderTextInCanvasSkia(
GetContext(), subcanvas,
"the quick brown fox jumped over the lazy dog!.?", "Roboto-Regular.ttf"));
subcanvas.Translate({0, 10});
subcanvas.Scale(Vector2(3, 3));
ASSERT_TRUE(RenderTextInCanvasSkia(
GetContext(), subcanvas,
"the quick brown fox jumped over the very big lazy dog!.?",
"Roboto-Regular.ttf"));
auto picture = subcanvas.EndRecordingAsPicture();

Canvas canvas;
canvas.Scale(Vector2(.2, .2));
canvas.Save();
canvas.Translate({200, 200});
canvas.Scale(Vector2(3.5, 3.5)); // The text must not be blurry after this.
canvas.DrawPicture(picture);
canvas.Restore();

canvas.Scale(Vector2(1.5, 1.5));
ASSERT_TRUE(RenderTextInCanvasSkia(
GetContext(), canvas,
"the quick brown fox jumped over the smaller lazy dog!.?",
"Roboto-Regular.ttf"));
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, DrawPictureClipped) {
Canvas subcanvas;
subcanvas.ClipRRect(Rect::MakeLTRB(100, 100, 400, 400), {15, 15});
subcanvas.DrawPaint({.color = Color::Red()});
auto picture = subcanvas.EndRecordingAsPicture();

Canvas canvas;
canvas.DrawPaint({.color = Color::CornflowerBlue()});

// Draw a red RRect via DrawPicture.
canvas.DrawPicture(picture);

// Draw over the picture with a larger green rectangle, completely covering it
// up.
canvas.ClipRRect(Rect::MakeLTRB(100, 100, 400, 400).Expand(20), {15, 15});
canvas.DrawPaint({.color = Color::Green()});

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, MatrixSaveLayerFilter) {
Canvas canvas;
canvas.DrawPaint({.color = Color::Black()});
Expand Down
29 changes: 0 additions & 29 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -620,35 +620,6 @@ void Canvas::DrawPoints(std::vector<Point> points,
AddEntityToCurrentPass(std::move(entity));
}

void Canvas::DrawPicture(const Picture& picture) {
if (!picture.pass) {
return;
}

// Clone the base pass and account for the CTM updates.
auto pass = picture.pass->Clone();

pass->IterateAllElements([&](auto& element) -> bool {
if (auto entity = std::get_if<Entity>(&element)) {
entity->IncrementStencilDepth(GetClipDepth());
entity->SetTransform(GetCurrentTransform() * entity->GetTransform());
return true;
}

if (auto subpass = std::get_if<std::unique_ptr<EntityPass>>(&element)) {
subpass->get()->SetClipDepth(subpass->get()->GetClipDepth() +
GetClipDepth());
return true;
}

FML_UNREACHABLE();
});

GetCurrentPass().AddSubpassInline(std::move(pass));

RestoreClip();
}

void Canvas::DrawImage(const std::shared_ptr<Image>& image,
Point offset,
const Paint& paint,
Expand Down
2 changes: 0 additions & 2 deletions impeller/aiks/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ class Canvas {
const Size& corner_radii,
Entity::ClipOperation clip_op = Entity::ClipOperation::kIntersect);

void DrawPicture(const Picture& picture);

void DrawTextFrame(const std::shared_ptr<TextFrame>& text_frame,
Point position,
const Paint& paint);
Expand Down
6 changes: 0 additions & 6 deletions impeller/aiks/canvas_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ enum CanvasRecorderOp : uint16_t {
kClipRect,
kClipOval,
kClipRRect,
kDrawPicture,
kDrawTextFrame,
kDrawVertices,
kDrawAtlas,
Expand Down Expand Up @@ -280,11 +279,6 @@ class CanvasRecorder {
corner_radii, clip_op);
}

void DrawPicture(const Picture& picture) {
return ExecuteAndSerialize(FLT_CANVAS_RECORDER_OP_ARG(DrawPicture),
picture);
}

void DrawTextFrame(const std::shared_ptr<TextFrame>& text_frame,
Point position,
const Paint& paint) {
Expand Down
6 changes: 0 additions & 6 deletions impeller/aiks/canvas_recorder_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,6 @@ TEST(CanvasRecorder, ClipRRect) {
ASSERT_EQ(recorder.GetSerializer().last_op_, CanvasRecorderOp::kClipRRect);
}

TEST(CanvasRecorder, DrawPicture) {
CanvasRecorder<Serializer> recorder;
recorder.DrawPicture({});
ASSERT_EQ(recorder.GetSerializer().last_op_, CanvasRecorderOp::kDrawPicture);
}

TEST(CanvasRecorder, DrawTextFrame) {
CanvasRecorder<Serializer> recorder;
recorder.DrawTextFrame({}, {}, {});
Expand Down
1 change: 0 additions & 1 deletion impeller/aiks/trace_serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ std::string_view CanvasRecorderOpToString(CanvasRecorderOp op) {
FLT_CANVAS_RECORDER_OP_TO_STRING(kClipRect);
FLT_CANVAS_RECORDER_OP_TO_STRING(kClipOval);
FLT_CANVAS_RECORDER_OP_TO_STRING(kClipRRect);
FLT_CANVAS_RECORDER_OP_TO_STRING(kDrawPicture);
FLT_CANVAS_RECORDER_OP_TO_STRING(kDrawTextFrame);
FLT_CANVAS_RECORDER_OP_TO_STRING(kDrawVertices);
FLT_CANVAS_RECORDER_OP_TO_STRING(kDrawAtlas);
Expand Down
13 changes: 0 additions & 13 deletions impeller/display_list/dl_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ flutter::DlColor toColor(const float* components) {
using DisplayListTest = DlPlayground;
INSTANTIATE_PLAYGROUND_SUITE(DisplayListTest);

TEST_P(DisplayListTest, DrawPictureWithAClip) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though the name of this test was "DrawPictureWithAClip", it was actually drawing a DisplayList with a clip - should it be eliminated here?

flutter::DisplayListBuilder sub_builder;
sub_builder.ClipRect(SkRect::MakeXYWH(0, 0, 24, 24));
sub_builder.DrawPaint(flutter::DlPaint(flutter::DlColor::kBlue()));

auto display_list = sub_builder.Build();
flutter::DisplayListBuilder builder;
builder.DrawDisplayList(display_list);
builder.DrawRect(SkRect::MakeXYWH(30, 30, 24, 24),
flutter::DlPaint(flutter::DlColor::kRed()));
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

TEST_P(DisplayListTest, CanDrawRect) {
flutter::DisplayListBuilder builder;
builder.DrawRect(SkRect::MakeXYWH(10, 10, 100, 100),
Expand Down
34 changes: 0 additions & 34 deletions impeller/entity/entity_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1153,40 +1153,6 @@ size_t EntityPass::GetElementCount() const {
return elements_.size();
}

std::unique_ptr<EntityPass> EntityPass::Clone() const {
std::vector<Element> new_elements;
new_elements.reserve(elements_.size());

for (const auto& element : elements_) {
if (auto entity = std::get_if<Entity>(&element)) {
new_elements.push_back(entity->Clone());
continue;
}
if (auto subpass = std::get_if<std::unique_ptr<EntityPass>>(&element)) {
new_elements.push_back(subpass->get()->Clone());
continue;
}
FML_UNREACHABLE();
}

auto pass = std::make_unique<EntityPass>();
pass->SetElements(std::move(new_elements));
pass->active_clips_.insert(pass->active_clips_.begin(), active_clips_.begin(),
active_clips_.end());
pass->backdrop_filter_reads_from_pass_texture_ =
backdrop_filter_reads_from_pass_texture_;
pass->advanced_blend_reads_from_pass_texture_ =
advanced_blend_reads_from_pass_texture_;
pass->backdrop_filter_proc_ = backdrop_filter_proc_;
pass->blend_mode_ = blend_mode_;
pass->delegate_ = delegate_;
pass->new_clip_depth_ = new_clip_depth_;
// Note: I tried also adding flood clip and bounds limit but one of the
// two caused rendering in wonderous to break. It's 10:51 PM, and I'm
// ready to move on.
return pass;
}

void EntityPass::SetTransform(Matrix transform) {
transform_ = transform;
}
Expand Down
2 changes: 0 additions & 2 deletions impeller/entity/entity_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ class EntityPass {

size_t GetSubpassesDepth() const;

std::unique_ptr<EntityPass> Clone() const;

/// @brief Add an entity to the current entity pass.
void AddEntity(Entity entity);

Expand Down