return GrShape(*this, apply, scale);
}
+ /** Returns the unstyled geometry as a rrect if possible. */
bool asRRect(SkRRect* rrect) const {
if (Type::kRRect != fType) {
return false;
return true;
}
+ /** Returns the unstyled geometry as a path. */
void asPath(SkPath* out) const {
switch (fType) {
case Type::kEmpty:
}
/**
- * Is it known that the shape has no unclosed contours. This means that it will not have
- * any caps if stroked (modulo the effect of any path effect).
+ * Returns whether the geometry is empty. Note that applying the style could produce a
+ * non-empty shape.
+ */
+ bool isEmpty() const { return Type::kEmpty == fType; }
+
+ /**
+ * Is it known that the unstyled geometry has no unclosed contours. This means that it will
+ * not have any caps if stroked (modulo the effect of any path effect).
*/
bool knownToBeClosed() const {
switch (fType) {
fAppliedPEThenStroke.asPath(&a);
fAppliedFull.asPath(&b);
REPORTER_ASSERT(r, a == b);
+ REPORTER_ASSERT(r, fAppliedFull.isEmpty() == fAppliedPEThenStroke.isEmpty());
+
+ SkPath path;
+ fBase.asPath(&path);
+ REPORTER_ASSERT(r, path.isEmpty() == fBase.isEmpty());
+ fAppliedPE.asPath(&path);
+ REPORTER_ASSERT(r, path.isEmpty() == fAppliedPE.isEmpty());
+ fAppliedFull.asPath(&path);
+ REPORTER_ASSERT(r, path.isEmpty() == fAppliedFull.isEmpty());
// Check that the same path is produced when style is applied by GrShape and GrStyle.
SkPath preStyle;
fBase.asPath(&a);
that.fBase.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fBase.isEmpty() == that.fBase.isEmpty());
REPORTER_ASSERT(reporter, fAppliedPEKey != that.fAppliedPEKey);
REPORTER_ASSERT(reporter, fAppliedFullKey != that.fAppliedFullKey);
break;
fBase.asPath(&a);
that.fBase.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fBase.isEmpty() == that.fBase.isEmpty());
REPORTER_ASSERT(reporter, fAppliedPEKey == that.fAppliedPEKey);
fAppliedPE.asPath(&a);
that.fAppliedPE.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fAppliedPE.isEmpty() == that.fAppliedPE.isEmpty());
REPORTER_ASSERT(reporter, fAppliedFullKey != that.fAppliedFullKey);
break;
case kAllSame_ComparisonExpecation:
fBase.asPath(&a);
that.fBase.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fBase.isEmpty() == that.fBase.isEmpty());
REPORTER_ASSERT(reporter, fAppliedPEKey == that.fAppliedPEKey);
fAppliedPE.asPath(&a);
that.fAppliedPE.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fAppliedPE.isEmpty() == that.fAppliedPE.isEmpty());
REPORTER_ASSERT(reporter, fAppliedFullKey == that.fAppliedFullKey);
fAppliedFull.asPath(&a);
that.fAppliedFull.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fAppliedFull.isEmpty() == that.fAppliedFull.isEmpty());
break;
}
}
GrShape emptyShape(emptyPath);
Key emptyKey;
make_key(&emptyKey, emptyShape);
+ REPORTER_ASSERT(reporter, emptyShape.isEmpty());
SkPaint pe;
pe.setPathEffect(EmptyPathEffect::Make());
REPORTER_ASSERT(reporter, geoCase.appliedFullStyleKey() == emptyKey);
REPORTER_ASSERT(reporter, geoCase.appliedPathEffectKey() == emptyKey);
REPORTER_ASSERT(reporter, geoCase.appliedPathEffectThenStrokeKey() == emptyKey);
+ REPORTER_ASSERT(reporter, geoCase.appliedPathEffectShape().isEmpty());
+ REPORTER_ASSERT(reporter, geoCase.appliedFullStyleShape().isEmpty());
SkPaint peStroke;
peStroke.setPathEffect(EmptyPathEffect::Make());
REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedFullStyleKey() == emptyKey);
REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectKey() == emptyKey);
REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectThenStrokeKey() == emptyKey);
+ REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectShape().isEmpty());
+ REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedFullStyleShape().isEmpty());
}
void test_empty_shape(skiatest::Reporter* reporter) {
SkPath emptyPath;
SkPaint fill;
TestCase fillEmptyCase(emptyPath, fill, reporter);
+ REPORTER_ASSERT(reporter, fillEmptyCase.baseShape().isEmpty());
+ REPORTER_ASSERT(reporter, fillEmptyCase.appliedPathEffectShape().isEmpty());
+ REPORTER_ASSERT(reporter, fillEmptyCase.appliedFullStyleShape().isEmpty());
Key emptyKey(fillEmptyCase.baseKey());
REPORTER_ASSERT(reporter, emptyKey.count());