Skip to content

Commit 8784ff4

Browse files
bderodnfield
authored andcommitted
Don't use Add[Thing] operations when emulating Skia path components (flutter#86)
1 parent e381974 commit 8784ff4

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

impeller/display_list/display_list_dispatcher.cc

+16-17
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ static Color ToColor(const SkColor& color) {
8989
}
9090

9191
// |flutter::Dispatcher|
92-
void DisplayListDispatcher::setColorSource(const flutter::DlColorSource* source) {
92+
void DisplayListDispatcher::setColorSource(
93+
const flutter::DlColorSource* source) {
9394
if (!source) {
9495
paint_.contents = nullptr;
9596
return;
9697
}
9798

98-
switch(source->type()) {
99+
switch (source->type()) {
99100
case flutter::DlColorSourceType::kColor: {
100101
const flutter::DlColorColorSource* color = source->asColor();
101102
paint_.contents = nullptr;
@@ -104,7 +105,8 @@ void DisplayListDispatcher::setColorSource(const flutter::DlColorSource* source)
104105
return;
105106
}
106107
case flutter::DlColorSourceType::kLinearGradient: {
107-
const flutter::DlLinearGradientColorSource* linear = source->asLinearGradient();
108+
const flutter::DlLinearGradientColorSource* linear =
109+
source->asLinearGradient();
108110
FML_DCHECK(linear);
109111
auto contents = std::make_shared<LinearGradientContents>();
110112
contents->SetEndPoints(ToPoint(linear->start_point()),
@@ -327,13 +329,13 @@ static Path ToPath(const SkPath& path) {
327329
builder.MoveTo(ToPoint(data.points[0]));
328330
break;
329331
case SkPath::kLine_Verb:
330-
builder.AddLine(ToPoint(data.points[0]), ToPoint(data.points[1]));
332+
builder.LineTo(ToPoint(data.points[0]));
333+
builder.LineTo(ToPoint(data.points[1]));
331334
break;
332335
case SkPath::kQuad_Verb:
333-
builder.AddQuadraticCurve(ToPoint(data.points[0]), // p1
334-
ToPoint(data.points[1]), // cp
335-
ToPoint(data.points[2]) // p2
336-
);
336+
builder.LineTo(ToPoint(data.points[0]));
337+
builder.QuadraticCurveTo(ToPoint(data.points[1]),
338+
ToPoint(data.points[2]));
337339
break;
338340
case SkPath::kConic_Verb: {
339341
constexpr auto kPow2 = 1; // Only works for sweeps up to 90 degrees.
@@ -352,18 +354,15 @@ static Path ToPath(const SkPath& path) {
352354
curve_index < curve_count; //
353355
curve_index++, point_index += 2 //
354356
) {
355-
builder.AddQuadraticCurve(ToPoint(points[point_index + 0]), // p1
356-
ToPoint(points[point_index + 1]), // cp
357-
ToPoint(points[point_index + 2]) // p2
358-
);
357+
builder.LineTo(ToPoint(points[point_index + 0]));
358+
builder.QuadraticCurveTo(ToPoint(points[point_index + 1]),
359+
ToPoint(points[point_index + 2]));
359360
}
360361
} break;
361362
case SkPath::kCubic_Verb:
362-
builder.AddCubicCurve(ToPoint(data.points[0]), // p1
363-
ToPoint(data.points[1]), // cp1
364-
ToPoint(data.points[2]), // cp2
365-
ToPoint(data.points[3]) // p2
366-
);
363+
builder.LineTo(ToPoint(data.points[0]));
364+
builder.CubicCurveTo(ToPoint(data.points[1]), ToPoint(data.points[2]),
365+
ToPoint(data.points[3]));
367366
break;
368367
case SkPath::kClose_Verb:
369368
builder.Close();

0 commit comments

Comments
 (0)