reduce pathops templated code
Pathops uses a template to intersect a pair of curves.
This generates six copies: quad/quad, quad/conic, quad/cubic,
conic/conic, conic/cubic, cubic/cubic.
This CL rewrites the template to generate a single copy,
and leverages a new abstract class, SkTCurve, to dispatch
to one of SkTQuad, SkTConic, or SkTCubic. These classes
are thin wrappers on the existing double curves classes
SkDQuad, SkDConic, and SkDCubic, which do work.
Kevin's BuildStats bot says this saves around 180K on the
release build. Running pathops_unittest shows no significant
performance difference, and the smaller version may be
slightly faster.
Bug: skia:
Change-Id: I17f94fd57a317035bc105cd43a06be6da9541cb6
Reviewed-on: https://skia-review.googlesource.com/c/161146
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Cary Clark <caryclark@skia.org>
diff --git a/src/pathops/SkPathOpsTCurve.h b/src/pathops/SkPathOpsTCurve.h
new file mode 100644
index 0000000..4981dea
--- /dev/null
+++ b/src/pathops/SkPathOpsTCurve.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPathOpsTCurve_DEFINED
+#define SkPathOpsTCurve_DEFINED
+
+#include "SkPathOpsPoint.h"
+
+class SkArenaAlloc;
+class SkIntersections;
+
+class SkTCurve {
+public:
+ virtual ~SkTCurve() {}
+ virtual const SkDPoint& operator[](int n) const = 0;
+ virtual SkDPoint& operator[](int n) = 0;
+
+ virtual bool collapsed() const = 0;
+ virtual bool controlsInside() const = 0;
+ virtual void debugInit() = 0;
+ virtual SkDVector dxdyAtT(double t) const = 0;
+ virtual bool hullIntersects(const SkDQuad& , bool* isLinear) const = 0;
+ virtual bool hullIntersects(const SkDConic& , bool* isLinear) const = 0;
+ virtual bool hullIntersects(const SkDCubic& , bool* isLinear) const = 0;
+ virtual bool hullIntersects(const SkTCurve& , bool* isLinear) const = 0;
+ virtual int intersectRay(SkIntersections* i, const SkDLine& line) const = 0;
+ virtual bool IsConic() const = 0;
+ virtual SkTCurve* make(SkArenaAlloc& ) const = 0;
+ virtual int maxIntersections() const = 0;
+ virtual void otherPts(int oddMan, const SkDPoint* endPt[2]) const = 0;
+ virtual int pointCount() const = 0;
+ virtual int pointLast() const = 0;
+ virtual SkDPoint ptAtT(double t) const = 0;
+ virtual void setBounds(SkDRect* ) const = 0;
+ virtual void subDivide(double t1, double t2, SkTCurve* curve) const = 0;
+#ifdef SK_DEBUG
+ virtual SkOpGlobalState* globalState() const = 0;
+#endif
+};
+
+#endif