blob: 4356b42414774c327751f33228072a6883476f9f [file] [log] [blame]
caryclark@google.com818b0cc2013-04-08 11:50:46 +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 */
7#include "PathOpsTestCommon.h"
8#include "SkPathOpsCubic.h"
9
caryclark@google.comd892bd82013-06-17 14:10:36 +000010void CubicToQuads(const SkDCubic& cubic, double precision, SkTArray<SkDQuad, true>& quads) {
11 SkTArray<double, true> ts;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000012 cubic.toQuadraticTs(precision, &ts);
caryclark@google.comcffbcc32013-06-04 17:59:42 +000013 if (ts.count() <= 0) {
caryclark@google.com818b0cc2013-04-08 11:50:46 +000014 SkDQuad quad = cubic.toQuad();
caryclark@google.comd892bd82013-06-17 14:10:36 +000015 quads.push_back(quad);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000016 return;
17 }
18 double tStart = 0;
19 for (int i1 = 0; i1 <= ts.count(); ++i1) {
20 const double tEnd = i1 < ts.count() ? ts[i1] : 1;
21 SkDCubic part = cubic.subDivide(tStart, tEnd);
22 SkDQuad quad = part.toQuad();
caryclark@google.comd892bd82013-06-17 14:10:36 +000023 quads.push_back(quad);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000024 tStart = tEnd;
25 }
26}