mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 19:08:05 +08:00
WIP graster-nodes: change Color params to Option<Color>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
//! custom BufferStruct impl for graphite
|
||||
|
||||
use crate::color::Color;
|
||||
use crate::shaders::buffer_struct::BufferStruct;
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Zeroable, Pod)]
|
||||
pub struct OptionalColorBuffer(u32, <Color as BufferStruct>::Buffer);
|
||||
|
||||
unsafe impl BufferStruct for Option<Color> {
|
||||
type Buffer = OptionalColorBuffer;
|
||||
|
||||
#[inline]
|
||||
fn write(from: Self) -> Self::Buffer {
|
||||
match from {
|
||||
None => OptionalColorBuffer(0, Color::write(Color::default())),
|
||||
Some(t) => OptionalColorBuffer(1, Color::write(t)),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read(from: Self::Buffer) -> Self {
|
||||
match from.0 {
|
||||
1 => Some(Color::read(from.1)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
use bytemuck::Pod;
|
||||
|
||||
mod glam;
|
||||
mod graphite;
|
||||
mod primitive;
|
||||
|
||||
/// A BufferStruct is a "parallel representation" of the original struct with some fundamental types remapped. This
|
||||
|
||||
Reference in New Issue
Block a user