git: 296cae89fb36 - main - graphics/dssim: fix build on big-endian

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Sun, 04 Aug 2024 12:01:16 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=296cae89fb3692e504c53cefe7a4c2886661b9d6

commit 296cae89fb3692e504c53cefe7a4c2886661b9d6
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2024-07-31 08:57:01 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2024-08-04 12:00:32 +0000

    graphics/dssim: fix build on big-endian
    
    Backport https://gitlab.com/kornelski/load_image/-/commit/e8f31164b97ba7b88ff881e8903ec13e5ddaec44
    
    error[E0599]: the method `to_image` exists for mutable reference `&mut [RGB<u8>]`, but its trait bounds were not satisfied
      --> /wrkdirs/usr/ports/graphics/dssim/work/dssim-3.2.4/cargo-crates/load_image-3.0.1/src/jpeg.rs:39:55
       |
    39 |             PixelFormat::RGB24 => pixels.as_rgb_mut().to_image(profile, width, height, true, meta),
       |                                                       ^^^^^^^^ method cannot be called on `&mut [RGB<u8>]` due to unsatisfied trait bounds
       |
      ::: /wrkdirs/usr/ports/graphics/dssim/work/dssim-3.2.4/cargo-crates/rgb-0.8.34/src/lib.rs:72:1
       |
    72 | pub struct RGB<ComponentType> {
       | ----------------------------- doesn't satisfy `rgb::RGB<u16>: pixel_format::LcmsPixelFormat`
       |
    note: trait bound `rgb::RGB<u16>: pixel_format::LcmsPixelFormat` was not satisfied
      --> /wrkdirs/usr/ports/graphics/dssim/work/dssim-3.2.4/cargo-crates/load_image-3.0.1/src/convert.rs:68:25
       |
    66 | impl<T> ToSRGBImage for [T]
       |         -----------     ---
    67 |     where T: LcmsPixelFormat + LcmsPixelConversion,
    68 |           T::Converted: LcmsPixelFormat + Default,
       |                         ^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here
    69 |           T::ConvertedOpaque: LcmsPixelFormat + Default,
       |                               ^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here
       = help: items from traits can only be used if the trait is implemented and in scope
    note: `convert::ToSRGBImage` defines an item `to_image`, perhaps you need to implement it
      --> /wrkdirs/usr/ports/graphics/dssim/work/dssim-3.2.4/cargo-crates/load_image-3.0.1/src/convert.rs:43:1
       |
    43 | pub trait ToSRGBImage {
       | ^^^^^^^^^^^^^^^^^^^^^
---
 ...o-crates_load__image-3.0.1_src_pixel__format.rs | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/graphics/dssim/files/patch-cargo-crates_load__image-3.0.1_src_pixel__format.rs b/graphics/dssim/files/patch-cargo-crates_load__image-3.0.1_src_pixel__format.rs
new file mode 100644
index 000000000000..24a9e9854993
--- /dev/null
+++ b/graphics/dssim/files/patch-cargo-crates_load__image-3.0.1_src_pixel__format.rs
@@ -0,0 +1,27 @@
+--- cargo-crates/load_image-3.0.1/src/pixel_format.rs.orig	2006-07-24 01:21:28 UTC
++++ cargo-crates/load_image-3.0.1/src/pixel_format.rs
+@@ -49,24 +49,16 @@ pixel_format!{GrayAlpha<u8>, PixelFormat::GRAYA_8, Col
+ pixel_format!{RGBA8, PixelFormat::RGBA_8, ColorSpaceSignature::RgbData }
+ pixel_format!{Gray<u8>, PixelFormat::GRAY_8, ColorSpaceSignature::GrayData }
+ pixel_format!{GrayAlpha<u8>, PixelFormat::GRAYA_8, ColorSpaceSignature::GrayData }
+-#[cfg(target_endian = "little")]
+ pixel_format!{RGB16, PixelFormat::RGB_16, ColorSpaceSignature::RgbData }
+-#[cfg(target_endian = "little")]
+ pixel_format!{RGBA16, PixelFormat::RGBA_16, ColorSpaceSignature::RgbData }
+-#[cfg(target_endian = "little")]
+ pixel_format!{Gray<u16>, PixelFormat::GRAY_16, ColorSpaceSignature::GrayData }
+-#[cfg(target_endian = "little")]
+ pixel_format!{GrayAlpha<u16>, PixelFormat::GRAYA_16, ColorSpaceSignature::GrayData }
+ 
+ pixel_conversion!{RGB8 => RGB16, RGB16}
+ pixel_conversion!{RGBA8 => RGBA16, RGB16}
+ pixel_conversion!{Gray<u8> => Gray<u16>, Gray<u16>}
+ pixel_conversion!{GrayAlpha<u8> => GrayAlpha<u16>, Gray<u16>}
+-#[cfg(target_endian = "little")]
+ pixel_conversion!{RGB16 => RGB16, RGB16}
+-#[cfg(target_endian = "little")]
+ pixel_conversion!{RGBA16 => RGBA16, RGB16}
+-#[cfg(target_endian = "little")]
+ pixel_conversion!{Gray<u16> => Gray<u16>, Gray<u16>}
+-#[cfg(target_endian = "little")]
+ pixel_conversion!{GrayAlpha<u16> => GrayAlpha<u16>, Gray<u16>}