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
14 changes: 7 additions & 7 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ TEST_P(AiksTest, RotateColorFilteredPath) {
ColorFilter::MakeBlend(BlendMode::kSourceIn, Color::AliceBlue()),
};

canvas.DrawPath(arrow_stem, paint);
canvas.DrawPath(arrow_head, paint);
canvas.DrawPath(std::move(arrow_stem), paint);
canvas.DrawPath(std::move(arrow_head), paint);
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

Expand Down Expand Up @@ -1266,7 +1266,7 @@ TEST_P(AiksTest, CanRenderRoundedRectWithNonUniformRadii) {
.AddRoundedRect(Rect::MakeXYWH(100, 100, 500, 500), radii)
.TakePath();

canvas.DrawPath(path, paint);
canvas.DrawPath(std::move(path), paint);

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
Expand Down Expand Up @@ -1323,7 +1323,7 @@ TEST_P(AiksTest, CanRenderDifferencePaths) {
canvas.DrawImage(
std::make_shared<Image>(CreateTextureForFixture("boston.jpg")), {10, 10},
Paint{});
canvas.DrawPath(path, paint);
canvas.DrawPath(std::move(path), paint);

ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
Expand Down Expand Up @@ -1984,7 +1984,7 @@ TEST_P(AiksTest, SolidStrokesRenderCorrectly) {
paint.stroke_join = join;
for (auto cap : {Cap::kButt, Cap::kSquare, Cap::kRound}) {
paint.stroke_cap = cap;
canvas.DrawPath(path, paint);
canvas.DrawPath(path.Clone(), paint);
canvas.Translate({80, 0});
}
canvas.Translate({-240, 60});
Expand Down Expand Up @@ -2248,7 +2248,7 @@ TEST_P(AiksTest, GradientStrokesRenderCorrectly) {
paint.stroke_join = join;
for (auto cap : {Cap::kButt, Cap::kSquare, Cap::kRound}) {
paint.stroke_cap = cap;
canvas.DrawPath(path, paint);
canvas.DrawPath(path.Clone(), paint);
canvas.Translate({80, 0});
}
canvas.Translate({-240, 60});
Expand Down Expand Up @@ -2980,7 +2980,7 @@ TEST_P(AiksTest, ImageFilteredSaveLayerWithUnboundedContents) {
.TakePath();
Paint paint = p;
paint.style = Paint::Style::kStroke;
canvas.DrawPath(path, paint);
canvas.DrawPath(std::move(path), paint);
};
// Registration marks for the edge of the SaveLayer
DrawLine(Point(75, 100), Point(225, 100), {.color = Color::White()});
Expand Down
19 changes: 10 additions & 9 deletions impeller/aiks/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,13 @@ void Canvas::RestoreToCount(size_t count) {
}
}

void Canvas::DrawPath(const Path& path, const Paint& paint) {
void Canvas::DrawPath(Path path, const Paint& paint) {
Entity entity;
entity.SetTransform(GetCurrentTransform());
entity.SetClipDepth(GetClipDepth());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(paint.WithFilters(paint.CreateContentsForEntity(path)));
entity.SetContents(
paint.WithFilters(paint.CreateContentsForEntity(std::move(path))));

GetCurrentPass().AddEntity(entity);
}
Expand Down Expand Up @@ -277,13 +278,13 @@ void Canvas::DrawRRect(Rect rect, Point corner_radii, const Paint& paint) {
entity.SetTransform(GetCurrentTransform());
entity.SetClipDepth(GetClipDepth());
entity.SetBlendMode(paint.blend_mode);
entity.SetContents(paint.WithFilters(
paint.CreateContentsForGeometry(Geometry::MakeFillPath(path))));
entity.SetContents(paint.WithFilters(paint.CreateContentsForGeometry(
Geometry::MakeFillPath(std::move(path)))));

GetCurrentPass().AddEntity(entity);
return;
}
DrawPath(path, paint);
DrawPath(std::move(path), paint);
}

void Canvas::DrawCircle(Point center, Scalar radius, const Paint& paint) {
Expand All @@ -308,10 +309,10 @@ void Canvas::DrawCircle(Point center, Scalar radius, const Paint& paint) {
GetCurrentPass().AddEntity(entity);
}

void Canvas::ClipPath(const Path& path, Entity::ClipOperation clip_op) {
ClipGeometry(Geometry::MakeFillPath(path), clip_op);
void Canvas::ClipPath(Path path, Entity::ClipOperation clip_op) {
auto bounds = path.GetBoundingBox();
ClipGeometry(Geometry::MakeFillPath(std::move(path)), clip_op);
if (clip_op == Entity::ClipOperation::kIntersect) {
auto bounds = path.GetBoundingBox();
if (bounds.has_value()) {
IntersectCulling(bounds.value());
}
Expand Down Expand Up @@ -355,7 +356,7 @@ void Canvas::ClipRRect(const Rect& rect,
std::optional<Rect> inner_rect = (flat_on_LR && flat_on_TB)
? rect.Expand(-corner_radii)
: std::make_optional<Rect>();
auto geometry = Geometry::MakeFillPath(path, inner_rect);
auto geometry = Geometry::MakeFillPath(std::move(path), inner_rect);
auto& cull_rect = transform_stack_.back().cull_rect;
if (clip_op == Entity::ClipOperation::kIntersect && //
cull_rect.has_value() && //
Expand Down
4 changes: 2 additions & 2 deletions impeller/aiks/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Canvas {

void Rotate(Radians radians);

void DrawPath(const Path& path, const Paint& paint);
void DrawPath(Path path, const Paint& paint);

void DrawPaint(const Paint& paint);

Expand Down Expand Up @@ -126,7 +126,7 @@ class Canvas {
SamplerDescriptor sampler = {});

void ClipPath(
const Path& path,
Path path,
Entity::ClipOperation clip_op = Entity::ClipOperation::kIntersect);

void ClipRect(
Expand Down
26 changes: 20 additions & 6 deletions impeller/aiks/canvas_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ class CanvasRecorder {
return (canvas_.*canvasMethod)(std::forward<Args>(args)...);
}

template <typename FuncType, typename... Args>
auto ExecuteAndSkipArgSerialize(CanvasRecorderOp op,
FuncType canvasMethod,
Args&&... args)
-> decltype((std::declval<Canvas>().*
canvasMethod)(std::forward<Args>(args)...)) {
serializer_.Write(op);
return (canvas_.*canvasMethod)(std::forward<Args>(args)...);
}

//////////////////////////////////////////////////////////////////////////////
// Canvas Static Polymorphism
// ////////////////////////////////////////////////
Expand Down Expand Up @@ -169,9 +179,11 @@ class CanvasRecorder {
return ExecuteAndSerialize(FLT_CANVAS_RECORDER_OP_ARG(Rotate), radians);
}

void DrawPath(const Path& path, const Paint& paint) {
return ExecuteAndSerialize(FLT_CANVAS_RECORDER_OP_ARG(DrawPath), path,
paint);
void DrawPath(Path path, const Paint& paint) {
serializer_.Write(path);
serializer_.Write(paint);
return ExecuteAndSkipArgSerialize(FLT_CANVAS_RECORDER_OP_ARG(DrawPath),
std::move(path), paint);
}

void DrawPaint(const Paint& paint) {
Expand Down Expand Up @@ -219,10 +231,12 @@ class CanvasRecorder {
}

void ClipPath(
const Path& path,
Path path,
Entity::ClipOperation clip_op = Entity::ClipOperation::kIntersect) {
return ExecuteAndSerialize(FLT_CANVAS_RECORDER_OP_ARG(ClipPath), path,
clip_op);
serializer_.Write(path);
serializer_.Write(clip_op);
return ExecuteAndSkipArgSerialize(FLT_CANVAS_RECORDER_OP_ARG(ClipPath),
std::move(path), clip_op);
}

void ClipRect(
Expand Down
10 changes: 5 additions & 5 deletions impeller/aiks/canvas_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ TEST(AiksCanvasTest, PathClipIntersectAgainstEmptyCullRect) {
Rect rect_clip = Rect::MakeXYWH(5, 5, 10, 10);

Canvas canvas;
canvas.ClipPath(path, Entity::ClipOperation::kIntersect);
canvas.ClipPath(std::move(path), Entity::ClipOperation::kIntersect);

ASSERT_TRUE(canvas.GetCurrentLocalCullingBounds().has_value());
ASSERT_EQ(canvas.GetCurrentLocalCullingBounds().value(), rect_clip);
Expand All @@ -282,7 +282,7 @@ TEST(AiksCanvasTest, PathClipDiffAgainstEmptyCullRect) {
Path path = builder.TakePath();

Canvas canvas;
canvas.ClipPath(path, Entity::ClipOperation::kDifference);
canvas.ClipPath(std::move(path), Entity::ClipOperation::kDifference);

ASSERT_FALSE(canvas.GetCurrentLocalCullingBounds().has_value());
}
Expand All @@ -298,7 +298,7 @@ TEST(AiksCanvasTest, PathClipIntersectAgainstCullRect) {
Rect result_cull = Rect::MakeXYWH(5, 5, 5, 5);

Canvas canvas(initial_cull);
canvas.ClipPath(path, Entity::ClipOperation::kIntersect);
canvas.ClipPath(std::move(path), Entity::ClipOperation::kIntersect);

ASSERT_TRUE(canvas.GetCurrentLocalCullingBounds().has_value());
ASSERT_EQ(canvas.GetCurrentLocalCullingBounds().value(), result_cull);
Expand All @@ -315,7 +315,7 @@ TEST(AiksCanvasTest, PathClipDiffAgainstNonCoveredCullRect) {
Rect result_cull = Rect::MakeXYWH(0, 0, 10, 10);

Canvas canvas(initial_cull);
canvas.ClipPath(path, Entity::ClipOperation::kDifference);
canvas.ClipPath(std::move(path), Entity::ClipOperation::kDifference);

ASSERT_TRUE(canvas.GetCurrentLocalCullingBounds().has_value());
ASSERT_EQ(canvas.GetCurrentLocalCullingBounds().value(), result_cull);
Expand All @@ -330,7 +330,7 @@ TEST(AiksCanvasTest, PathClipDiffAgainstFullyCoveredCullRect) {
Rect result_cull = Rect::MakeXYWH(5, 5, 10, 10);

Canvas canvas(initial_cull);
canvas.ClipPath(path, Entity::ClipOperation::kDifference);
canvas.ClipPath(std::move(path), Entity::ClipOperation::kDifference);

ASSERT_TRUE(canvas.GetCurrentLocalCullingBounds().has_value());
ASSERT_EQ(canvas.GetCurrentLocalCullingBounds().value(), result_cull);
Expand Down
13 changes: 7 additions & 6 deletions impeller/aiks/paint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ constexpr ColorMatrix kColorInversion = {
};
// clang-format on

std::shared_ptr<Contents> Paint::CreateContentsForEntity(const Path& path,
std::shared_ptr<Contents> Paint::CreateContentsForEntity(Path path,
bool cover) const {
std::shared_ptr<Geometry> geometry;
switch (style) {
case Style::kFill:
geometry = cover ? Geometry::MakeCover() : Geometry::MakeFillPath(path);
geometry = cover ? Geometry::MakeCover()
: Geometry::MakeFillPath(std::move(path));
break;
case Style::kStroke:
geometry =
cover ? Geometry::MakeCover()
: Geometry::MakeStrokePath(path, stroke_width, stroke_miter,
stroke_cap, stroke_join);
geometry = cover ? Geometry::MakeCover()
: Geometry::MakeStrokePath(std::move(path), stroke_width,
stroke_miter, stroke_cap,
stroke_join);
break;
}
return CreateContentsForGeometry(geometry);
Expand Down
2 changes: 1 addition & 1 deletion impeller/aiks/paint.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct Paint {
std::shared_ptr<Contents> input,
const Matrix& effect_transform = Matrix()) const;

std::shared_ptr<Contents> CreateContentsForEntity(const Path& path = {},
std::shared_ptr<Contents> CreateContentsForEntity(Path path = {},
bool cover = false) const;

std::shared_ptr<Contents> CreateContentsForGeometry(
Expand Down
2 changes: 1 addition & 1 deletion impeller/display_list/dl_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ void DlDispatcher::drawOval(const SkRect& bounds) {
.AddOval(skia_conversions::ToRect(bounds))
.SetConvexity(Convexity::kConvex)
.TakePath();
canvas_.DrawPath(path, paint_);
canvas_.DrawPath(std::move(path), paint_);
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing the linter isn't helping us here if we miss the std::move too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't move its actually a compile error!

Copy link
Member

Choose a reason for hiding this comment

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

oh right, nice!

}
}

Expand Down
4 changes: 2 additions & 2 deletions impeller/entity/contents/solid_color_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ bool SolidColorContents::Render(const ContentContext& renderer,
return true;
}

std::unique_ptr<SolidColorContents> SolidColorContents::Make(const Path& path,
std::unique_ptr<SolidColorContents> SolidColorContents::Make(Path path,
Color color) {
auto contents = std::make_unique<SolidColorContents>();
contents->SetGeometry(Geometry::MakeFillPath(path));
contents->SetGeometry(Geometry::MakeFillPath(std::move(path)));
contents->SetColor(color);
return contents;
}
Expand Down
3 changes: 1 addition & 2 deletions impeller/entity/contents/solid_color_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class SolidColorContents final : public ColorSourceContents {

~SolidColorContents() override;

static std::unique_ptr<SolidColorContents> Make(const Path& path,
Color color);
static std::unique_ptr<SolidColorContents> Make(Path path, Color color);

void SetColor(Color color);

Expand Down
24 changes: 12 additions & 12 deletions impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ TEST_P(EntityTest, CanDrawRRect) {
.SetConvexity(Convexity::kConvex)
.AddRoundedRect(Rect::MakeXYWH(100, 100, 100, 100), 10.0)
.TakePath();
contents->SetGeometry(Geometry::MakeFillPath(path));
contents->SetGeometry(Geometry::MakeFillPath(std::move(path)));
contents->SetColor(Color::Red());

Entity entity;
Expand Down Expand Up @@ -261,7 +261,7 @@ TEST_P(EntityTest, ThreeStrokesInOnePath) {
Entity entity;
entity.SetTransform(Matrix::MakeScale(GetContentScale()));
auto contents = std::make_unique<SolidColorContents>();
contents->SetGeometry(Geometry::MakeStrokePath(path, 5.0));
contents->SetGeometry(Geometry::MakeStrokePath(std::move(path), 5.0));
contents->SetColor(Color::Red());
entity.SetContents(std::move(contents));
ASSERT_TRUE(OpenPlaygroundHere(entity));
Expand All @@ -281,7 +281,7 @@ TEST_P(EntityTest, StrokeWithTextureContents) {
Entity entity;
entity.SetTransform(Matrix::MakeScale(GetContentScale()));
auto contents = std::make_unique<TiledTextureContents>();
contents->SetGeometry(Geometry::MakeStrokePath(path, 100.0));
contents->SetGeometry(Geometry::MakeStrokePath(std::move(path), 100.0));
contents->SetTexture(bridge);
contents->SetTileModes(Entity::TileMode::kClamp, Entity::TileMode::kClamp);
entity.SetContents(std::move(contents));
Expand Down Expand Up @@ -321,7 +321,7 @@ TEST_P(EntityTest, TriangleInsideASquare) {
Entity entity;
entity.SetTransform(Matrix::MakeScale(GetContentScale()));
auto contents = std::make_unique<SolidColorContents>();
contents->SetGeometry(Geometry::MakeStrokePath(path, 20.0));
contents->SetGeometry(Geometry::MakeStrokePath(std::move(path), 20.0));
contents->SetColor(Color::Red());
entity.SetContents(std::move(contents));

Expand Down Expand Up @@ -356,8 +356,8 @@ TEST_P(EntityTest, StrokeCapAndJoinTest) {
auto render_path = [width = width, &context, &pass, &world_matrix](
const Path& path, Cap cap, Join join) {
auto contents = std::make_unique<SolidColorContents>();
contents->SetGeometry(
Geometry::MakeStrokePath(path, width, miter_limit, cap, join));
contents->SetGeometry(Geometry::MakeStrokePath(path.Clone(), width,
miter_limit, cap, join));
contents->SetColor(Color::Red());

Entity entity;
Expand Down Expand Up @@ -470,7 +470,7 @@ TEST_P(EntityTest, CubicCurveTest) {
.TakePath();
Entity entity;
entity.SetTransform(Matrix::MakeScale(GetContentScale()));
entity.SetContents(SolidColorContents::Make(path, Color::Red()));
entity.SetContents(SolidColorContents::Make(std::move(path), Color::Red()));
ASSERT_TRUE(OpenPlaygroundHere(entity));
}

Expand Down Expand Up @@ -514,7 +514,7 @@ TEST_P(EntityTest, CanDrawCorrectlyWithRotatedTransform) {

Entity entity;
entity.SetTransform(result_transform);
entity.SetContents(SolidColorContents::Make(path, Color::Red()));
entity.SetContents(SolidColorContents::Make(std::move(path), Color::Red()));
return entity.Render(context, pass);
};
ASSERT_TRUE(OpenPlaygroundHere(callback));
Expand Down Expand Up @@ -744,7 +744,7 @@ TEST_P(EntityTest, CubicCurveAndOverlapTest) {
.TakePath();
Entity entity;
entity.SetTransform(Matrix::MakeScale(GetContentScale()));
entity.SetContents(SolidColorContents::Make(path, Color::Red()));
entity.SetContents(SolidColorContents::Make(std::move(path), Color::Red()));
ASSERT_TRUE(OpenPlaygroundHere(entity));
}

Expand Down Expand Up @@ -946,7 +946,7 @@ TEST_P(EntityTest, BezierCircleScaled) {
.TakePath();
entity.SetTransform(
Matrix::MakeScale({scale, scale, 1.0}).Translate({-90, -20, 0}));
entity.SetContents(SolidColorContents::Make(path, Color::Red()));
entity.SetContents(SolidColorContents::Make(std::move(path), Color::Red()));
return entity.Render(context, pass);
};
ASSERT_TRUE(OpenPlaygroundHere(callback));
Expand Down Expand Up @@ -2289,8 +2289,8 @@ TEST_P(EntityTest, CoverageForStrokePathWithNegativeValuesInTransform) {
.LineTo({120, 190})
.LineTo({190, 120})
.TakePath();
auto geometry = Geometry::MakeStrokePath(arrow_head, 15.0, 4.0, Cap::kRound,
Join::kRound);
auto geometry = Geometry::MakeStrokePath(std::move(arrow_head), 15.0, 4.0,
Cap::kRound, Join::kRound);

auto transform = Matrix::MakeTranslation({300, 300}) *
Matrix::MakeRotationZ(Radians(kPiOver2));
Expand Down
5 changes: 2 additions & 3 deletions impeller/entity/geometry/fill_path_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

namespace impeller {

FillPathGeometry::FillPathGeometry(const Path& path,
std::optional<Rect> inner_rect)
: path_(path), inner_rect_(inner_rect) {}
FillPathGeometry::FillPathGeometry(Path path, std::optional<Rect> inner_rect)
: path_(std::move(path)), inner_rect_(inner_rect) {}

GeometryResult FillPathGeometry::GetPositionBuffer(
const ContentContext& renderer,
Expand Down
Loading