Change TargetPixelBuffer's draw_texture function to take a data structure instead of many arguments

This commit is contained in:
Simon Hausmann 2025-02-20 09:16:48 +01:00 committed by Simon Hausmann
parent 491cb2f911
commit df6c99871d
8 changed files with 183 additions and 134 deletions

View file

@ -357,12 +357,26 @@ mod software_renderer {
use i_slint_core::graphics::{IntRect, Rgb8Pixel};
use i_slint_core::software_renderer::{
PhysicalRegion, PremultipliedRgbaColor, RepaintBufferType, Rgb565Pixel, SoftwareRenderer,
TargetPixelBuffer,
TargetPixelBuffer, Texture, TexturePixelFormat,
};
use i_slint_core::SharedVector;
type CppTargetPixelBufferUserData = *mut c_void;
#[repr(C)]
pub struct CppInternalTexture {
pub bytes: *const u8,
pub bytes_len: usize,
pub pixel_format: TexturePixelFormat,
pub pixel_stride: u16,
pub width: u16,
pub height: u16,
pub delta_x: u16,
pub delta_y: u16,
pub source_offset_x: u16,
pub source_offset_y: u16,
}
#[repr(C)]
pub struct CppRgb8TargetPixelBuffer {
user_data: CppTargetPixelBufferUserData,
@ -391,15 +405,7 @@ mod software_renderer {
i16,
i16,
i16,
*const u8,
u16,
i16,
i16,
u8,
u16,
u16,
u16,
u16,
&CppInternalTexture,
u32,
u8,
u8,
@ -452,15 +458,7 @@ mod software_renderer {
width: i16,
height: i16,
span_y: i16,
src: *const u8,
src_stride: u16,
src_width: i16,
src_height: i16,
src_pixel_format: u8,
dx: u16,
dy: u16,
off_x: u16,
off_y: u16,
texture: Texture<'_>,
colorize: u32,
alpha: u8,
rotation: u8,
@ -473,15 +471,18 @@ mod software_renderer {
width,
height,
span_y,
src,
src_stride,
src_width,
src_height,
src_pixel_format,
dx,
dy,
off_x,
off_y,
&CppInternalTexture {
bytes: texture.bytes.as_ptr(),
bytes_len: texture.bytes.len(),
pixel_format: texture.pixel_format,
pixel_stride: texture.pixel_stride,
width: texture.width,
height: texture.height,
delta_x: texture.delta_x,
delta_y: texture.delta_y,
source_offset_x: texture.source_offset_x,
source_offset_y: texture.source_offset_y,
},
colorize,
alpha,
rotation,
@ -518,15 +519,7 @@ mod software_renderer {
i16,
i16,
i16,
*const u8,
u16,
i16,
i16,
u8,
u16,
u16,
u16,
u16,
&CppInternalTexture,
u32,
u8,
u8,
@ -579,15 +572,7 @@ mod software_renderer {
width: i16,
height: i16,
span_y: i16,
src: *const u8,
src_stride: u16,
src_width: i16,
src_height: i16,
src_pixel_format: u8,
dx: u16,
dy: u16,
off_x: u16,
off_y: u16,
texture: Texture<'_>,
colorize: u32,
alpha: u8,
rotation: u8,
@ -600,15 +585,18 @@ mod software_renderer {
width,
height,
span_y,
src,
src_stride,
src_width,
src_height,
src_pixel_format,
dx,
dy,
off_x,
off_y,
&CppInternalTexture {
bytes: texture.bytes.as_ptr(),
bytes_len: texture.bytes.len(),
pixel_format: texture.pixel_format,
pixel_stride: texture.pixel_stride,
width: texture.width,
height: texture.height,
delta_x: texture.delta_x,
delta_y: texture.delta_y,
source_offset_x: texture.source_offset_x,
source_offset_y: texture.source_offset_y,
},
colorize,
alpha,
rotation,