remove legacy defines
The defines SK_SUPPORT_LEGACY_ARCTO SK_SUPPORT_LEGACY_CONIC_MEASURE SK_SUPPORT_LEGACY_DASH_MEASURE SK_SUPPORT_LEGACY_HAIR_IGNORES_CAPS SK_SUPPORT_LEGACY_PATH_MEASURE_TVALUE have been removed from Chrome. This removes the obsolete code from Skia as well. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1627703002 Review URL: https://codereview.chromium.org/1627703002
This commit is contained in:
parent
8f66a8862f
commit
a273c0f667
@ -94,11 +94,7 @@ private:
|
||||
struct Segment {
|
||||
SkScalar fDistance; // total distance up to this point
|
||||
unsigned fPtIndex; // index into the fPts array
|
||||
#ifdef SK_SUPPORT_LEGACY_PATH_MEASURE_TVALUE
|
||||
unsigned fTValue : 15;
|
||||
#else
|
||||
unsigned fTValue : 30;
|
||||
#endif
|
||||
unsigned fType : 2;
|
||||
|
||||
SkScalar getScalarT() const;
|
||||
@ -111,20 +107,14 @@ private:
|
||||
void buildSegments();
|
||||
SkScalar compute_quad_segs(const SkPoint pts[3], SkScalar distance,
|
||||
int mint, int maxt, int ptIndex);
|
||||
#ifdef SK_SUPPORT_LEGACY_CONIC_MEASURE
|
||||
SkScalar compute_conic_segs(const SkConic&, SkScalar distance, int mint, int maxt, int ptIndex);
|
||||
#else
|
||||
SkScalar compute_conic_segs(const SkConic&, SkScalar distance,
|
||||
int mint, const SkPoint& minPt,
|
||||
int maxt, const SkPoint& maxPt, int ptIndex);
|
||||
#endif
|
||||
SkScalar compute_cubic_segs(const SkPoint pts[3], SkScalar distance,
|
||||
int mint, int maxt, int ptIndex);
|
||||
const Segment* distanceToSegment(SkScalar distance, SkScalar* t);
|
||||
bool quad_too_curvy(const SkPoint pts[3]);
|
||||
#ifndef SK_SUPPORT_LEGACY_CONIC_MEASURE
|
||||
bool conic_too_curvy(const SkPoint& firstPt, const SkPoint& midTPt,const SkPoint& lastPt);
|
||||
#endif
|
||||
bool cheap_dist_exceeds_limit(const SkPoint& pt, SkScalar x, SkScalar y);
|
||||
bool cubic_too_curvy(const SkPoint pts[4]);
|
||||
};
|
||||
|
@ -1146,9 +1146,6 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
|
||||
proc SK_INIT_TO_AVOID_WARNING;
|
||||
SkDEBUGFAIL("unknown paint cap type");
|
||||
}
|
||||
#ifdef SK_SUPPORT_LEGACY_HAIR_IGNORES_CAPS
|
||||
proc = SkScan::AntiHairPath;
|
||||
#endif
|
||||
} else {
|
||||
switch (paint->getStrokeCap()) {
|
||||
case SkPaint::kButt_Cap:
|
||||
@ -1164,9 +1161,6 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
|
||||
proc SK_INIT_TO_AVOID_WARNING;
|
||||
SkDEBUGFAIL("unknown paint cap type");
|
||||
}
|
||||
#ifdef SK_SUPPORT_LEGACY_HAIR_IGNORES_CAPS
|
||||
proc = SkScan::HairPath;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
proc(*devPathPtr, *fRC, blitter);
|
||||
|
@ -949,180 +949,6 @@ bool SkChopMonoCubicAtX(SkPoint src[4], SkScalar x, SkPoint dst[7]) {
|
||||
return cubic_dchop_at_intercept(src, x, dst, &SkDCubic::verticalIntersect);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ARCTO
|
||||
/* Find t value for quadratic [a, b, c] = d.
|
||||
Return 0 if there is no solution within [0, 1)
|
||||
*/
|
||||
static SkScalar quad_solve(SkScalar a, SkScalar b, SkScalar c, SkScalar d) {
|
||||
// At^2 + Bt + C = d
|
||||
SkScalar A = a - 2 * b + c;
|
||||
SkScalar B = 2 * (b - a);
|
||||
SkScalar C = a - d;
|
||||
|
||||
SkScalar roots[2];
|
||||
int count = SkFindUnitQuadRoots(A, B, C, roots);
|
||||
|
||||
SkASSERT(count <= 1);
|
||||
return count == 1 ? roots[0] : 0;
|
||||
}
|
||||
|
||||
/* given a quad-curve and a point (x,y), chop the quad at that point and place
|
||||
the new off-curve point and endpoint into 'dest'.
|
||||
Should only return false if the computed pos is the start of the curve
|
||||
(i.e. root == 0)
|
||||
*/
|
||||
static bool truncate_last_curve(const SkPoint quad[3], SkScalar x, SkScalar y,
|
||||
SkPoint* dest) {
|
||||
const SkScalar* base;
|
||||
SkScalar value;
|
||||
|
||||
if (SkScalarAbs(x) < SkScalarAbs(y)) {
|
||||
base = &quad[0].fX;
|
||||
value = x;
|
||||
} else {
|
||||
base = &quad[0].fY;
|
||||
value = y;
|
||||
}
|
||||
|
||||
// note: this returns 0 if it thinks value is out of range, meaning the
|
||||
// root might return something outside of [0, 1)
|
||||
SkScalar t = quad_solve(base[0], base[2], base[4], value);
|
||||
|
||||
if (t > 0) {
|
||||
SkPoint tmp[5];
|
||||
SkChopQuadAt(quad, tmp, t);
|
||||
dest[0] = tmp[1];
|
||||
dest[1].set(x, y);
|
||||
return true;
|
||||
} else {
|
||||
/* t == 0 means either the value triggered a root outside of [0, 1)
|
||||
For our purposes, we can ignore the <= 0 roots, but we want to
|
||||
catch the >= 1 roots (which given our caller, will basically mean
|
||||
a root of 1, give-or-take numerical instability). If we are in the
|
||||
>= 1 case, return the existing offCurve point.
|
||||
|
||||
The test below checks to see if we are close to the "end" of the
|
||||
curve (near base[4]). Rather than specifying a tolerance, I just
|
||||
check to see if value is on to the right/left of the middle point
|
||||
(depending on the direction/sign of the end points).
|
||||
*/
|
||||
if ((base[0] < base[4] && value > base[2]) ||
|
||||
(base[0] > base[4] && value < base[2])) // should root have been 1
|
||||
{
|
||||
dest[0] = quad[1];
|
||||
dest[1].set(x, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static const SkPoint gQuadCirclePts[kSkBuildQuadArcStorage] = {
|
||||
// The mid point of the quadratic arc approximation is half way between the two
|
||||
// control points. The float epsilon adjustment moves the on curve point out by
|
||||
// two bits, distributing the convex test error between the round rect
|
||||
// approximation and the convex cross product sign equality test.
|
||||
#define SK_MID_RRECT_OFFSET \
|
||||
(SK_Scalar1 + SK_ScalarTanPIOver8 + FLT_EPSILON * 4) / 2
|
||||
{ SK_Scalar1, 0 },
|
||||
{ SK_Scalar1, SK_ScalarTanPIOver8 },
|
||||
{ SK_MID_RRECT_OFFSET, SK_MID_RRECT_OFFSET },
|
||||
{ SK_ScalarTanPIOver8, SK_Scalar1 },
|
||||
|
||||
{ 0, SK_Scalar1 },
|
||||
{ -SK_ScalarTanPIOver8, SK_Scalar1 },
|
||||
{ -SK_MID_RRECT_OFFSET, SK_MID_RRECT_OFFSET },
|
||||
{ -SK_Scalar1, SK_ScalarTanPIOver8 },
|
||||
|
||||
{ -SK_Scalar1, 0 },
|
||||
{ -SK_Scalar1, -SK_ScalarTanPIOver8 },
|
||||
{ -SK_MID_RRECT_OFFSET, -SK_MID_RRECT_OFFSET },
|
||||
{ -SK_ScalarTanPIOver8, -SK_Scalar1 },
|
||||
|
||||
{ 0, -SK_Scalar1 },
|
||||
{ SK_ScalarTanPIOver8, -SK_Scalar1 },
|
||||
{ SK_MID_RRECT_OFFSET, -SK_MID_RRECT_OFFSET },
|
||||
{ SK_Scalar1, -SK_ScalarTanPIOver8 },
|
||||
|
||||
{ SK_Scalar1, 0 }
|
||||
#undef SK_MID_RRECT_OFFSET
|
||||
};
|
||||
|
||||
int SkBuildQuadArc(const SkVector& uStart, const SkVector& uStop,
|
||||
SkRotationDirection dir, const SkMatrix* userMatrix,
|
||||
SkPoint quadPoints[]) {
|
||||
// rotate by x,y so that uStart is (1.0)
|
||||
SkScalar x = SkPoint::DotProduct(uStart, uStop);
|
||||
SkScalar y = SkPoint::CrossProduct(uStart, uStop);
|
||||
|
||||
SkScalar absX = SkScalarAbs(x);
|
||||
SkScalar absY = SkScalarAbs(y);
|
||||
|
||||
int pointCount;
|
||||
|
||||
// check for (effectively) coincident vectors
|
||||
// this can happen if our angle is nearly 0 or nearly 180 (y == 0)
|
||||
// ... we use the dot-prod to distinguish between 0 and 180 (x > 0)
|
||||
if (absY <= SK_ScalarNearlyZero && x > 0 &&
|
||||
((y >= 0 && kCW_SkRotationDirection == dir) ||
|
||||
(y <= 0 && kCCW_SkRotationDirection == dir))) {
|
||||
|
||||
// just return the start-point
|
||||
quadPoints[0].set(SK_Scalar1, 0);
|
||||
pointCount = 1;
|
||||
} else {
|
||||
if (dir == kCCW_SkRotationDirection) {
|
||||
y = -y;
|
||||
}
|
||||
// what octant (quadratic curve) is [xy] in?
|
||||
int oct = 0;
|
||||
bool sameSign = true;
|
||||
|
||||
if (0 == y) {
|
||||
oct = 4; // 180
|
||||
SkASSERT(SkScalarAbs(x + SK_Scalar1) <= SK_ScalarNearlyZero);
|
||||
} else if (0 == x) {
|
||||
SkASSERT(absY - SK_Scalar1 <= SK_ScalarNearlyZero);
|
||||
oct = y > 0 ? 2 : 6; // 90 : 270
|
||||
} else {
|
||||
if (y < 0) {
|
||||
oct += 4;
|
||||
}
|
||||
if ((x < 0) != (y < 0)) {
|
||||
oct += 2;
|
||||
sameSign = false;
|
||||
}
|
||||
if ((absX < absY) == sameSign) {
|
||||
oct += 1;
|
||||
}
|
||||
}
|
||||
|
||||
int wholeCount = oct << 1;
|
||||
memcpy(quadPoints, gQuadCirclePts, (wholeCount + 1) * sizeof(SkPoint));
|
||||
|
||||
const SkPoint* arc = &gQuadCirclePts[wholeCount];
|
||||
if (truncate_last_curve(arc, x, y, &quadPoints[wholeCount + 1])) {
|
||||
wholeCount += 2;
|
||||
}
|
||||
pointCount = wholeCount + 1;
|
||||
}
|
||||
|
||||
// now handle counter-clockwise and the initial unitStart rotation
|
||||
SkMatrix matrix;
|
||||
matrix.setSinCos(uStart.fY, uStart.fX);
|
||||
if (dir == kCCW_SkRotationDirection) {
|
||||
matrix.preScale(SK_Scalar1, -SK_Scalar1);
|
||||
}
|
||||
if (userMatrix) {
|
||||
matrix.postConcat(*userMatrix);
|
||||
}
|
||||
matrix.mapPoints(quadPoints, pointCount);
|
||||
return pointCount;
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NURB representation for conics. Helpful explanations at:
|
||||
|
@ -194,22 +194,6 @@ enum SkRotationDirection {
|
||||
kCCW_SkRotationDirection
|
||||
};
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ARCTO
|
||||
/** Maximum number of points needed in the quadPoints[] parameter for
|
||||
SkBuildQuadArc()
|
||||
*/
|
||||
#define kSkBuildQuadArcStorage 17
|
||||
|
||||
/** Given 2 unit vectors and a rotation direction, fill out the specified
|
||||
array of points with quadratic segments. Return is the number of points
|
||||
written to, which will be { 0, 3, 5, 7, ... kSkBuildQuadArcStorage }
|
||||
|
||||
matrix, if not null, is appled to the points before they are returned.
|
||||
*/
|
||||
int SkBuildQuadArc(const SkVector& unitStart, const SkVector& unitStop,
|
||||
SkRotationDirection, const SkMatrix*, SkPoint quadPoints[]);
|
||||
#endif
|
||||
|
||||
struct SkConic {
|
||||
SkConic() {}
|
||||
SkConic(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2, SkScalar w) {
|
||||
|
@ -1414,41 +1414,10 @@ void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar
|
||||
|
||||
SkScalar xx = x1 - SkScalarMul(dist, before.fX);
|
||||
SkScalar yy = y1 - SkScalarMul(dist, before.fY);
|
||||
#ifndef SK_SUPPORT_LEGACY_ARCTO
|
||||
after.setLength(dist);
|
||||
this->lineTo(xx, yy);
|
||||
SkScalar weight = SkScalarSqrt(SK_ScalarHalf + cosh * SK_ScalarHalf);
|
||||
this->conicTo(x1, y1, x1 + after.fX, y1 + after.fY, weight);
|
||||
#else
|
||||
SkRotationDirection arcDir;
|
||||
|
||||
// now turn before/after into normals
|
||||
if (sinh > 0) {
|
||||
before.rotateCCW();
|
||||
after.rotateCCW();
|
||||
arcDir = kCW_SkRotationDirection;
|
||||
} else {
|
||||
before.rotateCW();
|
||||
after.rotateCW();
|
||||
arcDir = kCCW_SkRotationDirection;
|
||||
}
|
||||
|
||||
SkMatrix matrix;
|
||||
SkPoint pts[kSkBuildQuadArcStorage];
|
||||
|
||||
matrix.setScale(radius, radius);
|
||||
matrix.postTranslate(xx - SkScalarMul(radius, before.fX),
|
||||
yy - SkScalarMul(radius, before.fY));
|
||||
|
||||
int count = SkBuildQuadArc(before, after, arcDir, &matrix, pts);
|
||||
|
||||
this->incReserve(count);
|
||||
// [xx,yy] == pts[0]
|
||||
this->lineTo(xx, yy);
|
||||
for (int i = 1; i < count; i += 2) {
|
||||
this->quadTo(pts[i], pts[i+1]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -20,20 +20,12 @@ enum {
|
||||
kConic_SegType,
|
||||
};
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_PATH_MEASURE_TVALUE
|
||||
#define kMaxTValue 32767
|
||||
#else
|
||||
#define kMaxTValue 0x3FFFFFFF
|
||||
#endif
|
||||
|
||||
static inline SkScalar tValue2Scalar(int t) {
|
||||
SkASSERT((unsigned)t <= kMaxTValue);
|
||||
#ifdef SK_SUPPORT_LEGACY_PATH_MEASURE_TVALUE
|
||||
return t * 3.05185e-5f; // t / 32767
|
||||
#else
|
||||
const SkScalar kMaxTReciprocal = 1.0f / kMaxTValue;
|
||||
return t * kMaxTReciprocal;
|
||||
#endif
|
||||
}
|
||||
|
||||
SkScalar SkPathMeasure::Segment::getScalarT() const {
|
||||
@ -73,7 +65,6 @@ bool SkPathMeasure::quad_too_curvy(const SkPoint pts[3]) {
|
||||
return dist > fTolerance;
|
||||
}
|
||||
|
||||
#ifndef SK_SUPPORT_LEGACY_CONIC_MEASURE
|
||||
bool SkPathMeasure::conic_too_curvy(const SkPoint& firstPt, const SkPoint& midTPt,
|
||||
const SkPoint& lastPt) {
|
||||
SkPoint midEnds = firstPt + lastPt;
|
||||
@ -82,7 +73,6 @@ bool SkPathMeasure::conic_too_curvy(const SkPoint& firstPt, const SkPoint& midTP
|
||||
SkScalar dist = SkMaxScalar(SkScalarAbs(dxy.fX), SkScalarAbs(dxy.fY));
|
||||
return dist > fTolerance;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool SkPathMeasure::cheap_dist_exceeds_limit(const SkPoint& pt,
|
||||
SkScalar x, SkScalar y) {
|
||||
@ -177,31 +167,6 @@ SkScalar SkPathMeasure::compute_quad_segs(const SkPoint pts[3],
|
||||
return distance;
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_CONIC_MEASURE
|
||||
SkScalar SkPathMeasure::compute_conic_segs(const SkConic& conic,
|
||||
SkScalar distance, int mint, int maxt, int ptIndex) {
|
||||
if (tspan_big_enough(maxt - mint) && quad_too_curvy(conic.fPts)) {
|
||||
SkConic tmp[2];
|
||||
conic.chop(tmp);
|
||||
|
||||
int halft = (mint + maxt) >> 1;
|
||||
distance = this->compute_conic_segs(tmp[0], distance, mint, halft, ptIndex);
|
||||
distance = this->compute_conic_segs(tmp[1], distance, halft, maxt, ptIndex);
|
||||
} else {
|
||||
SkScalar d = SkPoint::Distance(conic.fPts[0], conic.fPts[2]);
|
||||
SkScalar prevD = distance;
|
||||
distance += d;
|
||||
if (distance > prevD) {
|
||||
Segment* seg = fSegments.append();
|
||||
seg->fDistance = distance;
|
||||
seg->fPtIndex = ptIndex;
|
||||
seg->fType = kConic_SegType;
|
||||
seg->fTValue = maxt;
|
||||
}
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
#else
|
||||
SkScalar SkPathMeasure::compute_conic_segs(const SkConic& conic, SkScalar distance,
|
||||
int mint, const SkPoint& minPt,
|
||||
int maxt, const SkPoint& maxPt, int ptIndex) {
|
||||
@ -224,7 +189,6 @@ SkScalar SkPathMeasure::compute_conic_segs(const SkConic& conic, SkScalar distan
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
#endif
|
||||
|
||||
SkScalar SkPathMeasure::compute_cubic_segs(const SkPoint pts[4],
|
||||
SkScalar distance, int mint, int maxt, int ptIndex) {
|
||||
@ -319,12 +283,8 @@ void SkPathMeasure::buildSegments() {
|
||||
case SkPath::kConic_Verb: {
|
||||
const SkConic conic(pts, fIter.conicWeight());
|
||||
SkScalar prevD = distance;
|
||||
#ifdef SK_SUPPORT_LEGACY_CONIC_MEASURE
|
||||
distance = this->compute_conic_segs(conic, distance, 0, kMaxTValue, ptIndex);
|
||||
#else
|
||||
distance = this->compute_conic_segs(conic, distance, 0, conic.fPts[0],
|
||||
kMaxTValue, conic.fPts[2], ptIndex);
|
||||
#endif
|
||||
if (distance > prevD) {
|
||||
// we store the conic weight in our next point, followed by the last 2 pts
|
||||
// thus to reconstitue a conic, you'd need to say
|
||||
@ -477,17 +437,6 @@ static void seg_to(const SkPoint pts[], int segType,
|
||||
dst->conicTo(tmp[0].fPts[1], tmp[0].fPts[2], tmp[0].fW);
|
||||
}
|
||||
} else {
|
||||
#ifdef SK_SUPPORT_LEGACY_CONIC_MEASURE
|
||||
SkConic tmp1[2];
|
||||
conic.chopAt(startT, tmp1);
|
||||
if (SK_Scalar1 == stopT) {
|
||||
dst->conicTo(tmp1[1].fPts[1], tmp1[1].fPts[2], tmp1[1].fW);
|
||||
} else {
|
||||
SkConic tmp2[2];
|
||||
tmp1[1].chopAt((stopT - startT) / (SK_Scalar1 - startT), tmp2);
|
||||
dst->conicTo(tmp2[0].fPts[1], tmp2[0].fPts[2], tmp2[0].fW);
|
||||
}
|
||||
#else
|
||||
if (SK_Scalar1 == stopT) {
|
||||
SkConic tmp1[2];
|
||||
conic.chopAt(startT, tmp1);
|
||||
@ -497,7 +446,6 @@ static void seg_to(const SkPoint pts[], int segType,
|
||||
conic.chopAt(startT, stopT, &tmp);
|
||||
dst->conicTo(tmp.fPts[1], tmp.fPts[2], tmp.fW);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} break;
|
||||
case kCubic_SegType:
|
||||
@ -537,11 +485,7 @@ SkPathMeasure::SkPathMeasure() {
|
||||
|
||||
SkPathMeasure::SkPathMeasure(const SkPath& path, bool forceClosed, SkScalar resScale) {
|
||||
fPath = &path;
|
||||
#ifdef SK_SUPPORT_LEGACY_DASH_MEASURE
|
||||
fTolerance = CHEAP_DIST_LIMIT;
|
||||
#else
|
||||
fTolerance = CHEAP_DIST_LIMIT * SkScalarInvert(resScale);
|
||||
#endif
|
||||
fLength = -1; // signal we need to compute it
|
||||
fForceClosed = forceClosed;
|
||||
fFirstPtIndex = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user