summaryrefslogtreecommitdiffstats
path: root/wgpu/src/layer/quad.rs
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/layer/quad.rs')
-rw-r--r--wgpu/src/layer/quad.rs41
1 files changed, 31 insertions, 10 deletions
diff --git a/wgpu/src/layer/quad.rs b/wgpu/src/layer/quad.rs
index 0d8bde9d..9913cfe0 100644
--- a/wgpu/src/layer/quad.rs
+++ b/wgpu/src/layer/quad.rs
@@ -1,7 +1,9 @@
-/// A colored rectangle with a border.
-///
-/// This type can be directly uploaded to GPU memory.
-#[derive(Debug, Clone, Copy)]
+//! A rectangle with certain styled properties.
+
+use bytemuck::{Pod, Zeroable};
+
+/// The properties of a quad.
+#[derive(Clone, Copy, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct Quad {
/// The position of the [`Quad`].
@@ -10,21 +12,40 @@ pub struct Quad {
/// The size of the [`Quad`].
pub size: [f32; 2],
- /// The color of the [`Quad`], in __linear RGB__.
- pub color: [f32; 4],
-
/// The border color of the [`Quad`], in __linear RGB__.
pub border_color: [f32; 4],
- /// The border radius of the [`Quad`].
+ /// The border radii of the [`Quad`].
pub border_radius: [f32; 4],
/// The border width of the [`Quad`].
pub border_width: f32,
}
+/// A quad filled with a solid color.
+#[derive(Clone, Copy, Debug, Pod, Zeroable)]
+#[repr(C)]
+pub struct Solid {
+ /// The background color data of the quad.
+ pub color: [f32; 4],
+
+ /// The [`Quad`] data of the [`Solid`].
+ pub quad: Quad,
+}
+
+/// A quad filled with interpolated colors.
+#[derive(Clone, Copy, Debug)]
+#[repr(C)]
+pub struct Gradient {
+ /// The background gradient data of the quad.
+ pub gradient: [f32; 44],
+
+ /// The [`Quad`] data of the [`Gradient`].
+ pub quad: Quad,
+}
+
#[allow(unsafe_code)]
-unsafe impl bytemuck::Zeroable for Quad {}
+unsafe impl Pod for Gradient {}
#[allow(unsafe_code)]
-unsafe impl bytemuck::Pod for Quad {}
+unsafe impl Zeroable for Gradient {}