2013-04-08 11:50:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
#include "PathOpsTestCommon.h"
|
|
|
|
#include "SkPathOpsCubic.h"
|
|
|
|
|
2013-06-17 14:10:36 +00:00
|
|
|
void CubicToQuads(const SkDCubic& cubic, double precision, SkTArray<SkDQuad, true>& quads) {
|
|
|
|
SkTArray<double, true> ts;
|
2013-04-08 11:50:46 +00:00
|
|
|
cubic.toQuadraticTs(precision, &ts);
|
2013-06-04 17:59:42 +00:00
|
|
|
if (ts.count() <= 0) {
|
2013-04-08 11:50:46 +00:00
|
|
|
SkDQuad quad = cubic.toQuad();
|
2013-06-17 14:10:36 +00:00
|
|
|
quads.push_back(quad);
|
2013-04-08 11:50:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
double tStart = 0;
|
|
|
|
for (int i1 = 0; i1 <= ts.count(); ++i1) {
|
|
|
|
const double tEnd = i1 < ts.count() ? ts[i1] : 1;
|
|
|
|
SkDCubic part = cubic.subDivide(tStart, tEnd);
|
|
|
|
SkDQuad quad = part.toQuad();
|
2013-06-17 14:10:36 +00:00
|
|
|
quads.push_back(quad);
|
2013-04-08 11:50:46 +00:00
|
|
|
tStart = tEnd;
|
|
|
|
}
|
|
|
|
}
|