Detailed changes
@@ -10,11 +10,6 @@ var s_sprite: sampler;
const M_PI_F: f32 = 3.1415926;
const GRAYSCALE_FACTORS: vec3<f32> = vec3<f32>(0.2126, 0.7152, 0.0722);
-struct ViewId {
- lo: u32,
- hi: u32,
-}
-
struct Bounds {
origin: vec2<f32>,
size: vec2<f32>,
@@ -172,8 +167,6 @@ fn quad_sdf(point: vec2<f32>, bounds: Bounds, corner_radii: Corners) -> f32 {
// --- quads --- //
struct Quad {
- view_id: ViewId,
- layer_id: u32,
order: u32,
bounds: Bounds,
content_mask: Bounds,
@@ -266,15 +259,12 @@ fn fs_quad(input: QuadVarying) -> @location(0) vec4<f32> {
// --- shadows --- //
struct Shadow {
- view_id: ViewId,
- layer_id: u32,
order: u32,
+ blur_radius: f32,
bounds: Bounds,
corner_radii: Corners,
content_mask: Bounds,
color: Hsla,
- blur_radius: f32,
- pad: u32,
}
var<storage, read> b_shadows: array<Shadow>;
@@ -418,9 +408,8 @@ fn fs_path(input: PathVarying) -> @location(0) vec4<f32> {
// --- underlines --- //
struct Underline {
- view_id: ViewId,
- layer_id: u32,
order: u32,
+ pad: u32,
bounds: Bounds,
content_mask: Bounds,
color: Hsla,
@@ -480,9 +469,8 @@ fn fs_underline(input: UnderlineVarying) -> @location(0) vec4<f32> {
// --- monochrome sprites --- //
struct MonochromeSprite {
- view_id: ViewId,
- layer_id: u32,
order: u32,
+ pad: u32,
bounds: Bounds,
content_mask: Bounds,
color: Hsla,
@@ -523,15 +511,12 @@ fn fs_mono_sprite(input: MonoSpriteVarying) -> @location(0) vec4<f32> {
// --- polychrome sprites --- //
struct PolychromeSprite {
- view_id: ViewId,
- layer_id: u32,
order: u32,
+ grayscale: u32,
bounds: Bounds,
content_mask: Bounds,
corner_radii: Corners,
tile: AtlasTile,
- grayscale: u32,
- pad: u32,
}
var<storage, read> b_poly_sprites: array<PolychromeSprite>;
@@ -418,6 +418,7 @@ pub(crate) enum PrimitiveBatch<'a> {
#[repr(C)]
pub(crate) struct Quad {
pub order: DrawOrder,
+ pub pad: u32, // align to 8 bytes
pub bounds: Bounds<ScaledPixels>,
pub content_mask: ContentMask<ScaledPixels>,
pub background: Hsla,
@@ -448,6 +449,7 @@ impl From<Quad> for Primitive {
#[repr(C)]
pub(crate) struct Underline {
pub order: DrawOrder,
+ pub pad: u32, // align to 8 bytes
pub bounds: Bounds<ScaledPixels>,
pub content_mask: ContentMask<ScaledPixels>,
pub color: Hsla,
@@ -477,12 +479,11 @@ impl From<Underline> for Primitive {
#[repr(C)]
pub(crate) struct Shadow {
pub order: DrawOrder,
+ pub blur_radius: ScaledPixels,
pub bounds: Bounds<ScaledPixels>,
pub corner_radii: Corners<ScaledPixels>,
pub content_mask: ContentMask<ScaledPixels>,
pub color: Hsla,
- pub blur_radius: ScaledPixels,
- pub pad: u32, // align to 8 bytes
}
impl Ord for Shadow {
@@ -507,6 +508,7 @@ impl From<Shadow> for Primitive {
#[repr(C)]
pub(crate) struct MonochromeSprite {
pub order: DrawOrder,
+ pub pad: u32, // align to 8 bytes
pub bounds: Bounds<ScaledPixels>,
pub content_mask: ContentMask<ScaledPixels>,
pub color: Hsla,
@@ -538,12 +540,11 @@ impl From<MonochromeSprite> for Primitive {
#[repr(C)]
pub(crate) struct PolychromeSprite {
pub order: DrawOrder,
+ pub grayscale: bool,
pub bounds: Bounds<ScaledPixels>,
pub content_mask: ContentMask<ScaledPixels>,
pub corner_radii: Corners<ScaledPixels>,
pub tile: AtlasTile,
- pub grayscale: bool,
- pub pad: u32, // align to 8 bytes
}
impl Ord for PolychromeSprite {
@@ -859,12 +859,11 @@ impl<'a> ElementContext<'a> {
shadow_bounds.dilate(shadow.spread_radius);
self.window.next_frame.scene.insert_primitive(Shadow {
order: 0,
+ blur_radius: shadow.blur_radius.scale(scale_factor),
bounds: shadow_bounds.scale(scale_factor),
content_mask: content_mask.scale(scale_factor),
corner_radii: corner_radii.scale(scale_factor),
color: shadow.color,
- blur_radius: shadow.blur_radius.scale(scale_factor),
- pad: 0,
});
}
}
@@ -877,6 +876,7 @@ impl<'a> ElementContext<'a> {
let content_mask = self.content_mask();
self.window.next_frame.scene.insert_primitive(Quad {
order: 0,
+ pad: 0,
bounds: quad.bounds.scale(scale_factor),
content_mask: content_mask.scale(scale_factor),
background: quad.background,
@@ -919,6 +919,7 @@ impl<'a> ElementContext<'a> {
self.window.next_frame.scene.insert_primitive(Underline {
order: 0,
+ pad: 0,
bounds: bounds.scale(scale_factor),
content_mask: content_mask.scale(scale_factor),
color: style.color.unwrap_or_default(),
@@ -944,6 +945,7 @@ impl<'a> ElementContext<'a> {
self.window.next_frame.scene.insert_primitive(Underline {
order: 0,
+ pad: 0,
bounds: bounds.scale(scale_factor),
content_mask: content_mask.scale(scale_factor),
thickness: style.thickness.scale(scale_factor),
@@ -1000,6 +1002,7 @@ impl<'a> ElementContext<'a> {
.scene
.insert_primitive(MonochromeSprite {
order: 0,
+ pad: 0,
bounds,
content_mask,
color,
@@ -1054,12 +1057,11 @@ impl<'a> ElementContext<'a> {
.scene
.insert_primitive(PolychromeSprite {
order: 0,
+ grayscale: false,
bounds,
corner_radii: Default::default(),
content_mask,
tile,
- grayscale: false,
- pad: 0,
});
}
Ok(())
@@ -1096,6 +1098,7 @@ impl<'a> ElementContext<'a> {
.scene
.insert_primitive(MonochromeSprite {
order: 0,
+ pad: 0,
bounds,
content_mask,
color,
@@ -1131,12 +1134,11 @@ impl<'a> ElementContext<'a> {
.scene
.insert_primitive(PolychromeSprite {
order: 0,
+ grayscale,
bounds,
content_mask,
corner_radii,
tile,
- grayscale,
- pad: 0,
});
Ok(())
}