decoder: Use glycin 1.0

This commit is contained in:
Sophie Herold 2023-12-25 21:34:18 +01:00
parent 0e490f38ad
commit f14cb540eb
9 changed files with 124 additions and 99 deletions

98
Cargo.lock generated
View file

@ -122,6 +122,17 @@ dependencies = [
"futures-lite 1.13.0",
]
[[package]]
name = "async-fs"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd1f344136bad34df1f83a47f3fd7f2ab85d75cb8a940af4ccf6d482a84ea01b"
dependencies = [
"async-lock 3.2.0",
"blocking",
"futures-lite 2.1.0",
]
[[package]]
name = "async-global-executor"
version = "2.4.1"
@ -213,6 +224,24 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "async-process"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15c1cd5d253ecac3d3cf15e390fd96bd92a13b1d14497d81abf077304794fb04"
dependencies = [
"async-channel 2.1.1",
"async-io 2.2.2",
"async-lock 3.2.0",
"async-signal",
"blocking",
"cfg-if",
"event-listener 4.0.1",
"futures-lite 2.1.0",
"rustix 0.38.28",
"windows-sys 0.52.0",
]
[[package]]
name = "async-recursion"
version = "1.0.5"
@ -252,7 +281,6 @@ dependencies = [
"async-global-executor",
"async-io 1.13.0",
"async-lock 2.8.0",
"async-process",
"crossbeam-utils",
"futures-channel",
"futures-core",
@ -657,21 +685,6 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "futures"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.30"
@ -679,7 +692,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
@ -762,7 +774,6 @@ version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-macro",
@ -1021,13 +1032,16 @@ dependencies = [
[[package]]
name = "glycin"
version = "0.1.0"
version = "1.0.0-alpha"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad6c03181c84fdbe028957f3e90747686038b2f0f85ea2a2bf68bef287a6cb8a"
checksum = "c9b4551bd5e514034e097a219e5d24569d881bd89a2298e00c6dc1372ab4b332"
dependencies = [
"anyhow",
"async-std",
"futures",
"async-fs 2.1.0",
"async-global-executor",
"async-process 2.0.1",
"futures-channel",
"futures-util",
"gdk4",
"gio",
"glycin-utils",
@ -1035,23 +1049,20 @@ dependencies = [
"lcms2-sys",
"memfd",
"memmap2",
"nix",
"nix 0.27.1",
"rgb",
"safe-transmute",
"zbus",
]
[[package]]
name = "glycin-utils"
version = "0.1.0"
version = "1.0.0-alpha"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ecc581b89258e8cd90d8aa90a2864ce634270d6f9d2b0c28a050b491a66c874"
checksum = "c141d45a216382d88ebb29620abd688d159200d95428779e3cacd4721a139b8b"
dependencies = [
"anyhow",
"async-std",
"gettext-rs",
"memmap2",
"nix",
"rustix 0.37.27",
"serde",
"zbus",
]
@ -1348,10 +1359,11 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lcms2"
version = "5.6.0"
version = "6.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9d50a4d00d909da0ec023ab34ea09bf3b3b79b5a36b3e0da3a305112edaf150"
checksum = "745453cbf12c57cce42c1d1db6075d481ca1956fa9bf661f770018656d55e1bd"
dependencies = [
"bytemuck",
"foreign-types",
"lcms2-sys",
]
@ -1513,9 +1525,9 @@ dependencies = [
[[package]]
name = "memmap2"
version = "0.7.1"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6"
checksum = "45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92"
dependencies = [
"libc",
]
@ -1563,7 +1575,17 @@ dependencies = [
"cfg-if",
"libc",
"memoffset 0.7.1",
"pin-utils",
]
[[package]]
name = "nix"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
"bitflags 2.4.1",
"cfg-if",
"libc",
]
[[package]]
@ -2575,7 +2597,7 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd"
dependencies = [
"nix",
"nix 0.26.4",
"winapi",
]
@ -2587,10 +2609,10 @@ checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948"
dependencies = [
"async-broadcast",
"async-executor",
"async-fs",
"async-fs 1.6.0",
"async-io 1.13.0",
"async-lock 2.8.0",
"async-process",
"async-process 1.8.1",
"async-recursion",
"async-task",
"async-trait",
@ -2603,7 +2625,7 @@ dependencies = [
"futures-sink",
"futures-util",
"hex",
"nix",
"nix 0.26.4",
"once_cell",
"ordered-stream",
"rand",

View file

@ -19,7 +19,7 @@ async-channel = "2.1.0"
env_logger = "0.10.0"
futures-channel = "0.3.25"
futures-lite = "2.1.0"
glycin = "0.1.0"
glycin = "1.0.0-alpha"
gvdb-macros = "0.1.6"
indexmap = "2.0.0"
kamadak-exif = "0.5.5"

View file

@ -1,14 +1,14 @@
{
"id" : "org.gnome.Loupe.Devel",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
"sdk-extensions" : [
"id": "org.gnome.Loupe.Devel",
"runtime": "org.gnome.Platform",
"runtime-version": "master",
"sdk": "org.gnome.Sdk",
"sdk-extensions": [
"org.freedesktop.Sdk.Extension.rust-stable",
"org.freedesktop.Sdk.Extension.llvm16"
],
"command" : "loupe",
"finish-args" : [
"command": "loupe",
"finish-args": [
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
@ -20,20 +20,20 @@
"--filesystem=xdg-run/gvfs",
"--filesystem=xdg-run/gvfsd"
],
"build-options" : {
"append-path" : "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm16/bin",
"build-args" : [
"build-options": {
"append-path": "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm16/bin",
"build-args": [
"--share=network"
],
"env" : {
"RUSTFLAGS" : "-C force-frame-pointers=yes",
"CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER" : "clang",
"CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER" : "clang",
"CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS" : "-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold",
"CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS" : "-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold"
"env": {
"RUSTFLAGS": "-C force-frame-pointers=yes",
"CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER": "clang",
"CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER": "clang",
"CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS": "-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold",
"CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS": "-C link-arg=-fuse-ld=/usr/lib/sdk/rust-stable/bin/mold"
}
},
"cleanup" : [
"cleanup": [
"/include",
"/lib/pkgconfig",
"/man",
@ -46,18 +46,18 @@
],
"add-extensions": {
/* Exile HEIC (x265) codec into extension */
"org.gnome.Loupe.Devel.HEIC" : {
"org.gnome.Loupe.Devel.HEIC": {
/* Relative to app dir */
"directory" : "lib/libheif-heic",
"directory": "lib/libheif-heic",
/* Relative to directory above */
"add-ld-path" : "lib",
"add-ld-path": "lib",
/* Remove extension data from main flatpak package */
"bundle" : true,
"bundle": true,
/* Remove this extension when Loupe is deinstalled */
"autodelete" : true
"autodelete": true
}
},
"modules" : [
"modules": [
{
"name": "geocode-glib",
"buildsystem": "meson",
@ -105,24 +105,24 @@
},
{
/* HEIC (x265) decoder */
"name" : "libde265",
"buildsystem" : "cmake",
"name": "libde265",
"buildsystem": "cmake",
"config-opts": [
/* Install into folder for extension */
"-DCMAKE_INSTALL_PREFIX=/app/lib/libheif-heic",
"-DENABLE_SDL=Off"
],
"sources" : [
"sources": [
{
"type" : "git",
"url" : "https://github.com/strukturag/libde265.git",
"tag" : "v1.0.11"
"type": "git",
"url": "https://github.com/strukturag/libde265.git",
"tag": "v1.0.11"
}
]
},
{
"name" : "libheif",
"buildsystem" : "cmake",
"name": "libheif",
"buildsystem": "cmake",
"config-opts": [
/* Build HEIC (x265) as plugin */
"-DWITH_LIBDE265_PLUGIN=On",
@ -141,38 +141,38 @@
/* No need for examples */
"-DWITH_EXAMPLES=Off"
],
"sources" : [
"sources": [
{
"type" : "git",
"url" : "https://github.com/strukturag/libheif.git",
"tag" : "v1.16.2"
"type": "git",
"url": "https://github.com/strukturag/libheif.git",
"tag": "v1.17.2"
}
]
},
{
"name" : "glycin",
"buildsystem" : "meson",
"sources" : [
"name": "glycin",
"buildsystem": "meson",
"sources": [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/sophie-h/glycin.git",
"commit" : "84885234beca8185ca739bfcca229fb52b339800"
"type": "git",
"url": "https://gitlab.gnome.org/sophie-h/glycin.git",
"commit": "2775373f373056ba79f5c3e0afd256815ad0dc32"
}
]
},
{
"name" : "loupe",
"buildsystem" : "meson",
"name": "loupe",
"buildsystem": "meson",
"config-opts": [
"-Dprofile=development",
"-Ddisable-glycin-sandbox=true"
],
"sources" : [
"sources": [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/loupe.git"
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/loupe.git"
}
]
}
]
}
}

View file

@ -57,10 +57,10 @@ impl Glycin {
let image = image_request.request().await?;
if let Some(exif_raw) = image.info().exif.clone().into() {
if let Some(exif_raw) = image.info().details.exif.clone() {
let mut metadata = Metadata::default();
metadata.set_exif_bytes(exif_raw);
metadata.set_transformations_applied(image.info().transformations_applied);
metadata.set_transformations_applied(image.info().details.transformations_applied);
updater.send(DecoderUpdate::Metadata(metadata));
}

View file

@ -78,11 +78,8 @@ impl Svg {
let image = image_request.request().await?;
let dimensions = if let Some(string) = image.info().dimensions_text.as_ref() {
ImageDimensionDetails::Svg(
string.to_string(),
image.info().dimensions_inch.clone().into(),
)
let dimensions = if let Some(string) = image.info().details.dimensions_text.as_ref() {
ImageDimensionDetails::Svg(string.to_string(), image.info().details.dimensions_inch)
} else {
ImageDimensionDetails::None
};

View file

@ -146,7 +146,7 @@ impl Decoder {
if mime_type.split('+').next() == Some("image/svg") {
update_sender.send(DecoderUpdate::Format(ImageFormat::new(
mime_type,
"SVG".into(),
Some("SVG".into()),
)));
return FormatDecoder::Svg(Svg::new(file, update_sender, tiles));
}

View file

@ -62,7 +62,7 @@ mod widgets;
mod window;
mod deps {
pub use gtk::{cairo, gdk, gdk_pixbuf, gio, glib, graphene, gsk};
pub use gtk::{cairo, gdk, gio, glib, graphene, gsk};
}
use application::LpApplication;

View file

@ -15,14 +15,16 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
use crate::util::gettext::*;
#[derive(Clone, Debug)]
pub struct ImageFormat {
mime_type: glycin::MimeType,
name: String,
name: Option<String>,
}
impl ImageFormat {
pub fn new(mime_type: glycin::MimeType, name: String) -> Self {
pub fn new(mime_type: glycin::MimeType, name: Option<String>) -> Self {
Self { mime_type, name }
}
@ -40,6 +42,10 @@ impl ImageFormat {
impl std::fmt::Display for ImageFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(f, "{}", self.name)
write!(
f,
"{}",
self.name.clone().unwrap_or_else(|| gettext("Unknown"))
)
}
}

View file

@ -74,7 +74,7 @@ impl GPSCoord {
}
fn position_exif(position: &[exif::Rational]) -> Option<(f64, Option<f64>, Option<f64>)> {
let (deg, mut min, mut sec) = (position.get(0)?, position.get(1), position.get(2));
let (deg, mut min, mut sec) = (position.first()?, position.get(1), position.get(2));
if let (Some(min_), Some(sec_)) = (min, sec) {
if min_.denom > 1 && sec_.num == 0 {