blob: 186ed43b6af8bdbefcfe1486f01d5b13714d3601 [file] [log] [blame]
caryclark@google.com9e49fb62012-08-27 14:11:33 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
caryclark@google.com235f56a2012-09-14 14:19:30 +00007#if !defined CUBIC_UTILITIES_H
8#define CUBIC_UTILITIES_H
9
caryclark@google.com8dcf1142012-07-02 20:27:02 +000010#include "DataTypes.h"
caryclark@google.com6d0032a2013-01-04 19:41:13 +000011#include "SkTDArray.h"
caryclark@google.com8dcf1142012-07-02 20:27:02 +000012
caryclark@google.com73ca6242013-01-17 21:02:47 +000013double calcPrecision(const Cubic& cubic);
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000014#if SK_DEBUG
15double calcPrecision(const Cubic& cubic, double t, double scale);
16#endif
17void chop_at(const Cubic& src, CubicPair& dst, double t);
caryclark@google.com9f602912013-01-24 21:47:16 +000018// FIXME: should be private static but public here for testing
19void computeDelta(const Cubic& c1, double t1, double scale1, const Cubic& c2, double t2,
20 double scale2, double& delta1, double& delta2);
caryclark@google.com27accef2012-01-25 18:57:23 +000021double cube_root(double x);
caryclark@google.comd68bc302013-01-07 13:17:18 +000022int cubic_to_quadratics(const Cubic& cubic, double precision,
23 SkTDArray<Quadratic>& quadratics);
caryclark@google.com73ca6242013-01-17 21:02:47 +000024void cubic_to_quadratics(const Cubic& cubic, double precision, SkTDArray<double>& ts);
caryclark@google.comc6825902012-02-03 22:07:47 +000025void coefficients(const double* cubic, double& A, double& B, double& C, double& D);
caryclark@google.com9f602912013-01-24 21:47:16 +000026int cubicRootsValidT(double A, double B, double C, double D, double t[3]);
27int cubicRootsReal(double A, double B, double C, double D, double s[3]);
caryclark@google.com73ca6242013-01-17 21:02:47 +000028void demote_cubic_to_quad(const Cubic& cubic, Quadratic& quad);
caryclark@google.com05c4bad2013-01-19 13:22:39 +000029double dx_at_t(const Cubic& , double t);
30double dy_at_t(const Cubic& , double t);
31void dxdy_at_t(const Cubic& , double t, _Point& y);
caryclark@google.com73ca6242013-01-17 21:02:47 +000032int find_cubic_inflections(const Cubic& src, double tValues[]);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000033bool rotate(const Cubic& cubic, int zero, int index, Cubic& rotPath);
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000034void sub_divide(const Cubic& src, double t1, double t2, Cubic& dst);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000035void xy_at_t(const Cubic& , double t, double& x, double& y);
caryclark@google.com235f56a2012-09-14 14:19:30 +000036
caryclark@google.com05c4bad2013-01-19 13:22:39 +000037extern const int precisionUnit;
caryclark@google.com235f56a2012-09-14 14:19:30 +000038#endif