From 96cf239e7af4e958f0c16574ff1550a9763bcd3a Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Aug 11 2020 22:32:43 +0000 Subject: Initial commit (#1867423). --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f7b0708 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/ragg_0.3.1.tar.gz diff --git a/0001-Byte-swap-agg_capture-output-on-big-endian-systems.patch b/0001-Byte-swap-agg_capture-output-on-big-endian-systems.patch new file mode 100644 index 0000000..a37999c --- /dev/null +++ b/0001-Byte-swap-agg_capture-output-on-big-endian-systems.patch @@ -0,0 +1,48 @@ +From 3fe3b45dd22b97525caa22678f8927d0ddf352ca Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Tue, 4 Aug 2020 05:54:38 -0400 +Subject: [PATCH 1/2] Byte swap `agg_capture` output on big-endian systems. + +R expects colours to be integers of ABGR, which on little-endian +machines maps to singular bytes in RGBA order, but maps to ABGR order on +bit-endian machines. + +Signed-off-by: Elliott Sales de Andrade +--- + src/AggDeviceCapture.h | 4 +++- + src/ragg.h | 2 ++ + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/AggDeviceCapture.h b/src/AggDeviceCapture.h +index 02f76a4..86f7cc4 100644 +--- a/src/AggDeviceCapture.h ++++ b/src/AggDeviceCapture.h +@@ -21,7 +21,9 @@ public: + } + SEXP capture() { + SEXP raster = PROTECT(Rf_allocVector(INTSXP, this->width * this->height)); +- memcpy(INTEGER(raster), this->buffer, this->width * this->height * 4); ++ agg::rendering_buffer caprbuf(reinterpret_cast(INTEGER(raster)), ++ this->width, this->height, this->width * 4); ++ agg::convert(&caprbuf, &this->rbuf); + SEXP dims = PROTECT(Rf_allocVector(INTSXP, 2)); + INTEGER(dims)[0] = this->height; + INTEGER(dims)[1] = this->width; +diff --git a/src/ragg.h b/src/ragg.h +index 7a66d8b..0fca0a5 100644 +--- a/src/ragg.h ++++ b/src/ragg.h +@@ -36,8 +36,10 @@ typedef agg::pixfmt_rgba64_pre pixfmt_type_64; + + #ifdef __BIG_ENDIAN__ + typedef agg::pixfmt_abgr32_plain pixfmt_r_raster; ++typedef agg::pixfmt_abgr32_pre pixfmt_r_capture; + #else + typedef agg::pixfmt_rgba32_plain pixfmt_r_raster; ++typedef agg::pixfmt_rgba32_pre pixfmt_r_capture; + #endif + + // pixfmt agnosting demultiplying +-- +2.25.4 + diff --git a/0002-Use-WORDS_BIGENDIAN-from-Rconfig.h.patch b/0002-Use-WORDS_BIGENDIAN-from-Rconfig.h.patch new file mode 100644 index 0000000..cfd3e08 --- /dev/null +++ b/0002-Use-WORDS_BIGENDIAN-from-Rconfig.h.patch @@ -0,0 +1,30 @@ +From fb0633028f569dd91ab949794c0a3af0ef0686ca Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Wed, 5 Aug 2020 05:43:22 -0400 +Subject: [PATCH 2/2] Use WORDS_BIGENDIAN from Rconfig.h. + +This seems to actually work, as __BIG_ENDIAN__ isn't defined on s390x. +Possibly it needs another header, but it's easier to use a macro already +in R. + +Signed-off-by: Elliott Sales de Andrade +--- + src/ragg.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/ragg.h b/src/ragg.h +index 0fca0a5..cd08ebb 100644 +--- a/src/ragg.h ++++ b/src/ragg.h +@@ -34,7 +34,7 @@ typedef agg::pixfmt_rgba32_pre pixfmt_type_32; + typedef agg::pixfmt_rgb48_pre pixfmt_type_48; + typedef agg::pixfmt_rgba64_pre pixfmt_type_64; + +-#ifdef __BIG_ENDIAN__ ++#ifdef WORDS_BIGENDIAN + typedef agg::pixfmt_abgr32_plain pixfmt_r_raster; + typedef agg::pixfmt_abgr32_pre pixfmt_r_capture; + #else +-- +2.25.4 + diff --git a/R-ragg.spec b/R-ragg.spec new file mode 100644 index 0000000..b26033b --- /dev/null +++ b/R-ragg.spec @@ -0,0 +1,87 @@ +%global packname ragg +%global packver 0.3.1 +%global rlibdir %{_libdir}/R/library + +Name: R-%{packname} +Version: 0.3.1 +Release: 1%{?dist} +Summary: Graphic Devices Based on AGG + +License: MIT +URL: https://CRAN.R-project.org/package=%{packname} +Source0: https://cran.r-project.org/src/contrib/%{packname}_%{packver}.tar.gz +# https://github.com/r-lib/ragg/pull/49 +Patch0001: 0001-Byte-swap-agg_capture-output-on-big-endian-systems.patch +Patch0002: 0002-Use-WORDS_BIGENDIAN-from-Rconfig.h.patch + +# Here's the R view of the dependencies world: +# Depends: +# Imports: R-systemfonts >= 0.2.1 +# Suggests: R-covr, R-testthat, R-grid, R-graphics +# LinkingTo: +# Enhances: + +BuildRequires: R-devel +BuildRequires: tex(latex) +BuildRequires: R-systemfonts-devel >= 0.2.1 +BuildRequires: R-testthat +BuildRequires: R-grid +BuildRequires: R-graphics + +BuildRequires: gcc-c++ +BuildRequires: pkgconfig(freetype2) +BuildRequires: pkgconfig(libpng) +BuildRequires: pkgconfig(libtiff-4) +BuildRequires: libjpeg-devel + +%description +Anti-Grain Geometry (AGG) is a high-quality and high-performance 2D drawing +library. The 'ragg' package provides a set of graphic devices based on AGG to +use as alternative to the raster devices provided through the 'grDevices' +package. + + +%prep +%setup -q -c -n %{packname} + +pushd %{packname} +%patch0001 -p1 +%patch0002 -p1 + +# Don't need coverage; it's not packaged either. +sed -i 's/covr, //g' DESCRIPTION +popd + + +%build + + +%install +mkdir -p %{buildroot}%{rlibdir} +%{_bindir}/R CMD INSTALL -l %{buildroot}%{rlibdir} %{packname} +test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so) +rm -f %{buildroot}%{rlibdir}/R.css + + +%check +%{_bindir}/R CMD check %{packname} || (cat %{packname}.Rcheck/tests/testthat.Rout.fail && exit 1) + + +%files +%dir %{rlibdir}/%{packname} +%doc %{rlibdir}/%{packname}/html +%{rlibdir}/%{packname}/DESCRIPTION +%doc %{rlibdir}/%{packname}/NEWS.md +%license %{rlibdir}/%{packname}/LICENSE +%{rlibdir}/%{packname}/INDEX +%{rlibdir}/%{packname}/NAMESPACE +%{rlibdir}/%{packname}/Meta +%{rlibdir}/%{packname}/R +%{rlibdir}/%{packname}/help +%dir %{rlibdir}/%{packname}/libs +%{rlibdir}/%{packname}/libs/%{packname}.so + + +%changelog +* Mon Aug 03 2020 Elliott Sales de Andrade - 0.3.1-1 +- initial package for Fedora diff --git a/sources b/sources new file mode 100644 index 0000000..b5e6eed --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (ragg_0.3.1.tar.gz) = c7aef1147739069a5d72458011d0ec1ed469117616c47d305089661deed5c39650f18b86b9a91574f45ea1b087f1e211dd214b7f3174e5c7589a8707f8df13e3