Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not automatically merge simple paths when appending shapes in AppendShape to reduce call time in main thread. #434

Merged
merged 1 commit into from
Jan 20, 2025
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
9 changes: 0 additions & 9 deletions src/core/shapes/AppendShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ void AppendShape::Append(std::vector<std::shared_ptr<Shape>>* shapes,
shapes->insert(shapes->end(), appendShape->shapes.begin(), appendShape->shapes.end());
return;
}
if (shape->type() == Type::Path && !shapes->empty()) {
auto lastShape = shapes->back();
if (lastShape->type() == Type::Path) {
auto path = std::static_pointer_cast<PathShape>(lastShape)->path;
path.addPath(std::static_pointer_cast<PathShape>(shape)->path);
shapes->back() = std::make_shared<PathShape>(std::move(path));
return;
}
}
shapes->push_back(std::move(shape));
}

Expand Down
4 changes: 2 additions & 2 deletions test/src/CanvasTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,12 @@ TGFX_TEST(CanvasTest, drawShape) {
path.addOval(Rect::MakeWH(100, 100));
auto shape2 = Shape::MakeFrom(path);
auto mergedShape = Shape::Merge(shape, shape2, PathOp::Append);
EXPECT_TRUE(mergedShape->isSimplePath());
EXPECT_FALSE(mergedShape->isSimplePath());
auto transShape = Shape::ApplyMatrix(shape, Matrix::MakeTrans(10, 10));
mergedShape = Shape::Merge({transShape, shape, shape2});
EXPECT_EQ(mergedShape->type(), Shape::Type::Append);
auto appendShape = std::static_pointer_cast<AppendShape>(mergedShape);
EXPECT_EQ(appendShape->shapes.size(), 2u);
EXPECT_EQ(appendShape->shapes.size(), 3u);

Paint paint;
paint.setStyle(PaintStyle::Stroke);
Expand Down
Loading