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