skia2/tests/PathOpsTestCommon.cpp
caryclark@google.com d892bd8ba6 convert pathops to use SkSTArray where possible.
Replace SkTDArray with SkTArray and use SkSTArray when
the probable array size is known.

In a couple of places (spans, chases) the arrays are
constructed using insert() so SkTArrays can't be used for
now.

Also, add an optimization to cubic subdivide if either end
is zero or one.

BUG=

Review URL: https://codereview.chromium.org/16951017

git-svn-id: http://skia.googlecode.com/svn/trunk@9635 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-06-17 14:10:36 +00:00

27 lines
771 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, SkTArray<SkDQuad, true>& quads) {
SkTArray<double, true> ts;
cubic.toQuadraticTs(precision, &ts);
if (ts.count() <= 0) {
SkDQuad quad = cubic.toQuad();
quads.push_back(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.push_back(quad);
tStart = tEnd;
}
}