mirror of
https://github.com/CloudNebulaProject/wayray.git
synced 2026-04-10 13:10:41 +00:00
Fix pixel format: pass ARGB8888 directly as BGRA8
On little-endian x86, ARGB8888 bytes in memory are [B,G,R,A] which matches wgpu's Bgra8Unorm layout. No byte swapping needed.
This commit is contained in:
parent
6b15ee819e
commit
fa6bb53142
1 changed files with 5 additions and 12 deletions
|
|
@ -246,8 +246,10 @@ impl Display {
|
|||
|
||||
/// Upload framebuffer pixel data to the GPU texture.
|
||||
///
|
||||
/// `pixel_data` is ARGB8888 format from the server (PixmanRenderer).
|
||||
/// This method converts to BGRA8 for the GPU texture.
|
||||
/// `pixel_data` is ARGB8888 from the server (PixmanRenderer on
|
||||
/// little-endian x86). In memory this is `[B, G, R, A]` per pixel,
|
||||
/// which matches wgpu's `Bgra8Unorm` layout directly — no conversion
|
||||
/// needed.
|
||||
pub fn update_frame(&self, pixel_data: &[u8]) {
|
||||
let expected = (self.width * self.height * 4) as usize;
|
||||
if pixel_data.len() != expected {
|
||||
|
|
@ -258,18 +260,9 @@ impl Display {
|
|||
return;
|
||||
}
|
||||
|
||||
// Convert ARGB8888 → BGRA8: [A,R,G,B] → [B,G,R,A]
|
||||
let mut bgra = Vec::with_capacity(pixel_data.len());
|
||||
for pixel in pixel_data.chunks_exact(4) {
|
||||
bgra.push(pixel[3]); // B
|
||||
bgra.push(pixel[2]); // G
|
||||
bgra.push(pixel[1]); // R
|
||||
bgra.push(pixel[0]); // A
|
||||
}
|
||||
|
||||
self.queue.write_texture(
|
||||
self.frame_texture.as_image_copy(),
|
||||
&bgra,
|
||||
pixel_data,
|
||||
wgpu::TexelCopyBufferLayout {
|
||||
offset: 0,
|
||||
bytes_per_row: Some(self.width * 4),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue