update linux.rs & macos.rs with bytes:Byte

issues:958
This commit is contained in:
tom 2022-07-17 00:59:56 +08:00
parent efa6b5972d
commit ae839bd5bf
3 changed files with 8 additions and 7 deletions

View File

@ -8,7 +8,6 @@ fn main() {
.customize( .customize(
protobuf_codegen::Customize::default() protobuf_codegen::Customize::default()
.tokio_bytes(true) .tokio_bytes(true)
// .tokio_bytes_for_string(true)
) )
.run() .run()
.expect("Codegen failed."); .expect("Codegen failed.");

View File

@ -109,7 +109,8 @@ pub fn get_cursor_data(hcursor: u64) -> ResultType<CursorData> {
cd.id = (*img).cursor_serial as _; cd.id = (*img).cursor_serial as _;
let pixels = let pixels =
std::slice::from_raw_parts((*img).pixels, (cd.width * cd.height) as _); std::slice::from_raw_parts((*img).pixels, (cd.width * cd.height) as _);
cd.colors.resize(pixels.len() * 4, 0); // cd.colors.resize(pixels.len() * 4, 0);
let mut cd_colors = vec![0_u8; pixels.len() * 4];
for y in 0..cd.height { for y in 0..cd.height {
for x in 0..cd.width { for x in 0..cd.width {
let pos = (y * cd.width + x) as usize; let pos = (y * cd.width + x) as usize;
@ -122,12 +123,13 @@ pub fn get_cursor_data(hcursor: u64) -> ResultType<CursorData> {
continue; continue;
} }
let pos = pos * 4; let pos = pos * 4;
cd.colors[pos] = r as _; cd_colors[pos] = r as _;
cd.colors[pos + 1] = g as _; cd_colors[pos + 1] = g as _;
cd.colors[pos + 2] = b as _; cd_colors[pos + 2] = b as _;
cd.colors[pos + 3] = a as _; cd_colors[pos + 3] = a as _;
} }
} }
cd.colors = cd_colors.into();
res = Some(cd); res = Some(cd);
} }
if !img.is_null() { if !img.is_null() {

View File

@ -342,7 +342,7 @@ pub fn get_cursor_data(hcursor: u64) -> ResultType<CursorData> {
} }
Ok(CursorData { Ok(CursorData {
id: hcursor, id: hcursor,
colors, colors: colors.into(),
hotx: hotspot.x as _, hotx: hotspot.x as _,
hoty: hotspot.y as _, hoty: hotspot.y as _,
width: size.width as _, width: size.width as _,