Revert "Reland "Reland "Omit inner join geometry when possible"""
This reverts commit40dfc67917
. Reason for revert: same android CTS failures Original change's description: > Reland "Reland "Omit inner join geometry when possible"" > > This reverts commitbdc412f149
. > > Original change's description: > > Revert "Reland "Omit inner join geometry when possible"" > > > > This reverts commit44edd1952a
. > > > > Reason for revert: problematic gold diffs (e.g. paths-data-10-t) and androit CTS failures > > > > Original change's description: > > > Reland "Omit inner join geometry when possible" > > > > > > This is a reland of1b0a95e0ee
> > > > > > Original change's description: > > > > Omit inner join geometry when possible > > > > > > > > There is some relatively cheap math we can do to determine easy cases > > > > when the inner join geometry can be skipped. This CL is not > > > > comprehensive in that there may be other cases where we can skip the > > > > geometry. > > > > > > > > Only handling miter joins in this CL - the other join types can likely > > > > have similar logic, but will require a bit more computation to compute > > > > the inner (reflected) miter point. > > > > > > > > Misc notes: > > > > - Added SK_LEGACY_INNER_JOINS ifdef in the event that clients depend on > > > > the old behavior. > > > > - Modified stroker to track "previous previous" point, which is the > > > > start point of the previous line segment. > > > > > > > > Bug: b/165379671, skia:11964 > > > > Change-Id: I56789e85a2b4627c32f2a30fe60e47d448e9adf3 > > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404717 > > > > Reviewed-by: Mike Reed <reed@google.com> > > > > Commit-Queue: Tyler Denniston <tdenniston@google.com> > > > > > > Bug: b/165379671, skia:11964 > > > Change-Id: If8bf183db9379d0a98a6f88e70f871a559692a60 > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423821 > > > Reviewed-by: Tyler Denniston <tdenniston@google.com> > > > Commit-Queue: Tyler Denniston <tdenniston@google.com> > > > > TBR=reed@google.com,tdenniston@google.com > > > > Change-Id: I5a2dfd402269db6c788f0e0625f67e9bf3b1f5cf > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: b/165379671, skia:11964 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426059 > > Reviewed-by: Tyler Denniston <tdenniston@google.com> > > Commit-Queue: Tyler Denniston <tdenniston@google.com> > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: b/165379671, skia:11964 > Change-Id: Icfd420954a291f414fc2cb5cc2fe2756224a5d8d > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436518 > Reviewed-by: Tyler Denniston <tdenniston@google.com> > Commit-Queue: Tyler Denniston <tdenniston@google.com> TBR=reed@google.com,tdenniston@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com Change-Id: Ifbca34b8ff836aee6b517f58cbf05cf0aa38eace No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: b/165379671, skia:11964 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436567 Reviewed-by: Tyler Denniston <tdenniston@google.com> Commit-Queue: Tyler Denniston <tdenniston@google.com>
This commit is contained in:
parent
b449fff1d8
commit
cc04b6f0bf
@ -644,17 +644,3 @@ DEF_SIMPLE_GM(skbug12244, canvas, 150, 150) {
|
||||
canvas->translate(20.f, 20.f);
|
||||
canvas->drawPath(path, p);
|
||||
}
|
||||
|
||||
DEF_SIMPLE_GM(b165379671, canvas, 200, 200) {
|
||||
SkPaint p;
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setAntiAlias(true);
|
||||
p.setStrokeWidth(16.0f);
|
||||
|
||||
SkPath path;
|
||||
path.moveTo(100.0f, 72.0f);
|
||||
path.lineTo(98.0f, 110.0f);
|
||||
path.lineTo(97.0f, 121.0f);
|
||||
|
||||
canvas->drawPath(path, p);
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ private:
|
||||
SkScalar fInvResScaleSquared;
|
||||
|
||||
SkVector fFirstNormal, fPrevNormal, fFirstUnitNormal, fPrevUnitNormal;
|
||||
SkPoint fFirstPt, fPrevPt, fPrevPrevPt; // on original path
|
||||
SkPoint fFirstPt, fPrevPt; // on original path
|
||||
SkPoint fFirstOuterPt;
|
||||
int fFirstOuterPtIndexInContour;
|
||||
int fSegmentCount;
|
||||
@ -311,8 +311,7 @@ bool SkPathStroker::preJoinTo(const SkPoint& currPt, SkVector* normal,
|
||||
fInner.moveTo(prevX - normal->fX, prevY - normal->fY);
|
||||
} else { // we have a previous segment
|
||||
fJoiner(&fOuter, &fInner, fPrevUnitNormal, fPrevPt, *unitNormal,
|
||||
fRadius, fInvMiterLimit, fPrevIsLine, currIsLine,
|
||||
fPrevPrevPt, currPt);
|
||||
fRadius, fInvMiterLimit, fPrevIsLine, currIsLine);
|
||||
}
|
||||
fPrevIsLine = currIsLine;
|
||||
return true;
|
||||
@ -321,7 +320,6 @@ bool SkPathStroker::preJoinTo(const SkPoint& currPt, SkVector* normal,
|
||||
void SkPathStroker::postJoinTo(const SkPoint& currPt, const SkVector& normal,
|
||||
const SkVector& unitNormal) {
|
||||
fJoinCompleted = true;
|
||||
fPrevPrevPt = fPrevPt;
|
||||
fPrevPt = currPt;
|
||||
fPrevUnitNormal = unitNormal;
|
||||
fPrevNormal = normal;
|
||||
@ -335,7 +333,7 @@ void SkPathStroker::finishContour(bool close, bool currIsLine) {
|
||||
if (close) {
|
||||
fJoiner(&fOuter, &fInner, fPrevUnitNormal, fPrevPt,
|
||||
fFirstUnitNormal, fRadius, fInvMiterLimit,
|
||||
fPrevIsLine, currIsLine, fPrevPrevPt, fFirstPt);
|
||||
fPrevIsLine, currIsLine);
|
||||
fOuter.close();
|
||||
|
||||
if (fCanIgnoreCenter) {
|
||||
@ -424,7 +422,7 @@ void SkPathStroker::moveTo(const SkPoint& pt) {
|
||||
this->finishContour(false, false);
|
||||
}
|
||||
fSegmentCount = 0;
|
||||
fFirstPt = fPrevPt = fPrevPrevPt = pt;
|
||||
fFirstPt = fPrevPt = pt;
|
||||
fJoinCompleted = false;
|
||||
}
|
||||
|
||||
|
@ -67,86 +67,6 @@ static AngleType Dot2AngleType(SkScalar dot) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Consider the two line segments:
|
||||
*
|
||||
* s Inside
|
||||
* q +------+-----------------+
|
||||
* | | |
|
||||
* prevPt +------+ pivotPt---------+ nextPt
|
||||
* | | |
|
||||
* +------+-----------------+
|
||||
* Outside
|
||||
*
|
||||
* If the perpendicular distance from q to the line (pivot, nextPt) is less than
|
||||
* the stroke radius, the inner join geometry is needed. Or if s, which is the first
|
||||
* point on the inner stroke of the next segment, lies to the left of line (prevPt, q),
|
||||
* we also need the inner join. Then, we also need to check the reverse configuration:
|
||||
*
|
||||
* s Inside q
|
||||
* +------+-----------------+
|
||||
* | | |
|
||||
* prevPt +------+ pivotPt---------+ nextPt
|
||||
* | | |
|
||||
* +------+-----------------+
|
||||
* Outside
|
||||
*
|
||||
* In the reverse case, s is the last point on the inner stroke of the previous
|
||||
* segment (no longer the first point on the inner stroke of the next segment).
|
||||
*/
|
||||
static bool NeedInnerJoin(const SkPoint& beforeUnitNormal,
|
||||
const SkPoint& afterUnitNormal,
|
||||
const SkPoint& prevPt,
|
||||
const SkPoint& pivot,
|
||||
const SkPoint& nextPt,
|
||||
float radius,
|
||||
bool ccw) {
|
||||
#ifdef SK_LEGACY_INNER_JOINS
|
||||
// Previously we would always add inner joins.
|
||||
return true;
|
||||
#else
|
||||
SkPoint scaledBefore = beforeUnitNormal;
|
||||
scaledBefore.scale(radius);
|
||||
SkPoint scaledAfter = afterUnitNormal;
|
||||
scaledAfter.scale(radius);
|
||||
|
||||
const int sgn = ccw ? 1 : -1;
|
||||
bool needInnerJoin = false;
|
||||
|
||||
// Forward case
|
||||
{
|
||||
const SkPoint q = prevPt - scaledBefore;
|
||||
const SkPoint s = pivot - scaledAfter;
|
||||
|
||||
// Perpendicular distance
|
||||
const SkPoint n = -afterUnitNormal;
|
||||
needInnerJoin |= n.dot(q - pivot) < radius;
|
||||
|
||||
// Which-side-of-line
|
||||
const SkPoint v1 = s - prevPt;
|
||||
const SkPoint v2 = q - prevPt;
|
||||
needInnerJoin |= sgn * v1.cross(v2) > 0;
|
||||
}
|
||||
|
||||
// Reverse
|
||||
{
|
||||
const SkPoint q = nextPt - scaledAfter;
|
||||
const SkPoint s = pivot - scaledBefore;
|
||||
|
||||
// Perpendicular distance
|
||||
const SkPoint n = -beforeUnitNormal;
|
||||
needInnerJoin |= n.dot(q - pivot) < radius;
|
||||
|
||||
// Which-side-of-line
|
||||
const SkPoint v1 = s - nextPt;
|
||||
const SkPoint v2 = q - nextPt;
|
||||
needInnerJoin |= sgn * v1.cross(v2) < 0;
|
||||
}
|
||||
|
||||
return needInnerJoin;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void HandleInnerJoin(SkPath* inner, const SkPoint& pivot, const SkVector& after) {
|
||||
#if 1
|
||||
/* In the degenerate case that the stroke radius is larger than our segments
|
||||
@ -163,8 +83,7 @@ static void HandleInnerJoin(SkPath* inner, const SkPoint& pivot, const SkVector&
|
||||
|
||||
static void BluntJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnitNormal,
|
||||
const SkPoint& pivot, const SkVector& afterUnitNormal,
|
||||
SkScalar radius, SkScalar invMiterLimit, bool, bool,
|
||||
const SkPoint&, const SkPoint&) {
|
||||
SkScalar radius, SkScalar invMiterLimit, bool, bool) {
|
||||
SkVector after;
|
||||
afterUnitNormal.scale(radius, &after);
|
||||
|
||||
@ -180,8 +99,7 @@ static void BluntJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit
|
||||
|
||||
static void RoundJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnitNormal,
|
||||
const SkPoint& pivot, const SkVector& afterUnitNormal,
|
||||
SkScalar radius, SkScalar invMiterLimit, bool, bool,
|
||||
const SkPoint&, const SkPoint&) {
|
||||
SkScalar radius, SkScalar invMiterLimit, bool, bool) {
|
||||
SkScalar dotProd = SkPoint::DotProduct(beforeUnitNormal, afterUnitNormal);
|
||||
AngleType angleType = Dot2AngleType(dotProd);
|
||||
|
||||
@ -219,8 +137,7 @@ static void RoundJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit
|
||||
static void MiterJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnitNormal,
|
||||
const SkPoint& pivot, const SkVector& afterUnitNormal,
|
||||
SkScalar radius, SkScalar invMiterLimit,
|
||||
bool prevIsLine, bool currIsLine,
|
||||
const SkPoint& prevPt, const SkPoint& nextPt) {
|
||||
bool prevIsLine, bool currIsLine) {
|
||||
// negate the dot since we're using normals instead of tangents
|
||||
SkScalar dotProd = SkPoint::DotProduct(beforeUnitNormal, afterUnitNormal);
|
||||
AngleType angleType = Dot2AngleType(dotProd);
|
||||
@ -228,7 +145,7 @@ static void MiterJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit
|
||||
SkVector after = afterUnitNormal;
|
||||
SkVector mid;
|
||||
SkScalar sinHalfAngle;
|
||||
bool ccw = !is_clockwise(before, after);
|
||||
bool ccw;
|
||||
|
||||
if (angleType == kNearlyLine_AngleType) {
|
||||
return;
|
||||
@ -238,6 +155,7 @@ static void MiterJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit
|
||||
goto DO_BLUNT;
|
||||
}
|
||||
|
||||
ccw = !is_clockwise(before, after);
|
||||
if (ccw) {
|
||||
using std::swap;
|
||||
swap(outer, inner);
|
||||
@ -289,21 +207,11 @@ DO_MITER:
|
||||
}
|
||||
|
||||
DO_BLUNT:
|
||||
// Save copy of unit normal before scaling it
|
||||
const SkPoint savedAfter = after;
|
||||
after.scale(radius);
|
||||
if (!currIsLine) {
|
||||
outer->lineTo(pivot.fX + after.fX, pivot.fY + after.fY);
|
||||
}
|
||||
|
||||
// With two line segments, sometimes we can omit the inner join geometry.
|
||||
if (prevIsLine && currIsLine &&
|
||||
!NeedInnerJoin(before, savedAfter, prevPt, pivot, nextPt, radius, ccw)) {
|
||||
// Skip the inner join: move last inner point to mirrored miter point.
|
||||
inner->setLastPt(pivot - mid);
|
||||
} else {
|
||||
HandleInnerJoin(inner, pivot, after);
|
||||
}
|
||||
HandleInnerJoin(inner, pivot, after);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -34,8 +34,7 @@ public:
|
||||
const SkPoint& pivot,
|
||||
const SkVector& afterUnitNormal,
|
||||
SkScalar radius, SkScalar invMiterLimit,
|
||||
bool prevIsLine, bool currIsLine,
|
||||
const SkPoint& prevPt, const SkPoint& nextPt);
|
||||
bool prevIsLine, bool currIsLine);
|
||||
|
||||
static CapProc CapFactory(SkPaint::Cap);
|
||||
static JoinProc JoinFactory(SkPaint::Join);
|
||||
|
Loading…
Reference in New Issue
Block a user