mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 14:51:15 +00:00
Rename blend_buffer to blend_slice
This commit is contained in:
parent
228e2d9a7e
commit
243df1ed54
2 changed files with 10 additions and 10 deletions
|
@ -283,7 +283,7 @@ fn render_window_frame_by_line(
|
|||
PhysicalLength::new(dirty_region.min_x())..PhysicalLength::new(dirty_region.max_x()),
|
||||
|line_buffer| {
|
||||
let offset = dirty_region.min_x() as usize;
|
||||
TargetPixel::blend_buffer(line_buffer, background.into());
|
||||
TargetPixel::blend_slice(line_buffer, background.into());
|
||||
for span in scene.items[0..scene.current_items_index].iter().rev() {
|
||||
debug_assert!(scene.current_line >= span.pos.y_length());
|
||||
debug_assert!(
|
||||
|
@ -291,7 +291,7 @@ fn render_window_frame_by_line(
|
|||
);
|
||||
match span.command {
|
||||
SceneCommand::Rectangle { color } => {
|
||||
TargetPixel::blend_buffer(
|
||||
TargetPixel::blend_slice(
|
||||
&mut line_buffer[span.pos.x as usize - offset
|
||||
..(span.pos.x_length() + span.size.width_length()).get()
|
||||
as usize
|
||||
|
@ -684,7 +684,7 @@ impl<'a, T: TargetPixel> ProcessScene for RenderToBuffer<'a, T> {
|
|||
let color = PremultipliedRgbaColor::from(color);
|
||||
for line in geometry.min_y()..geometry.max_y() {
|
||||
let begin = line as usize * self.stride.get() as usize + geometry.origin.x as usize;
|
||||
TargetPixel::blend_buffer(
|
||||
TargetPixel::blend_slice(
|
||||
&mut self.buffer[begin..begin + geometry.width() as usize],
|
||||
color,
|
||||
);
|
||||
|
|
|
@ -170,13 +170,13 @@ pub(super) fn draw_rounded_rectangle_line(
|
|||
as usize;
|
||||
let r = rev(x2).floor().min(span.size.width as u32) as usize;
|
||||
if l < r {
|
||||
TargetPixel::blend_buffer(&mut line_buffer[pos_x + l..pos_x + r], rr.border_color)
|
||||
TargetPixel::blend_slice(&mut line_buffer[pos_x + l..pos_x + r], rr.border_color)
|
||||
}
|
||||
} else {
|
||||
if border > Shifted(0) {
|
||||
// 3. draw the border (between x2 and x3)
|
||||
if ONE + x2 <= x3 {
|
||||
TargetPixel::blend_buffer(
|
||||
TargetPixel::blend_slice(
|
||||
&mut line_buffer[pos_x
|
||||
+ x2.ceil()
|
||||
.saturating_sub(rr.left_clip.get() as u32)
|
||||
|
@ -206,7 +206,7 @@ pub(super) fn draw_rounded_rectangle_line(
|
|||
let begin = x4.ceil().saturating_sub(rr.left_clip.get() as u32).min(span.size.width as u32);
|
||||
let end = rev(x4).floor().min(span.size.width as u32);
|
||||
if begin < end {
|
||||
TargetPixel::blend_buffer(
|
||||
TargetPixel::blend_slice(
|
||||
&mut line_buffer[pos_x + begin as usize..pos_x + end as usize],
|
||||
rr.inner_color,
|
||||
)
|
||||
|
@ -222,7 +222,7 @@ pub(super) fn draw_rounded_rectangle_line(
|
|||
});
|
||||
// 7. border x3 .. x2
|
||||
if ONE + x2 <= x3 {
|
||||
TargetPixel::blend_buffer(
|
||||
TargetPixel::blend_slice(
|
||||
&mut line_buffer[pos_x + rev(x3).ceil().min(span.size.width as u32) as usize
|
||||
..pos_x + rev(x2).floor().min(span.size.width as u32) as usize as usize],
|
||||
rr.border_color,
|
||||
|
@ -282,10 +282,10 @@ fn interpolate_color(
|
|||
/// components
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
pub struct PremultipliedRgbaColor {
|
||||
pub alpha: u8,
|
||||
pub red: u8,
|
||||
pub green: u8,
|
||||
pub blue: u8,
|
||||
pub alpha: u8,
|
||||
}
|
||||
|
||||
/// Convert a non-premultiplied color to a premultiplied one
|
||||
|
@ -312,8 +312,8 @@ impl PremultipliedRgbaColor {
|
|||
pub trait TargetPixel: Sized + Copy {
|
||||
/// Blend a single pixel with a color
|
||||
fn blend(&mut self, color: PremultipliedRgbaColor);
|
||||
/// Fill (or blend) a color in the buffer.
|
||||
fn blend_buffer(to_fill: &mut [Self], color: PremultipliedRgbaColor) {
|
||||
/// Fill (or blend) a color for all the pixel in the span.
|
||||
fn blend_slice(to_fill: &mut [Self], color: PremultipliedRgbaColor) {
|
||||
if color.alpha == u8::MAX {
|
||||
to_fill.fill(Self::from_rgb(color.red, color.green, color.blue))
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue