[Impeller] Interpret odd path winding in the dispatcher (flutter/engine#33657)
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "impeller/entity/contents/linear_gradient_contents.h"
|
||||
#include "impeller/entity/contents/solid_stroke_contents.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/geometry/path.h"
|
||||
#include "impeller/geometry/path_builder.h"
|
||||
#include "impeller/geometry/scalar.h"
|
||||
#include "impeller/geometry/vertices.h"
|
||||
@@ -490,8 +491,23 @@ static Path ToPath(const SkPath& path) {
|
||||
break;
|
||||
}
|
||||
} while (verb != SkPath::Verb::kDone_Verb);
|
||||
// TODO: Convert fill types.
|
||||
return builder.TakePath();
|
||||
|
||||
FillType fill_type;
|
||||
switch (path.getFillType()) {
|
||||
case SkPathFillType::kWinding:
|
||||
fill_type = FillType::kNonZero;
|
||||
break;
|
||||
case SkPathFillType::kEvenOdd:
|
||||
fill_type = FillType::kOdd;
|
||||
break;
|
||||
case SkPathFillType::kInverseWinding:
|
||||
case SkPathFillType::kInverseEvenOdd:
|
||||
// TODO(104848): Support the inverse winding modes.
|
||||
UNIMPLEMENTED;
|
||||
fill_type = FillType::kNonZero;
|
||||
break;
|
||||
}
|
||||
return builder.TakePath(fill_type);
|
||||
}
|
||||
|
||||
static Path ToPath(const SkRRect& rrect) {
|
||||
@@ -558,7 +574,7 @@ void DisplayListDispatcher::clipRRect(const SkRRect& rrect,
|
||||
void DisplayListDispatcher::clipPath(const SkPath& path,
|
||||
SkClipOp clip_op,
|
||||
bool is_aa) {
|
||||
canvas_.ClipPath(ToPath(path));
|
||||
canvas_.ClipPath(ToPath(path), ToClipOperation(clip_op));
|
||||
}
|
||||
|
||||
// |flutter::Dispatcher|
|
||||
|
||||
@@ -176,6 +176,21 @@ TEST_P(DisplayListTest, StrokedPathsDrawCorrectly) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(DisplayListTest, CanDrawWithOddPathWinding) {
|
||||
flutter::DisplayListBuilder builder;
|
||||
builder.setColor(SK_ColorRED);
|
||||
builder.setStyle(flutter::DlDrawStyle::kFill);
|
||||
|
||||
builder.translate(300, 300);
|
||||
SkPath path;
|
||||
path.setFillType(SkPathFillType::kEvenOdd);
|
||||
path.addCircle(0, 0, 100);
|
||||
path.addCircle(0, 0, 50);
|
||||
builder.drawPath(path);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(DisplayListTest, CanDrawWithMaskBlur) {
|
||||
auto texture = CreateTextureForFixture("embarcadero.jpg");
|
||||
flutter::DisplayListBuilder builder;
|
||||
|
||||
Reference in New Issue
Block a user