Lines Matching refs:src
203 static SkScalar eval_quad(const SkScalar src[], SkScalar t)
205 SkASSERT(src);
209 SkScalar C = src[0];
210 SkScalar A = src[4] - 2 * src[2] + C;
211 SkScalar B = 2 * (src[2] - C);
214 SkScalar ab = SkScalarInterp(src[0], src[2], t);
215 SkScalar bc = SkScalarInterp(src[2], src[4], t);
220 static SkScalar eval_quad_derivative(const SkScalar src[], SkScalar t)
222 SkScalar A = src[4] - 2 * src[2] + src[0];
223 SkScalar B = src[2] - src[0];
228 static SkScalar eval_quad_derivative_at_half(const SkScalar src[])
230 SkScalar A = src[4] - 2 * src[2] + src[0];
231 SkScalar B = src[2] - src[0];
235 void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tangent)
237 SkASSERT(src);
241 pt->set(eval_quad(&src[0].fX, t), eval_quad(&src[0].fY, t));
243 tangent->set(eval_quad_derivative(&src[0].fX, t),
244 eval_quad_derivative(&src[0].fY, t));
247 void SkEvalQuadAtHalf(const SkPoint src[3], SkPoint* pt, SkVector* tangent)
249 SkASSERT(src);
253 SkScalar x01 = SkScalarAve(src[0].fX, src[1].fX);
254 SkScalar y01 = SkScalarAve(src[0].fY, src[1].fY);
255 SkScalar x12 = SkScalarAve(src[1].fX, src[2].fX);
256 SkScalar y12 = SkScalarAve(src[1].fY, src[2].fY);
260 tangent->set(eval_quad_derivative_at_half(&src[0].fX),
261 eval_quad_derivative_at_half(&src[0].fY));
264 static void interp_quad_coords(const SkScalar* src, SkScalar* dst, SkScalar t)
266 SkScalar ab = SkScalarInterp(src[0], src[2], t);
267 SkScalar bc = SkScalarInterp(src[2], src[4], t);
269 dst[0] = src[0];
273 dst[8] = src[4];
276 void SkChopQuadAt(const SkPoint src[3], SkPoint dst[5], SkScalar t)
280 interp_quad_coords(&src[0].fX, &dst[0].fX, t);
281 interp_quad_coords(&src[0].fY, &dst[0].fY, t);
284 void SkChopQuadAtHalf(const SkPoint src[3], SkPoint dst[5])
286 SkScalar x01 = SkScalarAve(src[0].fX, src[1].fX);
287 SkScalar y01 = SkScalarAve(src[0].fY, src[1].fY);
288 SkScalar x12 = SkScalarAve(src[1].fX, src[2].fX);
289 SkScalar y12 = SkScalarAve(src[1].fY, src[2].fY);
291 dst[0] = src[0];
295 dst[4] = src[2];
323 int SkChopQuadAtYExtrema(const SkPoint src[3], SkPoint dst[5])
325 SkASSERT(src);
341 SkScalar a = src[0].fY;
342 SkScalar b = src[1].fY;
343 SkScalar c = src[2].fY;
350 SkChopQuadAt(src, dst, tValue);
358 dst[0].set(src[0].fX, a);
359 dst[1].set(src[1].fX, b);
360 dst[2].set(src[2].fX, c);
367 int SkChopQuadAtXExtrema(const SkPoint src[3], SkPoint dst[5])
369 SkASSERT(src);
372 SkScalar a = src[0].fX;
373 SkScalar b = src[1].fX;
374 SkScalar c = src[2].fX;
379 SkChopQuadAt(src, dst, tValue);
387 dst[0].set(a, src[0].fY);
388 dst[1].set(b, src[1].fY);
389 dst[2].set(c, src[2].fY);
405 int SkChopQuadAtMaxCurvature(const SkPoint src[3], SkPoint dst[5])
407 SkScalar Ax = src[1].fX - src[0].fX;
408 SkScalar Ay = src[1].fY - src[0].fY;
409 SkScalar Bx = src[0].fX - src[1].fX - src[1].fX + src[2].fX;
410 SkScalar By = src[0].fY - src[1].fY - src[1].fY + src[2].fY;
441 memcpy(dst, src, 3 * sizeof(SkPoint));
446 SkChopQuadAt(src, dst, t);
451 void SkConvertQuadToCubic(const SkPoint src[3], SkPoint dst[4])
455 dst[0].set(src[0].fX, src[0].fY);
457 SkScalarMul(SkScalarMulAdd(src[1].fX, two, src[0].fX), one_third),
458 SkScalarMul(SkScalarMulAdd(src[1].fY, two, src[0].fY), one_third));
460 SkScalarMul(SkScalarMulAdd(src[1].fX, two, src[2].fX), one_third),
461 SkScalarMul(SkScalarMulAdd(src[1].fY, two, src[2].fY), one_third));
462 dst[3].set(src[2].fX, src[2].fY);
487 static SkScalar eval_cubic(const SkScalar src[], SkScalar t)
489 SkASSERT(src);
493 return src[0];
496 SkScalar D = src[0];
497 SkScalar A = src[6] + 3*(src[2] - src[4]) - D;
498 SkScalar B = 3*(src[4] - src[2] - src[2] + D);
499 SkScalar C = 3*(src[2] - D);
503 SkScalar ab = SkScalarInterp(src[0], src[2], t);
504 SkScalar bc = SkScalarInterp(src[2], src[4], t);
505 SkScalar cd = SkScalarInterp(src[4], src[6], t);
521 static SkScalar eval_cubic_derivative(const SkScalar src[], SkScalar t)
523 SkScalar A = src[6] + 3*(src[2] - src[4]) - src[0];
524 SkScalar B = 2*(src[4] - 2 * src[2] + src[0]);
525 SkScalar C = src[2] - src[0];
530 static SkScalar eval_cubic_2ndDerivative(const SkScalar src[], SkScalar t)
532 SkScalar A = src[6] + 3*(src[2] - src[4]) - src[0];
533 SkScalar B = src[4] - 2 * src[2] + src[0];
538 void SkEvalCubicAt(const SkPoint src[4], SkScalar t, SkPoint* loc, SkVector* tangent, SkVector* curvature)
540 SkASSERT(src);
544 loc->set(eval_cubic(&src[0].fX, t), eval_cubic(&src[0].fY, t));
546 tangent->set(eval_cubic_derivative(&src[0].fX, t),
547 eval_cubic_derivative(&src[0].fY, t));
549 curvature->set(eval_cubic_2ndDerivative(&src[0].fX, t),
550 eval_cubic_2ndDerivative(&src[0].fY, t));
574 static void interp_cubic_coords(const SkScalar* src, SkScalar* dst, SkScalar t)
576 SkScalar ab = SkScalarInterp(src[0], src[2], t);
577 SkScalar bc = SkScalarInterp(src[2], src[4], t);
578 SkScalar cd = SkScalarInterp(src[4], src[6], t);
583 dst[0] = src[0];
589 dst[12] = src[6];
592 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t)
596 interp_cubic_coords(&src[0].fX, &dst[0].fX, t);
597 interp_cubic_coords(&src[0].fY, &dst[0].fY, t);
611 SkPoint src[4] = {
619 SkChopCubicAt(src, dst, tval, 2);
623 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[], const SkScalar tValues[], int roots)
639 memcpy(dst, src, 4*sizeof(SkPoint));
647 SkChopCubicAt(src, dst, t);
652 // have src point to the remaining cubic (after the chop)
654 src = tmp;
660 dst[4] = dst[5] = dst[6] = src[3];
668 void SkChopCubicAtHalf(const SkPoint src[4], SkPoint dst[7])
670 SkScalar x01 = SkScalarAve(src[0].fX, src[1].fX);
671 SkScalar y01 = SkScalarAve(src[0].fY, src[1].fY);
672 SkScalar x12 = SkScalarAve(src[1].fX, src[2].fX);
673 SkScalar y12 = SkScalarAve(src[1].fY, src[2].fY);
674 SkScalar x23 = SkScalarAve(src[2].fX, src[3].fX);
675 SkScalar y23 = SkScalarAve(src[2].fY, src[3].fY);
682 dst[0] = src[0];
688 dst[6] = src[3];
704 int SkChopCubicAtYExtrema(const SkPoint src[4], SkPoint dst[10]) {
706 int roots = SkFindCubicExtrema(src[0].fY, src[1].fY, src[2].fY,
707 src[3].fY, tValues);
709 SkChopCubicAt(src, dst, tValues, roots);
720 int SkChopCubicAtXExtrema(const SkPoint src[4], SkPoint dst[10]) {
722 int roots = SkFindCubicExtrema(src[0].fX, src[1].fX, src[2].fX,
723 src[3].fX, tValues);
725 SkChopCubicAt(src, dst, tValues, roots);
747 int SkFindCubicInflections(const SkPoint src[4], SkScalar tValues[])
749 SkScalar Ax = src[1].fX - src[0].fX;
750 SkScalar Ay = src[1].fY - src[0].fY;
751 SkScalar Bx = src[2].fX - 2 * src[1].fX + src[0].fX;
752 SkScalar By = src[2].fY - 2 * src[1].fY + src[0].fY;
753 SkScalar Cx = src[3].fX + 3 * (src[1].fX - src[2].fX) - src[0].fX;
754 SkScalar Cy = src[3].fY + 3 * (src[1].fY - src[2].fY) - src[0].fY;
780 int SkChopCubicAtInflections(const SkPoint src[], SkPoint dst[10])
783 int count = SkFindCubicInflections(src, tValues);
788 memcpy(dst, src, 4 * sizeof(SkPoint));
790 SkChopCubicAt(src, dst, tValues, count);
936 static void formulate_F1DotF2(const SkScalar src[], SkFP coeff[4])
938 SkScalar a = src[2] - src[0];
939 SkScalar b = src[4] - 2 * src[2] + src[0];
940 SkScalar c = src[6] + 3 * (src[2] - src[4]) - src[0];
968 int SkFindCubicMaxCurvature(const SkPoint src[4], SkScalar tValues[3])
973 formulate_F1DotF2(&src[0].fX, coeffX);
974 formulate_F1DotF2(&src[0].fY, coeffY);
994 int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], SkScalar tValues[3])
1001 int count = SkFindCubicMaxCurvature(src, tValues);
1006 memcpy(dst, src, 4 * sizeof(SkPoint));
1008 SkChopCubicAt(src, dst, tValues, count);