| Index: src/gpu/GrShape.h
|
| diff --git a/src/gpu/GrShape.h b/src/gpu/GrShape.h
|
| index 87ee26e17333a50b7df08cb0bde4b19d51835ced..8f3be58702820eb0c4d7161b290a9477a5d640ac 100644
|
| --- a/src/gpu/GrShape.h
|
| +++ b/src/gpu/GrShape.h
|
| @@ -152,12 +152,19 @@ public:
|
| * If the unstyled shape is a straight line segment, returns true and sets pts to the endpoints.
|
| * An inverse filled line path is still considered a line.
|
| */
|
| - bool asLine(SkPoint pts[2]) const {
|
| - if (fType != Type::kPath) {
|
| - return false;
|
| - }
|
| - return this->path().isLine(pts);
|
| - }
|
| + bool asLine(SkPoint pts[2], bool* inverted) const {
|
| + if (fType != Type::kLine) {
|
| + return false;
|
| + }
|
| + if (pts) {
|
| + pts[0] = fLineData.fPts[0];
|
| + pts[1] = fLineData.fPts[1];
|
| + }
|
| + if (inverted) {
|
| + *inverted = fLineData.fInverted;
|
| + }
|
| + return true;
|
| + }
|
|
|
| /** Returns the unstyled geometry as a path. */
|
| void asPath(SkPath* out) const {
|
| @@ -175,6 +182,16 @@ public:
|
| out->setFillType(kDefaultPathFillType);
|
| }
|
| break;
|
| + case Type::kLine:
|
| + out->reset();
|
| + out->moveTo(fLineData.fPts[0]);
|
| + out->lineTo(fLineData.fPts[1]);
|
| + if (fLineData.fInverted) {
|
| + out->setFillType(kDefaultPathInverseFillType);
|
| + } else {
|
| + out->setFillType(kDefaultPathFillType);
|
| + }
|
| + break;
|
| case Type::kPath:
|
| *out = this->path();
|
| break;
|
| @@ -191,13 +208,13 @@ public:
|
| * Gets the bounds of the geometry without reflecting the shape's styling. This ignores
|
| * the inverse fill nature of the geometry.
|
| */
|
| - const SkRect& bounds() const;
|
| + SkRect bounds() const;
|
|
|
| /**
|
| * Gets the bounds of the geometry reflecting the shape's styling (ignoring inverse fill
|
| * status).
|
| */
|
| - void styledBounds(SkRect* bounds) const;
|
| + SkRect styledBounds() const;
|
|
|
| /**
|
| * Is this shape known to be convex, before styling is applied. An unclosed but otherwise
|
| @@ -210,6 +227,8 @@ public:
|
| return true;
|
| case Type::kRRect:
|
| return true;
|
| + case Type::kLine:
|
| + return true;
|
| case Type::kPath:
|
| // SkPath.isConvex() really means "is this path convex were it to be closed" and
|
| // thus doesn't give the correct answer for stroked paths, hence we also check
|
| @@ -231,6 +250,9 @@ public:
|
| case Type::kRRect:
|
| ret = fRRectData.fInverted;
|
| break;
|
| + case Type::kLine:
|
| + ret = fLineData.fInverted;
|
| + break;
|
| case Type::kPath:
|
| ret = this->path().isInverseFillType();
|
| break;
|
| @@ -264,6 +286,8 @@ public:
|
| return true;
|
| case Type::kRRect:
|
| return true;
|
| + case Type::kLine:
|
| + return false;
|
| case Type::kPath:
|
| // SkPath doesn't keep track of the closed status of each contour.
|
| return SkPathPriv::IsClosedSingleContour(this->path());
|
| @@ -282,6 +306,8 @@ public:
|
| return SkPath::kLine_SegmentMask;
|
| }
|
| return SkPath::kLine_SegmentMask | SkPath::kConic_SegmentMask;
|
| + case Type::kLine:
|
| + return SkPath::kLine_SegmentMask;
|
| case Type::kPath:
|
| return this->path().getSegmentMasks();
|
| }
|
| @@ -307,6 +333,7 @@ private:
|
| enum class Type {
|
| kEmpty,
|
| kRRect,
|
| + kLine,
|
| kPath,
|
| };
|
|
|
| @@ -356,6 +383,7 @@ private:
|
|
|
| void attemptToSimplifyPath();
|
| void attemptToSimplifyRRect();
|
| + void attemptToSimplifyLine();
|
|
|
| // Defaults to use when there is no distinction between even/odd and winding fills.
|
| static constexpr SkPath::FillType kDefaultPathFillType = SkPath::kEvenOdd_FillType;
|
| @@ -420,6 +448,10 @@ private:
|
| // Gen ID of the original path (fPath may be modified)
|
| int32_t fGenID;
|
| } fPathData;
|
| + struct {
|
| + SkPoint fPts[2];
|
| + bool fInverted;
|
| + } fLineData;
|
| };
|
| GrStyle fStyle;
|
| SkAutoSTArray<8, uint32_t> fInheritedKey;
|
|
|