From a243d7cd8464d6d625bf752b13da0219c8662fd9 Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Tue, 20 Aug 2024 16:01:20 +0200 Subject: [PATCH] community/inkscape: rebuild with lib2geom 1.4 --- community/inkscape/APKBUILD | 8 +- community/inkscape/new-2geom.patch | 241 +++++++++++++++++++++++++++++ 2 files changed, 246 insertions(+), 3 deletions(-) create mode 100644 community/inkscape/new-2geom.patch diff --git a/community/inkscape/APKBUILD b/community/inkscape/APKBUILD index d3bdb33cb85..4ef7235327f 100644 --- a/community/inkscape/APKBUILD +++ b/community/inkscape/APKBUILD @@ -3,7 +3,7 @@ pkgname=inkscape pkgver=1.3.2 _pkgdate=2023-11-25 _pkgcommit=091e20ef0f -pkgrel=6 +pkgrel=7 pkgdesc="Vector-based drawing program - svg compliant" url="https://inkscape.org/" arch="all" @@ -59,8 +59,9 @@ subpackages=" $pkgname-icon-theme-multicolor:_icon_theme:noarch " source="https://media.inkscape.org/dl/resources/file/inkscape-$pkgver.tar.xz - include-missing-header-file.patch - " + include-missing-header-file.patch + new-2geom.patch + " options="!check" # take extremely long and use absurd amounts of memory ldpath="/usr/lib/inkscape" builddir="$srcdir"/$pkgname-${pkgver}_${_pkgdate}_$_pkgcommit @@ -144,4 +145,5 @@ libinkscape_base() { sha512sums=" a6da4b676ba3e7f954f95e3916ce78ce358b49c8052795a52d478064ef02eeae0337b0a94e89b9752ea6824a5758d28072c2bbf83f1e9ee28daebd3b0ef87343 inkscape-1.3.2.tar.xz da6add9d8127db36c0ec0d63c69234e944b14241b668cc5bb4c1f2ec2d4b1eaea42ac32c91748c5944238a8ba9e456e83e19fdeaba90a5d2862d54793dfff783 include-missing-header-file.patch +14380c8df30d92aa1528f510f042dbe772a82ee7982d0b7de92d1987a10b8e95aca8023e14f12e51e91832ba0fa74dbfc6af9ca91b887f3a9179db0ce00a955a new-2geom.patch " diff --git a/community/inkscape/new-2geom.patch b/community/inkscape/new-2geom.patch new file mode 100644 index 00000000000..4fc9a164529 --- /dev/null +++ b/community/inkscape/new-2geom.patch @@ -0,0 +1,241 @@ +From ab2650a48473cff0175c8efab2444857f9ecbb20 Mon Sep 17 00:00:00 2001 +From: PBS +Date: Thu, 20 Jul 2023 13:03:34 +0900 +Subject: [PATCH] Update 2geom and migrate code + +Fixes https://gitlab.com/inkscape/inkscape/-/issues/4445 +Fixes https://gitlab.com/inkscape/inkscape/-/issues/4341 + +Also 'fixes' these pseudo non-bugs + +Fixes https://gitlab.com/inkscape/lib2geom/-/issues/65 +Fixes https://gitlab.com/inkscape/inbox/-/issues/8912 +--- + src/3rdparty/2geom | 2 +- + src/display/control/canvas-item.h | 6 --- + src/helper/geom.cpp | 61 --------------------- + src/helper/geom.h | 1 - + src/live_effects/lpe-tiling.cpp | 2 +- + src/trace/potrace/inkscape-potrace.cpp | 4 +- + src/trace/potrace/inkscape-potrace.h | 14 +---- + src/ui/widget/canvas.cpp | 1 - + src/ui/widget/canvas/stores.cpp | 9 ++-- + testfiles/CMakeLists.txt | 1 - + testfiles/src/min-bbox-test.cpp | 73 -------------------------- + 11 files changed, 10 insertions(+), 164 deletions(-) + delete mode 100644 testfiles/src/min-bbox-test.cpp + +diff --git a/src/display/control/canvas-item.h b/src/display/control/canvas-item.h +index 3a5387d9e91..205234ff787 100644 +--- a/src/display/control/canvas-item.h ++++ b/src/display/control/canvas-item.h +@@ -148,12 +148,6 @@ protected: + + } // namespace Inkscape + +-// Todo: Move to lib2geom. +-inline auto &operator<<(std::ostream &s, Geom::OptRect const &rect) +-{ +- return rect ? (s << *rect) : (s << "(empty)"); +-} +- + #endif // SEEN_CANVAS_ITEM_H + + /* +diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp +index 30111cb8d9d..6a282a18433 100644 +--- a/src/helper/geom.cpp ++++ b/src/helper/geom.cpp +@@ -1010,67 +1010,6 @@ bool approx_dihedral(Geom::Affine const &affine, double eps) + return arr == std::array {1, 0, 0, 1 } || arr == std::array{ 0, 1, 1, 0 }; + } + +-/** +- * Computes the rotation which puts a set of points in a position where they can be wrapped in the +- * smallest possible axis-aligned rectangle, and returns it along with the rectangle. +- */ +-std::pair min_bounding_box(std::vector const &pts) +-{ +- // Compute the convex hull. +- auto const hull = Geom::ConvexHull(pts); +- +- // Move the point i along until it maximises distance in the direction n. +- auto advance = [&] (int &i, Geom::Point const &n) { +- auto ih = Geom::dot(hull[i], n); +- while (true) { +- int j = (i + 1) % hull.size(); +- auto jh = Geom::dot(hull[j], n); +- if (ih >= jh) break; +- i = j; +- ih = jh; +- } +- }; +- +- double mina = std::numeric_limits::max(); +- std::pair result; +- +- // Run rotating callipers. +- int j, k, l; +- for (int i = 0; i < hull.size(); i++) { +- // Get the current segment. +- auto &p1 = hull[i]; +- auto &p2 = hull[(i + 1) % hull.size()]; +- auto v = (p2 - p1).normalized(); +- auto n = Geom::Point(-v.y(), v.x()); +- +- if (i == 0) { +- // Initialise the points. +- j = 0; advance(j, v); +- k = j; advance(k, n); +- l = k; advance(l, -v); +- } else { +- // Advance the points. +- advance(j, v); +- advance(k, n); +- advance(l, -v); +- } +- +- // Compute the dimensions of the unconstrained rectangle. +- auto w = Geom::dot(hull[j] - hull[l], v); +- auto h = Geom::dot(hull[k] - hull[i], n); +- auto a = w * h; +- +- // Track the minimum. +- if (a < mina) { +- mina = a; +- result = std::make_pair(Geom::Affine(v.x(), -v.y(), v.y(), v.x(), 0.0, 0.0), +- Geom::Rect::from_xywh(Geom::dot(hull[l], v), Geom::dot(hull[i], n), w, h)); +- } +- } +- +- return result; +-} +- + /* + Local Variables: + mode:c++ +diff --git a/src/helper/geom.h b/src/helper/geom.h +index 50e434da780..59542e7d44f 100644 +--- a/src/helper/geom.h ++++ b/src/helper/geom.h +@@ -45,7 +45,6 @@ void recursive_bezier4(const double x1, const double y1, const double x2, const + std::vector &pointlist, + int level); + bool approx_dihedral(Geom::Affine const &affine, double eps = 0.0001); +-std::pair min_bounding_box(std::vector const &pts); + + /// Returns signed area of triangle given by points; may be negative. + inline Geom::Coord triangle_area(Geom::Point const &p1, Geom::Point const &p2, Geom::Point const &p3) +diff --git a/src/live_effects/lpe-tiling.cpp b/src/live_effects/lpe-tiling.cpp +index b4913c79b2d..5bd88801475 100644 +--- a/src/live_effects/lpe-tiling.cpp ++++ b/src/live_effects/lpe-tiling.cpp +@@ -442,7 +442,7 @@ LPETiling::doAfterEffect (SPLPEItem const* lpeitem, SPCurve *curve) + auto p = Geom::Point(xset + offset_x - random_x[counter], yset + offset_y - random_y[counter]); + auto translate = p * gap.inverse(); + Geom::Affine finalit = (transformoriginal * Geom::Translate(spcenter_base).inverse() * mirror * Geom::Translate(spcenter_base)); +- finalit *= gapp.inverse() * Geom::Translate(spcenter).inverse() * originatrans.withoutTranslation().inverse() * r * translate * Geom::Translate(spcenter) ; ++ finalit *= gapp.inverse() * Geom::Translate(spcenter).inverse() * originatrans.withoutTranslation().inverse() * r * Geom::Translate(translate) * Geom::Translate(spcenter); + item->doWriteTransform(finalit); + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + forcewrite = forcewrite || write; +diff --git a/src/trace/potrace/inkscape-potrace.cpp b/src/trace/potrace/inkscape-potrace.cpp +index a6c7f65f92a..e51a5afb104 100644 +--- a/src/trace/potrace/inkscape-potrace.cpp ++++ b/src/trace/potrace/inkscape-potrace.cpp +@@ -93,7 +93,7 @@ void PotraceTracingEngine::setTurdSize(int turdsize) + * Recursively descend the potrace_path_t node tree \a paths, writing paths to \a builder. + * The \a points set is used to prevent redundant paths. + */ +-void PotraceTracingEngine::writePaths(potrace_path_t *paths, Geom::PathBuilder &builder, std::unordered_set &points, Async::Progress &progress) const ++void PotraceTracingEngine::writePaths(potrace_path_t *paths, Geom::PathBuilder &builder, std::unordered_set &points, Async::Progress &progress) const + { + auto to_geom = [] (potrace_dpoint_t const &c) { + return Geom::Point(c.x, c.y); +@@ -280,7 +280,7 @@ Geom::PathVector PotraceTracingEngine::grayMapToPath(GrayMap const &grayMap, Asy + + // Extract the paths into a pathvector and return it. + Geom::PathBuilder builder; +- std::unordered_set points; ++ std::unordered_set points; + writePaths(potraceState->plist, builder, points, progress); + return builder.peek(); + } +diff --git a/src/trace/potrace/inkscape-potrace.h b/src/trace/potrace/inkscape-potrace.h +index 0e4a9c62eeb..f30568369b2 100644 +--- a/src/trace/potrace/inkscape-potrace.h ++++ b/src/trace/potrace/inkscape-potrace.h +@@ -45,18 +45,6 @@ enum class TraceType + AUTOTRACE_CENTERLINE + }; + +-// Todo: Make lib2geom types hashable. +-struct geom_point_hash +-{ +- std::size_t operator()(Geom::Point const &pt) const +- { +- std::size_t hash = 0; +- boost::hash_combine(hash, pt.x()); +- boost::hash_combine(hash, pt.y()); +- return hash; +- } +-}; +- + class PotraceTracingEngine final + : public TracingEngine + { +@@ -119,7 +107,7 @@ private: + + Geom::PathVector grayMapToPath(GrayMap const &gm, Async::Progress &progress); + +- void writePaths(potrace_path_t *paths, Geom::PathBuilder &builder, std::unordered_set &points, Async::Progress &progress) const; ++ void writePaths(potrace_path_t *paths, Geom::PathBuilder &builder, std::unordered_set &points, Async::Progress &progress) const; + }; + + } // namespace Potrace +diff --git a/src/ui/widget/canvas.cpp b/src/ui/widget/canvas.cpp +index 7274d0a30f5..86fb95a54c7 100644 +--- a/src/ui/widget/canvas.cpp ++++ b/src/ui/widget/canvas.cpp +@@ -18,7 +18,6 @@ + #include + #include + #include +-#include <2geom/convex-hull.h> + + #include "canvas.h" + +diff --git a/src/ui/widget/canvas/stores.cpp b/src/ui/widget/canvas/stores.cpp +index 70327f5a48b..e51598de456 100644 +--- a/src/ui/widget/canvas/stores.cpp ++++ b/src/ui/widget/canvas/stores.cpp +@@ -4,6 +4,7 @@ + #include <2geom/transforms.h> + #include <2geom/parallelogram.h> + #include <2geom/point.h> ++#include <2geom/convex-hull.h> + #include "helper/geom.h" + #include "ui/util.h" + #include "stores.h" +@@ -61,8 +62,7 @@ auto region_affine_approxinwards(Cairo::RefPtr const ®, Geom:: + double fx = min(absolute(Geom::Point(1.0, 0.0) * affine.withoutTranslation())); + double fy = min(absolute(Geom::Point(0.0, 1.0) * affine.withoutTranslation())); + +- for (int i = 0; i < regsrc->get_num_rectangles(); i++) +- { ++ for (int i = 0; i < regsrc->get_num_rectangles(); i++) { + auto rect = cairo_to_geom(regsrc->get_rectangle(i)); + int nx = std::ceil(rect.width() * fx / d); + int ny = std::ceil(rect.height() * fy / d); +@@ -147,8 +147,9 @@ void Stores::snapshot_combine(Fragment const &view) + add_rect(Geom::Parallelogram(_snapshot.rect) * _snapshot.affine.inverse() * view.affine); + + // Compute their minimum-area bounding box as a fragment - an (affine, rect) pair. +- auto [affine, rect] = min_bounding_box(pts); +- affine = view.affine * affine; ++ auto const [rot, optrect] = Geom::ConvexHull(pts).minAreaRotation(); ++ auto rect = *optrect; // non-empty since pts is non-empty ++ auto affine = view.affine * rot; + + // Check if the paste transform takes the snapshot store exactly onto the new fragment, possibly with a dihedral transformation. + auto paste = Geom::Scale(_snapshot.rect.dimensions())