[Impeller] remove drawPicture from Aiks Canvas. (flutter/engine#50242)

These interfaces were added to allow experimentation with the AiksLayer in the framework. Since our current approach is focused on aligning display list and impeller, we don't need these anymore.
This commit is contained in:
Jonah Williams
2024-02-01 10:07:46 -08:00
committed by GitHub
parent 5251e0048f
commit abfdf7ed0b
9 changed files with 0 additions and 192 deletions

View File

@@ -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()});

View File

@@ -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,

View File

@@ -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);

View File

@@ -45,7 +45,6 @@ enum CanvasRecorderOp : uint16_t {
kClipRect,
kClipOval,
kClipRRect,
kDrawPicture,
kDrawTextFrame,
kDrawVertices,
kDrawAtlas,
@@ -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) {

View File

@@ -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({}, {}, {});

View File

@@ -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);

View File

@@ -46,19 +46,6 @@ flutter::DlColor toColor(const float* components) {
using DisplayListTest = DlPlayground;
INSTANTIATE_PLAYGROUND_SUITE(DisplayListTest);
TEST_P(DisplayListTest, DrawPictureWithAClip) {
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),

View File

@@ -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;
}

View File

@@ -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);