aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsTestCommon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/PathOpsTestCommon.cpp')
-rw-r--r--tests/PathOpsTestCommon.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/PathOpsTestCommon.cpp b/tests/PathOpsTestCommon.cpp
new file mode 100644
index 0000000000..cbea715b66
--- /dev/null
+++ b/tests/PathOpsTestCommon.cpp
@@ -0,0 +1,27 @@
+/*
+ * 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() <= 1) {
+ 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;
+ }
+}
+