-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcaeb87
commit ec1e3ab
Showing
9 changed files
with
158 additions
and
52 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,58 @@ | ||
[workspace.package] | ||
version = "0.4.0" | ||
edition = "2021" | ||
license = "MIT" | ||
description = "impl screencopy for wayland" | ||
authors = ["Decodertalkers <[email protected]>"] | ||
homepage = "https://github.com/Decodetalkers/haruhishot" | ||
documentation = "https://docs.rs/libharuhishot/" | ||
keywords = ["wayland"] | ||
|
||
[package] | ||
name = "haruhishot" | ||
version = "0.3.19" | ||
edition = "2021" | ||
version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
description = "haruhishot" | ||
authors.workspace = true | ||
homepage.workspace = true | ||
keywords.workspace = true | ||
build = "build.rs" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[workspace] | ||
members = [".", "libharuhishot"] | ||
|
||
[dependencies] | ||
|
||
libharuhishot = { path = "libharuhishot", version = "0.2.5" } | ||
|
||
#wayland-client = "=0.30.0-beta.13" | ||
|
||
[workspace.dependencies] | ||
image = { version = "0.25", default-features = false, features = [ | ||
"jpeg", | ||
"png", | ||
"pnm", | ||
] } | ||
wayland-client = "0.31" | ||
tracing-subscriber = "0.3.18" | ||
tracing = "0.1.40" | ||
|
||
[dependencies] | ||
|
||
libharuhishot = { path = "libharuhishot", version = "0.4.0" } | ||
|
||
#wayland-client = "=0.30.0-beta.13" | ||
image.workspace = true | ||
|
||
sctk = { version = "0.18.1", package = "smithay-client-toolkit", optional = true } | ||
|
||
# in the feature | ||
slint = { version = "1.8.0", optional = true } | ||
|
||
tracing-subscriber = "0.3.18" | ||
tracing = "0.1.40" | ||
tracing-subscriber.workspace = true | ||
tracing.workspace = true | ||
clap = "4.5.19" | ||
once_cell = "1.20.1" | ||
|
||
dialoguer = { version = "0.11.0", features = ["fuzzy-select"] } | ||
|
||
wayland-client = { version = "0.31", optional = true } | ||
wayland-client = { workspace = true, optional = true } | ||
notify-rust = { version = "4.11.3", optional = true, features = ["images"] } | ||
xkbcommon = "0.8.0" | ||
swayipc = { version = "3.0.2", optional = true } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[package] | ||
name = "libharuhishot" | ||
version = "0.2.5" | ||
edition = "2021" | ||
license = "MIT" | ||
version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
description = "impl screencopy for wayland" | ||
authors = ["Decodertalkers <[email protected]>"] | ||
homepage = "https://github.com/Decodetalkers/haruhishot" | ||
authors.workspace = true | ||
homepage.workspace = true | ||
documentation = "https://docs.rs/libharuhishot/" | ||
keywords = ["wayland"] | ||
readme = "README.md" | ||
|
@@ -23,7 +23,7 @@ wayland-protocols = { version = "0.32.4", default-features = false, features = [ | |
wayland-protocols-wlr = { version = "0.3.4", default-features = false, features = [ | ||
"client", | ||
] } | ||
wayland-client = "0.31" | ||
wayland-client.workspace = true | ||
#wayland-client = "=0.30.0-beta.13" | ||
|
||
nix = { version = "0.29.0", features = ["fs", "mman"] } | ||
|
@@ -34,3 +34,5 @@ memmap2 = "0.9.5" | |
tracing = "0.1.40" | ||
|
||
thiserror = "1.0.64" | ||
|
||
image.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
use image::ColorType; | ||
use wayland_client::protocol::wl_shm; | ||
|
||
pub trait Convert { | ||
/// Convert raw image data into output type, return said type | ||
fn convert_inplace(&self, data: &mut [u8]) -> ColorType; | ||
} | ||
|
||
#[derive(Default)] | ||
struct ConvertBGR10; | ||
|
||
#[derive(Default)] | ||
struct ConvertNone; | ||
|
||
#[derive(Default)] | ||
struct ConvertRGB8; | ||
|
||
#[derive(Default)] | ||
struct ConvertBGR888; | ||
|
||
const SHIFT10BITS_1: u32 = 20; | ||
const SHIFT10BITS_2: u32 = 10; | ||
|
||
/// Creates format converter based of input format, return None if conversion | ||
/// isn't possible. Conversion is happening inplace. | ||
pub fn create_converter(format: wl_shm::Format) -> Option<Box<dyn Convert>> { | ||
match format { | ||
wl_shm::Format::Xbgr8888 | wl_shm::Format::Abgr8888 => Some(Box::<ConvertNone>::default()), | ||
wl_shm::Format::Xrgb8888 | wl_shm::Format::Argb8888 => Some(Box::<ConvertRGB8>::default()), | ||
wl_shm::Format::Xbgr2101010 | wl_shm::Format::Abgr2101010 => { | ||
Some(Box::<ConvertBGR10>::default()) | ||
} | ||
wl_shm::Format::Bgr888 => Some(Box::<ConvertBGR888>::default()), | ||
_ => None, | ||
} | ||
} | ||
|
||
impl Convert for ConvertNone { | ||
fn convert_inplace(&self, _data: &mut [u8]) -> ColorType { | ||
ColorType::Rgba8 | ||
} | ||
} | ||
|
||
impl Convert for ConvertRGB8 { | ||
fn convert_inplace(&self, data: &mut [u8]) -> ColorType { | ||
for chunk in data.chunks_exact_mut(4) { | ||
chunk.swap(0, 2); | ||
} | ||
ColorType::Rgba8 | ||
} | ||
} | ||
|
||
/// Simple conversion from 10 to 8 bits for one channel | ||
fn convert10_to_8(color: u32) -> u8 { | ||
((color >> 2) & 255) as u8 | ||
} | ||
|
||
impl Convert for ConvertBGR10 { | ||
fn convert_inplace(&self, data: &mut [u8]) -> ColorType { | ||
for chunk in data.chunks_exact_mut(4) { | ||
let pixel = ((chunk[3] as u32) << 24) | ||
| ((chunk[2] as u32) << 16) | ||
| ((chunk[1] as u32) << 8) | ||
| chunk[0] as u32; | ||
let r = convert10_to_8(pixel >> SHIFT10BITS_1); | ||
let g = convert10_to_8(pixel >> SHIFT10BITS_2); | ||
let b = convert10_to_8(pixel); | ||
chunk[0] = b; | ||
chunk[1] = g; | ||
chunk[2] = r; | ||
chunk[3] = 255; | ||
} | ||
ColorType::Rgba8 | ||
} | ||
} | ||
|
||
impl Convert for ConvertBGR888 { | ||
fn convert_inplace(&self, _data: &mut [u8]) -> ColorType { | ||
ColorType::Rgb8 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters