Implement SkPathBuilder(SkPathFillType)

Bug: skia:9000

This constructor is already declared; provide a definition.
Add a test.

Change-Id: Ic54ccffe0b1adf7c8c411e19a3fc9d825a5c9619
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331799
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
Leon Scroggins 2020-11-03 12:58:07 -05:00 committed by Skia Commit-Bot
parent 007d97d699
commit f12d05d125
2 changed files with 22 additions and 0 deletions

View File

@ -18,6 +18,11 @@ SkPathBuilder::SkPathBuilder() {
this->reset();
}
SkPathBuilder::SkPathBuilder(SkPathFillType ft) {
this->reset();
fFillType = ft;
}
SkPathBuilder::SkPathBuilder(const SkPath& src) {
*this = src;
}

View File

@ -6,6 +6,7 @@
*/
#include "include/core/SkPathBuilder.h"
#include "include/core/SkPathTypes.h"
#include "src/core/SkPathPriv.h"
#include "tests/Test.h"
@ -41,6 +42,22 @@ DEF_TEST(pathbuilder, reporter) {
is_empty(reporter, b.detach());
}
DEF_TEST(pathbuilder_filltype, reporter) {
for (auto fillType : { SkPathFillType::kWinding,
SkPathFillType::kEvenOdd,
SkPathFillType::kInverseWinding,
SkPathFillType::kInverseEvenOdd }) {
SkPathBuilder b(fillType);
REPORTER_ASSERT(reporter, b.fillType() == fillType);
for (const SkPath& path : { b.snapshot(), b.detach() }) {
REPORTER_ASSERT(reporter, path.getFillType() == fillType);
is_empty(reporter, path);
}
}
}
static bool check_points(const SkPath& path, const SkPoint expected[], size_t count) {
std::vector<SkPoint> iter_pts;