From: Johan E. <jbc...@sw...> - 2013-11-12 00:18:28
|
Hi all, Currently, when translating a path (adding a point), 2geom treats it as any other affine transform. This is quite a performance hit. (refresher: Path is a collection of Curves. A Curve is a virtual base for many curve types. Because many curve types are not closed under affine transforms (the result after an affine transform can not always be represented as its original Curve type, e.g. HLineSegment after rotation), when transforming a Curve, a new Curve is created that holds the transform. When transforming a path, each Curve is transformed, and thus a bunch of new Curves are created. ) As far as I can see now, all (current) Curve types *are* closed under translations. I think we should enforce this for Curve. I.e., each Curve must implement virtual Curve &operator+=(Point const &); I tested the performance increase for special-casing Translate transforms, by adding Path &operator*=(Translate const &m) { *this += m.vector(); return *this; }; Path &operator+=(Point const &m); next to the current Path &operator*=(Affine const &m); Of course, more changes were needed, and so far I have only implemented addition for BezierCurveN, just to see the performance increase. After the change, the path-operations test runs more than twice as fast. Do you have any concerns about enforcing an operator+= implementation for Curves ? Interestingly, *all* member functions of Curve are const. operator+= would be the first state-changing member function. :) Cheers, Johan |