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

View file

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

View file

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

View file

@ -57,10 +57,10 @@ impl Glycin {
let image = image_request.request().await?; 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(); let mut metadata = Metadata::default();
metadata.set_exif_bytes(exif_raw); 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)); updater.send(DecoderUpdate::Metadata(metadata));
} }

View file

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

View file

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

View file

@ -62,7 +62,7 @@ mod widgets;
mod window; mod window;
mod deps { 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; use application::LpApplication;

View file

@ -15,14 +15,16 @@
// //
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
use crate::util::gettext::*;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ImageFormat { pub struct ImageFormat {
mime_type: glycin::MimeType, mime_type: glycin::MimeType,
name: String, name: Option<String>,
} }
impl ImageFormat { 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 } Self { mime_type, name }
} }
@ -40,6 +42,10 @@ impl ImageFormat {
impl std::fmt::Display for ImageFormat { impl std::fmt::Display for ImageFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { 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>)> { 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 let (Some(min_), Some(sec_)) = (min, sec) {
if min_.denom > 1 && sec_.num == 0 { if min_.denom > 1 && sec_.num == 0 {