add support for copyRect encoding
This commit is contained in:
parent
da807ead3e
commit
607c90009d
@ -256,6 +256,26 @@ impl PageVnc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
match cr.type_ {
|
||||||
|
1 => {
|
||||||
|
//copy
|
||||||
|
let sx = (cr.data[0] as u16) << 8 | cr.data[1] as u16;
|
||||||
|
let sy = (cr.data[2] as u16) << 8 | cr.data[3] as u16;
|
||||||
|
|
||||||
|
let _ = ctx.
|
||||||
|
draw_image_with_html_canvas_element_and_sw_and_sh_and_dx_and_dy_and_dw_and_dh(
|
||||||
|
&canvas,
|
||||||
|
sx as f64,
|
||||||
|
sy as f64,
|
||||||
|
cr.width as f64,
|
||||||
|
cr.height as f64,
|
||||||
|
cr.x as f64,
|
||||||
|
cr.y as f64,
|
||||||
|
cr.width as f64,
|
||||||
|
cr.height as f64
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
let data = ImageData::new_with_u8_clamped_array_and_sh(
|
let data = ImageData::new_with_u8_clamped_array_and_sh(
|
||||||
Clamped(&cr.data),
|
Clamped(&cr.data),
|
||||||
cr.width as u32,
|
cr.width as u32,
|
||||||
@ -267,6 +287,9 @@ impl PageVnc {
|
|||||||
// cr.x, cr.y, cr.width, cr.height
|
// cr.x, cr.y, cr.width, cr.height
|
||||||
// ));
|
// ));
|
||||||
let _ = ctx.put_image_data(&data, cr.x as f64, cr.y as f64);
|
let _ = ctx.put_image_data(&data, cr.x as f64, cr.y as f64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
should_render = true;
|
should_render = true;
|
||||||
}
|
}
|
||||||
ProtocalHandlerOutput::SetCanvas(width, height) => {
|
ProtocalHandlerOutput::SetCanvas(width, height) => {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use std::{rc::Rc, sync::Mutex};
|
use std::{rc::Rc, sync::Mutex};
|
||||||
|
|
||||||
pub struct CanvasData {
|
pub struct CanvasData {
|
||||||
|
pub type_: u32,
|
||||||
pub x: u16,
|
pub x: u16,
|
||||||
pub y: u16,
|
pub y: u16,
|
||||||
pub width: u16,
|
pub width: u16,
|
||||||
|
@ -23,6 +23,7 @@ pub enum SecurityType {
|
|||||||
// VeNCrypt = 19,
|
// VeNCrypt = 19,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
pub enum VncEncoding {
|
pub enum VncEncoding {
|
||||||
@ -79,7 +80,7 @@ impl ProtocalImpl for VncHandler {
|
|||||||
state: VncState::Init,
|
state: VncState::Init,
|
||||||
supported_encodings: vec![
|
supported_encodings: vec![
|
||||||
VncEncoding::Raw,
|
VncEncoding::Raw,
|
||||||
// VncEncoding::CopyRect,
|
VncEncoding::CopyRect,
|
||||||
// VncEncoding::RRE,
|
// VncEncoding::RRE,
|
||||||
// VncEncoding::Hextile,
|
// VncEncoding::Hextile,
|
||||||
// VncEncoding::TRLE,
|
// VncEncoding::TRLE,
|
||||||
@ -554,10 +555,15 @@ impl VncHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1 => {
|
||||||
|
// copy rectangle
|
||||||
|
self.read_exact_vec(&mut image_data, 4);
|
||||||
|
}
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
}
|
}
|
||||||
self.outs
|
self.outs
|
||||||
.push(ProtocalHandlerOutput::RenderCanvas(CanvasData {
|
.push(ProtocalHandlerOutput::RenderCanvas(CanvasData {
|
||||||
|
type_: rect.encoding_type,
|
||||||
x: rect.x,
|
x: rect.x,
|
||||||
y: rect.y,
|
y: rect.y,
|
||||||
width: rect.width,
|
width: rect.width,
|
||||||
@ -649,19 +655,31 @@ impl VncHandler {
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
encoding_type: 0,
|
encoding_type: 0,
|
||||||
encoding_data: Vec::new(), // we donnot need to store the data
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_copy_rect_encoding(&mut self, _x: u16, _y: u16, _width: u16, _height: u16) {
|
fn handle_copy_rect_encoding(&mut self, x: u16, y: u16, width: u16, height: u16) {
|
||||||
unimplemented!()
|
ConsoleService::log(&format!("VNC: CopyRect {} {} {} {}", x, y, width, height));
|
||||||
|
self.require = 4;
|
||||||
|
self.padding_rect = Some(VncRect {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
encoding_type: 1,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_rre_encoding(&mut self, _x: u16, _y: u16, _width: u16, _height: u16) {
|
fn handle_rre_encoding(&mut self, _x: u16, _y: u16, _width: u16, _height: u16) {
|
||||||
|
// Note: RRE encoding is obsolescent. In general, ZRLE and TRLE
|
||||||
|
// encodings are more compact.
|
||||||
|
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_hextile_encoding(&mut self, _x: u16, _y: u16, _width: u16, _height: u16) {
|
fn handle_hextile_encoding(&mut self, _x: u16, _y: u16, _width: u16, _height: u16) {
|
||||||
|
// Note: Hextile encoding is obsolescent. In general, ZRLE and TRLE
|
||||||
|
// encodings are more compact.
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,5 +818,4 @@ struct VncRect {
|
|||||||
width: u16,
|
width: u16,
|
||||||
height: u16,
|
height: u16,
|
||||||
encoding_type: u32,
|
encoding_type: u32,
|
||||||
encoding_data: Vec<u8>,
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user