refactor: narrow CellText glyph fields from u32 to u16
parent
c61f184069
commit
39d693e365
|
|
@ -3076,8 +3076,8 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||
.atlas = .grayscale,
|
||||
.grid_pos = .{ @intCast(x), @intCast(y) },
|
||||
.color = .{ color.r, color.g, color.b, alpha },
|
||||
.glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y },
|
||||
.glyph_size = .{ render.glyph.width, render.glyph.height },
|
||||
.glyph_pos = .{ @intCast(render.glyph.atlas_x), @intCast(render.glyph.atlas_y) },
|
||||
.glyph_size = .{ @intCast(render.glyph.width), @intCast(render.glyph.height) },
|
||||
.bearings = .{
|
||||
@intCast(render.glyph.offset_x),
|
||||
@intCast(render.glyph.offset_y),
|
||||
|
|
@ -3107,8 +3107,8 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||
.atlas = .grayscale,
|
||||
.grid_pos = .{ @intCast(x), @intCast(y) },
|
||||
.color = .{ color.r, color.g, color.b, alpha },
|
||||
.glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y },
|
||||
.glyph_size = .{ render.glyph.width, render.glyph.height },
|
||||
.glyph_pos = .{ @intCast(render.glyph.atlas_x), @intCast(render.glyph.atlas_y) },
|
||||
.glyph_size = .{ @intCast(render.glyph.width), @intCast(render.glyph.height) },
|
||||
.bearings = .{
|
||||
@intCast(render.glyph.offset_x),
|
||||
@intCast(render.glyph.offset_y),
|
||||
|
|
@ -3138,8 +3138,8 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||
.atlas = .grayscale,
|
||||
.grid_pos = .{ @intCast(x), @intCast(y) },
|
||||
.color = .{ color.r, color.g, color.b, alpha },
|
||||
.glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y },
|
||||
.glyph_size = .{ render.glyph.width, render.glyph.height },
|
||||
.glyph_pos = .{ @intCast(render.glyph.atlas_x), @intCast(render.glyph.atlas_y) },
|
||||
.glyph_size = .{ @intCast(render.glyph.width), @intCast(render.glyph.height) },
|
||||
.bearings = .{
|
||||
@intCast(render.glyph.offset_x),
|
||||
@intCast(render.glyph.offset_y),
|
||||
|
|
@ -3201,8 +3201,8 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||
.bools = .{ .no_min_contrast = noMinContrast(cp) },
|
||||
.grid_pos = .{ @intCast(x), @intCast(y) },
|
||||
.color = .{ color.r, color.g, color.b, alpha },
|
||||
.glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y },
|
||||
.glyph_size = .{ render.glyph.width, render.glyph.height },
|
||||
.glyph_pos = .{ @intCast(render.glyph.atlas_x), @intCast(render.glyph.atlas_y) },
|
||||
.glyph_size = .{ @intCast(render.glyph.width), @intCast(render.glyph.height) },
|
||||
.bearings = .{
|
||||
@intCast(render.glyph.offset_x + shaper_cell.x_offset),
|
||||
@intCast(render.glyph.offset_y + shaper_cell.y_offset),
|
||||
|
|
@ -3290,8 +3290,8 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||
.bools = .{ .is_cursor_glyph = true },
|
||||
.grid_pos = .{ x, cursor_vp.y },
|
||||
.color = .{ cursor_color.r, cursor_color.g, cursor_color.b, alpha },
|
||||
.glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y },
|
||||
.glyph_size = .{ render.glyph.width, render.glyph.height },
|
||||
.glyph_pos = .{ @intCast(render.glyph.atlas_x), @intCast(render.glyph.atlas_y) },
|
||||
.glyph_size = .{ @intCast(render.glyph.width), @intCast(render.glyph.height) },
|
||||
.bearings = .{
|
||||
@intCast(render.glyph.offset_x),
|
||||
@intCast(render.glyph.offset_y),
|
||||
|
|
@ -3326,8 +3326,8 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||
.atlas = .grayscale,
|
||||
.grid_pos = .{ @intCast(coord.x), @intCast(coord.y) },
|
||||
.color = .{ screen_fg.r, screen_fg.g, screen_fg.b, 255 },
|
||||
.glyph_pos = .{ render.glyph.atlas_x, render.glyph.atlas_y },
|
||||
.glyph_size = .{ render.glyph.width, render.glyph.height },
|
||||
.glyph_pos = .{ @intCast(render.glyph.atlas_x), @intCast(render.glyph.atlas_y) },
|
||||
.glyph_size = .{ @intCast(render.glyph.width), @intCast(render.glyph.height) },
|
||||
.bearings = .{
|
||||
@intCast(render.glyph.offset_x),
|
||||
@intCast(render.glyph.offset_y),
|
||||
|
|
|
|||
|
|
@ -263,8 +263,8 @@ pub const Uniforms = extern struct {
|
|||
|
||||
/// This is a single parameter for the terminal cell shader.
|
||||
pub const CellText = extern struct {
|
||||
glyph_pos: [2]u32 align(8) = .{ 0, 0 },
|
||||
glyph_size: [2]u32 align(8) = .{ 0, 0 },
|
||||
glyph_pos: [2]u16 align(4) = .{ 0, 0 },
|
||||
glyph_size: [2]u16 align(4) = .{ 0, 0 },
|
||||
bearings: [2]i16 align(4) = .{ 0, 0 },
|
||||
grid_pos: [2]u16 align(4),
|
||||
color: [4]u8 align(4),
|
||||
|
|
@ -283,7 +283,7 @@ pub const CellText = extern struct {
|
|||
test {
|
||||
// Minimizing the size of this struct is important,
|
||||
// so we test it in order to be aware of any changes.
|
||||
try std.testing.expectEqual(32, @sizeOf(CellText));
|
||||
try std.testing.expectEqual(24, @sizeOf(CellText));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -232,8 +232,8 @@ pub const Uniforms = extern struct {
|
|||
|
||||
/// This is a single parameter for the terminal cell shader.
|
||||
pub const CellText = extern struct {
|
||||
glyph_pos: [2]u32 align(8) = .{ 0, 0 },
|
||||
glyph_size: [2]u32 align(8) = .{ 0, 0 },
|
||||
glyph_pos: [2]u16 align(4) = .{ 0, 0 },
|
||||
glyph_size: [2]u16 align(4) = .{ 0, 0 },
|
||||
bearings: [2]i16 align(4) = .{ 0, 0 },
|
||||
grid_pos: [2]u16 align(4),
|
||||
color: [4]u8 align(4),
|
||||
|
|
@ -249,11 +249,11 @@ pub const CellText = extern struct {
|
|||
color = 1,
|
||||
};
|
||||
|
||||
// test {
|
||||
// // Minimizing the size of this struct is important,
|
||||
// // so we test it in order to be aware of any changes.
|
||||
// try std.testing.expectEqual(32, @sizeOf(CellText));
|
||||
// }
|
||||
test {
|
||||
// Minimizing the size of this struct is important,
|
||||
// so we test it in order to be aware of any changes.
|
||||
try std.testing.expectEqual(24, @sizeOf(CellText));
|
||||
}
|
||||
};
|
||||
|
||||
/// This is a single parameter for the cell bg shader.
|
||||
|
|
|
|||
|
|
@ -524,13 +524,13 @@ enum CellTextBools : uint8_t {
|
|||
|
||||
struct CellTextVertexIn {
|
||||
// The position of the glyph in the texture (x, y)
|
||||
uint2 glyph_pos [[attribute(0)]];
|
||||
ushort2 glyph_pos [[attribute(0)]];
|
||||
|
||||
// The size of the glyph in the texture (w, h)
|
||||
uint2 glyph_size [[attribute(1)]];
|
||||
ushort2 glyph_size [[attribute(1)]];
|
||||
|
||||
// The left and top bearings for the glyph (x, y)
|
||||
int2 bearings [[attribute(2)]];
|
||||
short2 bearings [[attribute(2)]];
|
||||
|
||||
// The grid coordinates (x, y) where x < columns and y < rows
|
||||
ushort2 grid_pos [[attribute(3)]];
|
||||
|
|
|
|||
Loading…
Reference in New Issue