Skip to content

Commit b1f161a

Browse files
committed
wip: use my own fork for now
1 parent a3c65d2 commit b1f161a

File tree

4 files changed

+25
-33
lines changed

4 files changed

+25
-33
lines changed

.cargo/config.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[alias]
22
xtask = "run --package xtask --"
3+
4+
[patch.crates-io]
5+
qoi = { git = "https://github.com/elmarco/qoi-rust.git", branch = "raw" }

Cargo.lock

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ironrdp-server/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ name = "perfenc"
2020
required-features = ["__bench"]
2121

2222
[features]
23-
default = ["rayon"]
23+
default = ["rayon", "qoi"]
2424
helper = ["dep:x509-cert", "dep:rustls-pemfile"]
2525
rayon = ["dep:rayon"]
2626
qoi = ["dep:qoi", "ironrdp-pdu/qoi"]

crates/ironrdp-server/src/encoder/mod.rs

+20-30
Original file line numberDiff line numberDiff line change
@@ -273,38 +273,28 @@ impl QoiHandler {
273273

274274
#[cfg(feature = "qoi")]
275275
impl BitmapUpdateHandler for QoiHandler {
276-
fn handle<'a>(&mut self, mut bitmap: BitmapUpdate, encoder: &'a mut PduEncoder) -> Result<UpdateFragmenter<'a>> {
276+
fn handle<'a>(&mut self, bitmap: BitmapUpdate, encoder: &'a mut PduEncoder) -> Result<UpdateFragmenter<'a>> {
277277
use ironrdp_graphics::image_processing::PixelFormat::*;
278278

279-
if usize::from(bitmap.width.get() * 4) != bitmap.stride {
280-
anyhow::bail!("unsupported bitmap with stride");
281-
}
282-
let mut pixels = bitmap.data.as_mut_slice();
283-
let n = pixels.len() / 4;
284-
match bitmap.format {
285-
ARgb32 => (),
286-
XRgb32 => {
287-
(0..n).for_each(|i| pixels.copy_within(4 * i + 1..4 * i + 4, 3 * i));
288-
pixels = &mut pixels[..n * 3];
289-
}
290-
ABgr32 => todo!(),
291-
XBgr32 => todo!(),
292-
BgrA32 => pixels.chunks_exact_mut(4).for_each(|chunk| chunk.reverse()),
293-
BgrX32 => {
294-
dbg!();
295-
(0..n).for_each(|i| {
296-
pixels[4 * i..4 * i + 3].reverse();
297-
pixels.copy_within(4 * i..4 * i + 3, 3 * i);
298-
});
299-
pixels = &mut pixels[..n * 3];
300-
}
301-
RgbA32 => todo!(),
302-
RgbX32 => {
303-
(0..n).for_each(|i| pixels.copy_within(4 * i..4 * i + 3, 3 * i));
304-
pixels = &mut pixels[..n * 3];
305-
}
306-
}
307-
let data = qoi::encode_to_vec(pixels, bitmap.width.get().into(), bitmap.height.get().into()).unwrap();
279+
let channels = match bitmap.format {
280+
ARgb32 => qoi::RawChannels::Argb,
281+
XRgb32 => qoi::RawChannels::Xrgb,
282+
ABgr32 => qoi::RawChannels::Abgr,
283+
XBgr32 => qoi::RawChannels::Xbgr,
284+
BgrA32 => qoi::RawChannels::Bgra,
285+
BgrX32 => qoi::RawChannels::Bgrx,
286+
RgbA32 => qoi::RawChannels::Rgba,
287+
RgbX32 => qoi::RawChannels::Rgbx,
288+
};
289+
290+
let enc = qoi::Encoder::new_raw(
291+
&bitmap.data,
292+
bitmap.width.get().into(),
293+
bitmap.height.get().into(),
294+
bitmap.stride,
295+
channels,
296+
)?;
297+
let data = enc.encode_to_vec()?;
308298
encoder.set_surface(bitmap, self.codec_id, data)
309299
}
310300
}

0 commit comments

Comments
 (0)