Changed gradient::Packed to be repr(C) for direct gpu upload.
This commit is contained in:
parent
413526ad09
commit
902e333148
5 changed files with 31 additions and 22 deletions
|
|
@ -116,13 +116,17 @@ impl Linear {
|
|||
data[42] = self.end.x;
|
||||
data[43] = self.end.y;
|
||||
|
||||
Packed { data }
|
||||
Packed(data)
|
||||
}
|
||||
}
|
||||
|
||||
/// Packed [`Gradient`] data for use in shader code.
|
||||
#[derive(Debug)]
|
||||
pub struct Packed {
|
||||
/// The packed [`Gradient`] data.
|
||||
pub data: [f32; 44],
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
#[repr(C)]
|
||||
pub struct Packed([f32; 44]);
|
||||
|
||||
impl From<[f32; 44]> for Packed {
|
||||
fn from(value: [f32; 44]) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use crate::core::image;
|
|||
use crate::core::svg;
|
||||
use crate::core::text;
|
||||
use crate::core::{Background, Color, Font, Rectangle, Size, Vector};
|
||||
use crate::gradient;
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use std::sync::Arc;
|
||||
|
|
@ -258,7 +259,7 @@ pub struct GradientVertex2D {
|
|||
pub position: [f32; 2],
|
||||
|
||||
/// The packed vertex data of the gradient.
|
||||
pub gradient: [f32; 44],
|
||||
pub gradient: gradient::Packed,
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue