Clay custom dispatch improvements & DPI scaling fixes (#26)
Co-authored-by: Zachary Levy <zachary@sunforge.is> Reviewed-on: #26
This commit was merged in pull request #26.
This commit is contained in:
+14
-14
@@ -487,11 +487,11 @@ MAX_GAUSSIAN_BLUR_KERNEL_PAIRS :: 32
|
||||
// pipeline rather than tacked onto this one as a flag bit.
|
||||
//INTERNAL
|
||||
Gaussian_Blur_Primitive :: struct {
|
||||
bounds: [4]f32, // 0: 16 — world-space quad (min_xy, max_xy)
|
||||
radii: [4]f32, // 16: 16 — per-corner radii in physical pixels (BR, TR, BL, TL)
|
||||
half_size: [2]f32, // 32: 8 — RRect half extents (physical px)
|
||||
half_feather: f32, // 40: 4 — feather_px * 0.5 (SDF anti-aliasing)
|
||||
color: Color, // 44: 4 — tint, packed RGBA u8x4
|
||||
bounds: [4]f32, // 0: 16 — world-space quad (min_xy, max_xy) in logical px
|
||||
radii_ppx: [4]f32, // 16: 16 — per-corner radii (BR, TR, BL, TL)
|
||||
half_size_ppx: [2]f32, // 32: 8 — RRect half extents
|
||||
half_feather_ppx: f32, // 40: 4 — feather_ppx * 0.5 (SDF anti-aliasing)
|
||||
color: Color, // 44: 4 — tint, packed RGBA u8x4
|
||||
}
|
||||
#assert(size_of(Gaussian_Blur_Primitive) == 48)
|
||||
|
||||
@@ -1070,7 +1070,7 @@ run_backdrop_bracket :: proc(
|
||||
build_backdrop_primitive :: proc(
|
||||
rect: Rectangle,
|
||||
radii: Rectangle_Radii,
|
||||
feather_px: f32,
|
||||
feather_ppx: f32,
|
||||
) -> Gaussian_Blur_Primitive {
|
||||
max_radius := min(rect.width, rect.height) * 0.5
|
||||
clamped_top_left := clamp(radii.top_left, 0, max_radius)
|
||||
@@ -1078,8 +1078,8 @@ build_backdrop_primitive :: proc(
|
||||
clamped_bottom_right := clamp(radii.bottom_right, 0, max_radius)
|
||||
clamped_bottom_left := clamp(radii.bottom_left, 0, max_radius)
|
||||
|
||||
half_feather := feather_px * 0.5
|
||||
padding := half_feather / GLOB.dpi_scaling
|
||||
half_feather_ppx := feather_ppx * 0.5
|
||||
padding := half_feather_ppx / GLOB.dpi_scaling
|
||||
dpi_scale := GLOB.dpi_scaling
|
||||
|
||||
half_width := rect.width * 0.5
|
||||
@@ -1088,7 +1088,7 @@ build_backdrop_primitive :: proc(
|
||||
center_y := rect.y + half_height
|
||||
|
||||
return Gaussian_Blur_Primitive {
|
||||
bounds = {
|
||||
bounds = {
|
||||
center_x - half_width - padding,
|
||||
center_y - half_height - padding,
|
||||
center_x + half_width + padding,
|
||||
@@ -1098,14 +1098,14 @@ build_backdrop_primitive :: proc(
|
||||
// (p.x > 0) ? r.xy : r.zw picks right-vs-left half
|
||||
// then (p.y > 0) ? rxy.x : rxy.y picks bottom-vs-top within that half
|
||||
// So slot 0 = bottom-right, slot 1 = top-right, slot 2 = bottom-left, slot 3 = top-left.
|
||||
radii = {
|
||||
radii_ppx = {
|
||||
clamped_bottom_right * dpi_scale,
|
||||
clamped_top_right * dpi_scale,
|
||||
clamped_bottom_left * dpi_scale,
|
||||
clamped_top_left * dpi_scale,
|
||||
},
|
||||
half_size = {half_width * dpi_scale, half_height * dpi_scale},
|
||||
half_feather = half_feather,
|
||||
half_size_ppx = {half_width * dpi_scale, half_height * dpi_scale},
|
||||
half_feather_ppx = half_feather_ppx,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1162,9 +1162,9 @@ backdrop_blur :: proc(
|
||||
gaussian_sigma: f32,
|
||||
tint: Color = DFT_TINT,
|
||||
radii: Rectangle_Radii = {},
|
||||
feather_px: f32 = DFT_FEATHER_PX,
|
||||
feather_ppx: f32 = DFT_FEATHER_PPX,
|
||||
) {
|
||||
prim := build_backdrop_primitive(rect, radii, feather_px)
|
||||
prim := build_backdrop_primitive(rect, radii, feather_ppx)
|
||||
prim.color = tint
|
||||
prepare_backdrop_primitive(layer, prim, gaussian_sigma)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user