cffbcc3b96
This is a major change resulting from a minor tweak. In the old code, the intersection point of two curves was shared between them, but the intersection points and end points of sorted edges was computed directly from the intersection T value. In this CL, both intersection points and sorted points are the same, and intermediate control points are computed to preserve their slope. The sort itself has been completely rewritten to be more robust and remove 'magic' checks, conditions that empirically worked but couldn't be rationalized. This CL was triggered by errors generated computing the clips of SKP files. At this point, all 73M standard tests work and at least the first troublesome SKPs work. Review URL: https://codereview.chromium.org/15338003 git-svn-id: http://skia.googlecode.com/svn/trunk@9432 2bbb7eff-a529-9590-31e7-b0007b416f81
27 lines
763 B
C++
27 lines
763 B
C++
/*
|
|
* 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"
|
|
|
|
void CubicToQuads(const SkDCubic& cubic, double precision, SkTDArray<SkDQuad>& quads) {
|
|
SkTDArray<double> ts;
|
|
cubic.toQuadraticTs(precision, &ts);
|
|
if (ts.count() <= 0) {
|
|
SkDQuad quad = cubic.toQuad();
|
|
*quads.append() = quad;
|
|
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();
|
|
*quads.append() = quad;
|
|
tStart = tEnd;
|
|
}
|
|
}
|