Merge pull request #2087 from qwerasd205/murica

spelling: normalize grey -> gray
This commit is contained in:
Mitchell Hashimoto
2024-08-11 18:03:22 -07:00
committed by GitHub
22 changed files with 120 additions and 116 deletions

View File

@ -51,7 +51,7 @@ fetch(url.href)
group_cache_free, group_cache_free,
group_cache_index_for_codepoint, group_cache_index_for_codepoint,
group_cache_render_glyph, group_cache_render_glyph,
group_cache_atlas_greyscale, group_cache_atlas_grayscale,
group_cache_atlas_color, group_cache_atlas_color,
atlas_new, atlas_new,
atlas_free, atlas_free,
@ -83,7 +83,7 @@ fetch(url.href)
free(config_str.ptr); free(config_str.ptr);
// Create our atlas // Create our atlas
// const atlas = atlas_new(512, 0 /* greyscale */); // const atlas = atlas_new(512, 0 /* grayscale */);
// Create some memory for our string // Create some memory for our string
const font_name = makeStr("monospace"); const font_name = makeStr("monospace");
@ -174,7 +174,7 @@ fetch(url.href)
// Debug our atlas canvas // Debug our atlas canvas
{ {
const atlas = group_cache_atlas_greyscale(group_cache); const atlas = group_cache_atlas_grayscale(group_cache);
const id = atlas_debug_canvas(atlas); const id = atlas_debug_canvas(atlas);
document.getElementById("atlas-canvas").append(zjs.deleteValue(id)); document.getElementById("atlas-canvas").append(zjs.deleteValue(id));
} }

View File

@ -7,7 +7,7 @@
</head> </head>
<body> <body>
<p>Open your console, we are just debugging here.</p> <p>Open your console, we are just debugging here.</p>
<p>The current <b>greyscale</b> font atlas is rendered below.</p> <p>The current <b>grayscale</b> font atlas is rendered below.</p>
<div><div id="atlas-canvas" style="display: inline-block; border: 1px solid green;"></div></div> <div><div id="atlas-canvas" style="display: inline-block; border: 1px solid green;"></div></div>
<p>The current <b>color</b> font atlas is rendered below.</p> <p>The current <b>color</b> font atlas is rendered below.</p>
<div><div id="atlas-color-canvas" style="display: inline-block; border: 1px solid blue;"></div></div> <div><div id="atlas-color-canvas" style="display: inline-block; border: 1px solid blue;"></div></div>

View File

@ -36,7 +36,7 @@ nodes: std.ArrayListUnmanaged(Node) = .{},
/// The format of the texture data being written into the Atlas. This must be /// The format of the texture data being written into the Atlas. This must be
/// uniform for all textures in the Atlas. If you have some textures with /// uniform for all textures in the Atlas. If you have some textures with
/// different formats, you must use multiple atlases or convert the textures. /// different formats, you must use multiple atlases or convert the textures.
format: Format = .greyscale, format: Format = .grayscale,
/// This will be incremented every time the atlas is modified. This is useful /// This will be incremented every time the atlas is modified. This is useful
/// for knowing if the texture data has changed since the last time it was /// for knowing if the texture data has changed since the last time it was
@ -50,13 +50,13 @@ modified: std.atomic.Value(usize) = .{ .raw = 0 },
resized: std.atomic.Value(usize) = .{ .raw = 0 }, resized: std.atomic.Value(usize) = .{ .raw = 0 },
pub const Format = enum(u8) { pub const Format = enum(u8) {
greyscale = 0, grayscale = 0,
rgb = 1, rgb = 1,
rgba = 2, rgba = 2,
pub fn depth(self: Format) u8 { pub fn depth(self: Format) u8 {
return switch (self) { return switch (self) {
.greyscale => 1, .grayscale => 1,
.rgb => 3, .rgb => 3,
.rgba => 4, .rgba => 4,
}; };
@ -396,7 +396,7 @@ pub const Wasm = struct {
// RGBA is the native ImageData format // RGBA is the native ImageData format
.rgba => self.data, .rgba => self.data,
.greyscale => buf: { .grayscale => buf: {
// Convert from A8 to RGBA so every 4th byte is set to a value. // Convert from A8 to RGBA so every 4th byte is set to a value.
var buf: []u8 = try alloc.alloc(u8, self.data.len * 4); var buf: []u8 = try alloc.alloc(u8, self.data.len * 4);
errdefer alloc.free(buf); errdefer alloc.free(buf);
@ -451,7 +451,7 @@ pub const Wasm = struct {
} }
test "happy path" { test "happy path" {
const atlas = atlas_new(512, @intFromEnum(Format.greyscale)).?; const atlas = atlas_new(512, @intFromEnum(Format.grayscale)).?;
defer atlas_free(atlas); defer atlas_free(atlas);
const reg = atlas_reserve(atlas, 2, 2).?; const reg = atlas_reserve(atlas, 2, 2).?;
@ -469,7 +469,7 @@ pub const Wasm = struct {
test "exact fit" { test "exact fit" {
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas = try init(alloc, 34, .greyscale); // +2 for 1px border var atlas = try init(alloc, 34, .grayscale); // +2 for 1px border
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
const modified = atlas.modified.load(.monotonic); const modified = atlas.modified.load(.monotonic);
@ -480,7 +480,7 @@ test "exact fit" {
test "doesnt fit" { test "doesnt fit" {
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas = try init(alloc, 32, .greyscale); var atlas = try init(alloc, 32, .grayscale);
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
// doesn't fit due to border // doesn't fit due to border
@ -489,7 +489,7 @@ test "doesnt fit" {
test "fit multiple" { test "fit multiple" {
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas = try init(alloc, 32, .greyscale); var atlas = try init(alloc, 32, .grayscale);
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
_ = try atlas.reserve(alloc, 15, 30); _ = try atlas.reserve(alloc, 15, 30);
@ -499,7 +499,7 @@ test "fit multiple" {
test "writing data" { test "writing data" {
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas = try init(alloc, 32, .greyscale); var atlas = try init(alloc, 32, .grayscale);
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
const reg = try atlas.reserve(alloc, 2, 2); const reg = try atlas.reserve(alloc, 2, 2);
@ -517,7 +517,7 @@ test "writing data" {
test "grow" { test "grow" {
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas = try init(alloc, 4, .greyscale); // +2 for 1px border var atlas = try init(alloc, 4, .grayscale); // +2 for 1px border
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
const reg = try atlas.reserve(alloc, 2, 2); const reg = try atlas.reserve(alloc, 2, 2);

View File

@ -458,8 +458,8 @@ test "getIndex disabled font style" {
const alloc = testing.allocator; const alloc = testing.allocator;
const testFont = @import("test.zig").fontRegular; const testFont = @import("test.zig").fontRegular;
var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas_greyscale.deinit(alloc); defer atlas_grayscale.deinit(alloc);
var lib = try Library.init(); var lib = try Library.init();
defer lib.deinit(); defer lib.deinit();

View File

@ -44,7 +44,7 @@ glyphs: std.AutoHashMapUnmanaged(GlyphKey, Render) = .{},
/// The texture atlas to store renders in. The Glyph data in the glyphs /// The texture atlas to store renders in. The Glyph data in the glyphs
/// cache is dependent on the atlas matching. /// cache is dependent on the atlas matching.
atlas_greyscale: Atlas, atlas_grayscale: Atlas,
atlas_color: Atlas, atlas_color: Atlas,
/// The underlying resolver for font data, fallbacks, etc. The shared /// The underlying resolver for font data, fallbacks, etc. The shared
@ -77,14 +77,14 @@ pub fn init(
// We need to support loading options since we use the size data // We need to support loading options since we use the size data
assert(resolver.collection.load_options != null); assert(resolver.collection.load_options != null);
var atlas_greyscale = try Atlas.init(alloc, 512, .greyscale); var atlas_grayscale = try Atlas.init(alloc, 512, .grayscale);
errdefer atlas_greyscale.deinit(alloc); errdefer atlas_grayscale.deinit(alloc);
var atlas_color = try Atlas.init(alloc, 512, .rgba); var atlas_color = try Atlas.init(alloc, 512, .rgba);
errdefer atlas_color.deinit(alloc); errdefer atlas_color.deinit(alloc);
var result: SharedGrid = .{ var result: SharedGrid = .{
.resolver = resolver, .resolver = resolver,
.atlas_greyscale = atlas_greyscale, .atlas_grayscale = atlas_grayscale,
.atlas_color = atlas_color, .atlas_color = atlas_color,
.lock = .{}, .lock = .{},
.metrics = undefined, // Loaded below .metrics = undefined, // Loaded below
@ -105,7 +105,7 @@ pub fn init(
pub fn deinit(self: *SharedGrid, alloc: Allocator) void { pub fn deinit(self: *SharedGrid, alloc: Allocator) void {
self.codepoints.deinit(alloc); self.codepoints.deinit(alloc);
self.glyphs.deinit(alloc); self.glyphs.deinit(alloc);
self.atlas_greyscale.deinit(alloc); self.atlas_grayscale.deinit(alloc);
self.atlas_color.deinit(alloc); self.atlas_color.deinit(alloc);
self.resolver.deinit(alloc); self.resolver.deinit(alloc);
} }
@ -272,7 +272,7 @@ pub fn renderGlyph(
// Get the presentation to determine what atlas to use // Get the presentation to determine what atlas to use
const p = try self.resolver.getPresentation(index, glyph_index); const p = try self.resolver.getPresentation(index, glyph_index);
const atlas: *font.Atlas = switch (p) { const atlas: *font.Atlas = switch (p) {
.text => &self.atlas_greyscale, .text => &self.atlas_grayscale,
.emoji => &self.atlas_color, .emoji => &self.atlas_color,
}; };

View File

@ -671,7 +671,7 @@ test {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas = try font.Atlas.init(alloc, 512, .greyscale); var atlas = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
const name = try macos.foundation.String.createWithBytes("Monaco", .utf8, false); const name = try macos.foundation.String.createWithBytes("Monaco", .utf8, false);
@ -735,7 +735,7 @@ test "in-memory" {
const alloc = testing.allocator; const alloc = testing.allocator;
const testFont = @import("../test.zig").fontRegular; const testFont = @import("../test.zig").fontRegular;
var atlas = try font.Atlas.init(alloc, 512, .greyscale); var atlas = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
var lib = try font.Library.init(); var lib = try font.Library.init();
@ -757,7 +757,7 @@ test "variable" {
const alloc = testing.allocator; const alloc = testing.allocator;
const testFont = @import("../test.zig").fontVariable; const testFont = @import("../test.zig").fontVariable;
var atlas = try font.Atlas.init(alloc, 512, .greyscale); var atlas = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
var lib = try font.Library.init(); var lib = try font.Library.init();
@ -779,7 +779,7 @@ test "variable set variation" {
const alloc = testing.allocator; const alloc = testing.allocator;
const testFont = @import("../test.zig").fontVariable; const testFont = @import("../test.zig").fontVariable;
var atlas = try font.Atlas.init(alloc, 512, .greyscale); var atlas = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
var lib = try font.Library.init(); var lib = try font.Library.init();

View File

@ -281,7 +281,7 @@ pub const Face = struct {
// conversion. // conversion.
const format: ?font.Atlas.Format = switch (bitmap_ft.pixel_mode) { const format: ?font.Atlas.Format = switch (bitmap_ft.pixel_mode) {
freetype.c.FT_PIXEL_MODE_MONO => null, freetype.c.FT_PIXEL_MODE_MONO => null,
freetype.c.FT_PIXEL_MODE_GRAY => .greyscale, freetype.c.FT_PIXEL_MODE_GRAY => .grayscale,
freetype.c.FT_PIXEL_MODE_BGRA => .rgba, freetype.c.FT_PIXEL_MODE_BGRA => .rgba,
else => { else => {
log.warn("glyph={} pixel mode={}", .{ glyph_index, bitmap_ft.pixel_mode }); log.warn("glyph={} pixel mode={}", .{ glyph_index, bitmap_ft.pixel_mode });
@ -657,7 +657,7 @@ test {
var lib = try Library.init(); var lib = try Library.init();
defer lib.deinit(); defer lib.deinit();
var atlas = try font.Atlas.init(alloc, 512, .greyscale); var atlas = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
var ft_font = try Face.init( var ft_font = try Face.init(
@ -734,7 +734,7 @@ test "metrics" {
var lib = try Library.init(); var lib = try Library.init();
defer lib.deinit(); defer lib.deinit();
var atlas = try font.Atlas.init(alloc, 512, .greyscale); var atlas = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas.deinit(alloc); defer atlas.deinit(alloc);
var ft_font = try Face.init( var ft_font = try Face.init(

View File

@ -34,12 +34,12 @@ fn genMap() Map {
} }
// Map our converters // Map our converters
result[freetype.c.FT_PIXEL_MODE_MONO].set(.greyscale, monoToGreyscale); result[freetype.c.FT_PIXEL_MODE_MONO].set(.grayscale, monoToGrayscale);
return result; return result;
} }
pub fn monoToGreyscale(alloc: Allocator, bm: Bitmap) Allocator.Error!Bitmap { pub fn monoToGrayscale(alloc: Allocator, bm: Bitmap) Allocator.Error!Bitmap {
var buf = try alloc.alloc(u8, bm.width * bm.rows); var buf = try alloc.alloc(u8, bm.width * bm.rows);
errdefer alloc.free(buf); errdefer alloc.free(buf);
@ -77,7 +77,7 @@ test {
_ = map; _ = map;
} }
test "mono to greyscale" { test "mono to grayscale" {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;
@ -93,7 +93,7 @@ test "mono to greyscale" {
.palette = null, .palette = null,
}; };
const result = try monoToGreyscale(alloc, source); const result = try monoToGrayscale(alloc, source);
defer alloc.free(result.buffer[0..(result.width * result.rows)]); defer alloc.free(result.buffer[0..(result.width * result.rows)]);
try testing.expect(result.pixel_mode == freetype.c.FT_PIXEL_MODE_GRAY); try testing.expect(result.pixel_mode == freetype.c.FT_PIXEL_MODE_GRAY);
try testing.expectEqual(@as(u8, 255), result.buffer[0]); try testing.expectEqual(@as(u8, 255), result.buffer[0]);

View File

@ -203,7 +203,7 @@ pub const Face = struct {
.rgba => render.bitmap, .rgba => render.bitmap,
// Convert down to A8 // Convert down to A8
.greyscale => a8: { .grayscale => a8: {
assert(@mod(render.bitmap.len, 4) == 0); assert(@mod(render.bitmap.len, 4) == 0);
var bitmap_a8 = try alloc.alloc(u8, render.bitmap.len / 4); var bitmap_a8 = try alloc.alloc(u8, render.bitmap.len / 4);
errdefer alloc.free(bitmap_a8); errdefer alloc.free(bitmap_a8);

View File

@ -2726,13 +2726,13 @@ test "all" {
var cp: u32 = 0x2500; var cp: u32 = 0x2500;
const end = 0x2570; const end = 0x2570;
while (cp <= end) : (cp += 1) { while (cp <= end) : (cp += 1) {
var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas_greyscale.deinit(alloc); defer atlas_grayscale.deinit(alloc);
const face: Box = .{ .width = 18, .height = 36, .thickness = 2 }; const face: Box = .{ .width = 18, .height = 36, .thickness = 2 };
const glyph = try face.renderGlyph( const glyph = try face.renderGlyph(
alloc, alloc,
&atlas_greyscale, &atlas_grayscale,
cp, cp,
); );
try testing.expectEqual(@as(u32, face.width), glyph.width); try testing.expectEqual(@as(u32, face.width), glyph.width);

View File

@ -527,13 +527,13 @@ test "all" {
0xE0D4, 0xE0D4,
}; };
for (cps) |cp| { for (cps) |cp| {
var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas_greyscale.deinit(alloc); defer atlas_grayscale.deinit(alloc);
const face: Powerline = .{ .width = 18, .height = 36, .thickness = 2 }; const face: Powerline = .{ .width = 18, .height = 36, .thickness = 2 };
const glyph = try face.renderGlyph( const glyph = try face.renderGlyph(
alloc, alloc,
&atlas_greyscale, &atlas_grayscale,
cp, cp,
); );
try testing.expectEqual(@as(u32, face.width), glyph.width); try testing.expectEqual(@as(u32, face.width), glyph.width);

View File

@ -220,7 +220,7 @@ const WebCanvasImpl = struct {
} }
pub fn writeAtlas(self: *WebCanvasImpl, alloc: Allocator, atlas: *font.Atlas) !font.Atlas.Region { pub fn writeAtlas(self: *WebCanvasImpl, alloc: Allocator, atlas: *font.Atlas) !font.Atlas.Region {
assert(atlas.format == .greyscale); assert(atlas.format == .grayscale);
// Reload our context since we resized the canvas // Reload our context since we resized the canvas
const ctx = try self.context(null); const ctx = try self.context(null);
@ -342,7 +342,7 @@ const PixmanImpl = struct {
/// Write the data in this drawing to the atlas. /// Write the data in this drawing to the atlas.
pub fn writeAtlas(self: *Canvas, alloc: Allocator, atlas: *font.Atlas) !font.Atlas.Region { pub fn writeAtlas(self: *Canvas, alloc: Allocator, atlas: *font.Atlas) !font.Atlas.Region {
assert(atlas.format == .greyscale); assert(atlas.format == .grayscale);
const width = @as(u32, @intCast(self.image.getWidth())); const width = @as(u32, @intCast(self.image.getWidth()));
const height = @as(u32, @intCast(self.image.getHeight())); const height = @as(u32, @intCast(self.image.getHeight()));

View File

@ -215,12 +215,12 @@ test "single" {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas_greyscale.deinit(alloc); defer atlas_grayscale.deinit(alloc);
_ = try renderGlyph( _ = try renderGlyph(
alloc, alloc,
&atlas_greyscale, &atlas_grayscale,
.underline, .underline,
36, 36,
18, 18,
@ -233,12 +233,12 @@ test "strikethrough" {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas_greyscale.deinit(alloc); defer atlas_grayscale.deinit(alloc);
_ = try renderGlyph( _ = try renderGlyph(
alloc, alloc,
&atlas_greyscale, &atlas_grayscale,
.strikethrough, .strikethrough,
36, 36,
18, 18,
@ -251,14 +251,14 @@ test "single large thickness" {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas_greyscale.deinit(alloc); defer atlas_grayscale.deinit(alloc);
// unrealistic thickness but used to cause a crash // unrealistic thickness but used to cause a crash
// https://github.com/mitchellh/ghostty/pull/1548 // https://github.com/mitchellh/ghostty/pull/1548
_ = try renderGlyph( _ = try renderGlyph(
alloc, alloc,
&atlas_greyscale, &atlas_grayscale,
.underline, .underline,
36, 36,
18, 18,
@ -271,12 +271,12 @@ test "curly" {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;
var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale); var atlas_grayscale = try font.Atlas.init(alloc, 512, .grayscale);
defer atlas_greyscale.deinit(alloc); defer atlas_grayscale.deinit(alloc);
_ = try renderGlyph( _ = try renderGlyph(
alloc, alloc,
&atlas_greyscale, &atlas_grayscale,
.underline_curly, .underline_curly,
36, 36,
18, 18,

View File

@ -238,8 +238,8 @@ pub const FrameState = struct {
cells: CellTextBuffer, cells: CellTextBuffer,
cells_bg: CellBgBuffer, cells_bg: CellBgBuffer,
greyscale: objc.Object, // MTLTexture grayscale: objc.Object, // MTLTexture
greyscale_modified: usize = 0, grayscale_modified: usize = 0,
color: objc.Object, // MTLTexture color: objc.Object, // MTLTexture
color_modified: usize = 0, color_modified: usize = 0,
@ -263,12 +263,12 @@ pub const FrameState = struct {
errdefer cells_bg.deinit(); errdefer cells_bg.deinit();
// Initialize our textures for our font atlas. // Initialize our textures for our font atlas.
const greyscale = try initAtlasTexture(device, &.{ const grayscale = try initAtlasTexture(device, &.{
.data = undefined, .data = undefined,
.size = 8, .size = 8,
.format = .greyscale, .format = .grayscale,
}); });
errdefer deinitMTLResource(greyscale); errdefer deinitMTLResource(grayscale);
const color = try initAtlasTexture(device, &.{ const color = try initAtlasTexture(device, &.{
.data = undefined, .data = undefined,
.size = 8, .size = 8,
@ -280,7 +280,7 @@ pub const FrameState = struct {
.uniforms = uniforms, .uniforms = uniforms,
.cells = cells, .cells = cells,
.cells_bg = cells_bg, .cells_bg = cells_bg,
.greyscale = greyscale, .grayscale = grayscale,
.color = color, .color = color,
}; };
} }
@ -289,7 +289,7 @@ pub const FrameState = struct {
self.uniforms.deinit(); self.uniforms.deinit();
self.cells.deinit(); self.cells.deinit();
self.cells_bg.deinit(); self.cells_bg.deinit();
deinitMTLResource(self.greyscale); deinitMTLResource(self.grayscale);
deinitMTLResource(self.color); deinitMTLResource(self.color);
} }
}; };
@ -827,7 +827,7 @@ pub fn setFontGrid(self: *Metal, grid: *font.SharedGrid) void {
// We can modify this without a lock because the GPU does not // We can modify this without a lock because the GPU does not
// touch this data. // touch this data.
for (&self.gpu_state.frames) |*frame| { for (&self.gpu_state.frames) |*frame| {
frame.greyscale_modified = 0; frame.grayscale_modified = 0;
frame.color_modified = 0; frame.color_modified = 0;
} }
@ -1045,10 +1045,10 @@ pub fn updateFrame(
switch (kv.value_ptr.image) { switch (kv.value_ptr.image) {
.ready => {}, .ready => {},
.pending_grey_alpha, .pending_gray_alpha,
.pending_rgb, .pending_rgb,
.pending_rgba, .pending_rgba,
.replace_grey_alpha, .replace_gray_alpha,
.replace_rgb, .replace_rgb,
.replace_rgba, .replace_rgba,
=> try kv.value_ptr.image.upload(self.alloc, self.gpu_state.device), => try kv.value_ptr.image.upload(self.alloc, self.gpu_state.device),
@ -1114,12 +1114,12 @@ pub fn drawFrame(self: *Metal, surface: *apprt.Surface) !void {
// If our font atlas changed, sync the texture data // If our font atlas changed, sync the texture data
texture: { texture: {
const modified = self.font_grid.atlas_greyscale.modified.load(.monotonic); const modified = self.font_grid.atlas_grayscale.modified.load(.monotonic);
if (modified <= frame.greyscale_modified) break :texture; if (modified <= frame.grayscale_modified) break :texture;
self.font_grid.lock.lockShared(); self.font_grid.lock.lockShared();
defer self.font_grid.lock.unlockShared(); defer self.font_grid.lock.unlockShared();
frame.greyscale_modified = self.font_grid.atlas_greyscale.modified.load(.monotonic); frame.grayscale_modified = self.font_grid.atlas_grayscale.modified.load(.monotonic);
try syncAtlasTexture(self.gpu_state.device, &self.font_grid.atlas_greyscale, &frame.greyscale); try syncAtlasTexture(self.gpu_state.device, &self.font_grid.atlas_grayscale, &frame.grayscale);
} }
texture: { texture: {
const modified = self.font_grid.atlas_color.modified.load(.monotonic); const modified = self.font_grid.atlas_color.modified.load(.monotonic);
@ -1571,7 +1571,7 @@ fn drawCellFgs(
void, void,
objc.sel("setFragmentTexture:atIndex:"), objc.sel("setFragmentTexture:atIndex:"),
.{ .{
frame.greyscale.value, frame.grayscale.value,
@as(c_ulong, 0), @as(c_ulong, 0),
}, },
); );
@ -1861,7 +1861,7 @@ fn prepKittyImage(
}; };
const new_image: Image = switch (image.format) { const new_image: Image = switch (image.format) {
.grey_alpha => .{ .pending_grey_alpha = pending }, .gray_alpha => .{ .pending_gray_alpha = pending },
.rgb => .{ .pending_rgb = pending }, .rgb => .{ .pending_rgb = pending },
.rgba => .{ .pending_rgba = pending }, .rgba => .{ .pending_rgba = pending },
.png => unreachable, // should be decoded by now .png => unreachable, // should be decoded by now
@ -2733,7 +2733,7 @@ fn syncAtlasTexture(device: objc.Object, atlas: *const font.Atlas, texture: *obj
fn initAtlasTexture(device: objc.Object, atlas: *const font.Atlas) !objc.Object { fn initAtlasTexture(device: objc.Object, atlas: *const font.Atlas) !objc.Object {
// Determine our pixel format // Determine our pixel format
const pixel_format: mtl.MTLPixelFormat = switch (atlas.format) { const pixel_format: mtl.MTLPixelFormat = switch (atlas.format) {
.greyscale => .r8unorm, .grayscale => .r8unorm,
.rgba => .bgra8unorm, .rgba => .bgra8unorm,
else => @panic("unsupported atlas format for Metal texture"), else => @panic("unsupported atlas format for Metal texture"),
}; };

View File

@ -82,8 +82,8 @@ gl_state: ?GLState = null,
font_grid: *font.SharedGrid, font_grid: *font.SharedGrid,
font_shaper: font.Shaper, font_shaper: font.Shaper,
font_shaper_cache: font.ShaperCache, font_shaper_cache: font.ShaperCache,
texture_greyscale_modified: usize = 0, texture_grayscale_modified: usize = 0,
texture_greyscale_resized: usize = 0, texture_grayscale_resized: usize = 0,
texture_color_modified: usize = 0, texture_color_modified: usize = 0,
texture_color_resized: usize = 0, texture_color_resized: usize = 0,
@ -551,9 +551,9 @@ pub fn displayRealize(self: *OpenGL) !void {
// reflush everything // reflush everything
self.gl_cells_size = 0; self.gl_cells_size = 0;
self.gl_cells_written = 0; self.gl_cells_written = 0;
self.texture_greyscale_modified = 0; self.texture_grayscale_modified = 0;
self.texture_color_modified = 0; self.texture_color_modified = 0;
self.texture_greyscale_resized = 0; self.texture_grayscale_resized = 0;
self.texture_color_resized = 0; self.texture_color_resized = 0;
// We need to reset our uniforms // We need to reset our uniforms
@ -669,8 +669,8 @@ pub fn setFontGrid(self: *OpenGL, grid: *font.SharedGrid) void {
// Reset our font grid // Reset our font grid
self.font_grid = grid; self.font_grid = grid;
self.grid_metrics = grid.metrics; self.grid_metrics = grid.metrics;
self.texture_greyscale_modified = 0; self.texture_grayscale_modified = 0;
self.texture_greyscale_resized = 0; self.texture_grayscale_resized = 0;
self.texture_color_modified = 0; self.texture_color_modified = 0;
self.texture_color_resized = 0; self.texture_color_resized = 0;
@ -1134,7 +1134,7 @@ fn prepKittyImage(
}; };
const new_image: Image = switch (image.format) { const new_image: Image = switch (image.format) {
.grey_alpha => .{ .pending_grey_alpha = pending }, .gray_alpha => .{ .pending_gray_alpha = pending },
.rgb => .{ .pending_rgb = pending }, .rgb => .{ .pending_rgb = pending },
.rgba => .{ .pending_rgba = pending }, .rgba => .{ .pending_rgba = pending },
.png => unreachable, // should be decoded by now .png => unreachable, // should be decoded by now
@ -1912,9 +1912,9 @@ fn flushAtlas(self: *OpenGL) !void {
try flushAtlasSingle( try flushAtlasSingle(
&self.font_grid.lock, &self.font_grid.lock,
gl_state.texture, gl_state.texture,
&self.font_grid.atlas_greyscale, &self.font_grid.atlas_grayscale,
&self.texture_greyscale_modified, &self.texture_grayscale_modified,
&self.texture_greyscale_resized, &self.texture_grayscale_resized,
.red, .red,
.red, .red,
); );
@ -1998,10 +1998,10 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
switch (kv.value_ptr.image) { switch (kv.value_ptr.image) {
.ready => {}, .ready => {},
.pending_grey_alpha, .pending_gray_alpha,
.pending_rgb, .pending_rgb,
.pending_rgba, .pending_rgba,
.replace_grey_alpha, .replace_gray_alpha,
.replace_rgb, .replace_rgb,
.replace_rgba, .replace_rgba,
=> try kv.value_ptr.image.upload(self.alloc), => try kv.value_ptr.image.upload(self.alloc),
@ -2317,12 +2317,12 @@ const GLState = struct {
try texbind.image2D( try texbind.image2D(
0, 0,
.red, .red,
@intCast(font_grid.atlas_greyscale.size), @intCast(font_grid.atlas_grayscale.size),
@intCast(font_grid.atlas_greyscale.size), @intCast(font_grid.atlas_grayscale.size),
0, 0,
.red, .red,
.UnsignedByte, .UnsignedByte,
font_grid.atlas_greyscale.data.ptr, font_grid.atlas_grayscale.data.ptr,
); );
} }

View File

@ -47,13 +47,13 @@ pub const Image = union(enum) {
/// ///
/// This data is owned by this union so it must be freed once the /// This data is owned by this union so it must be freed once the
/// image is uploaded. /// image is uploaded.
pending_grey_alpha: Pending, pending_gray_alpha: Pending,
pending_rgb: Pending, pending_rgb: Pending,
pending_rgba: Pending, pending_rgba: Pending,
/// This is the same as the pending states but there is a texture /// This is the same as the pending states but there is a texture
/// already allocated that we want to replace. /// already allocated that we want to replace.
replace_grey_alpha: Replace, replace_gray_alpha: Replace,
replace_rgb: Replace, replace_rgb: Replace,
replace_rgba: Replace, replace_rgba: Replace,
@ -90,12 +90,12 @@ pub const Image = union(enum) {
pub fn deinit(self: Image, alloc: Allocator) void { pub fn deinit(self: Image, alloc: Allocator) void {
switch (self) { switch (self) {
.pending_grey_alpha => |p| alloc.free(p.dataSlice(2)), .pending_gray_alpha => |p| alloc.free(p.dataSlice(2)),
.pending_rgb => |p| alloc.free(p.dataSlice(3)), .pending_rgb => |p| alloc.free(p.dataSlice(3)),
.pending_rgba => |p| alloc.free(p.dataSlice(4)), .pending_rgba => |p| alloc.free(p.dataSlice(4)),
.unload_pending => |data| alloc.free(data), .unload_pending => |data| alloc.free(data),
.replace_grey_alpha => |r| { .replace_gray_alpha => |r| {
alloc.free(r.pending.dataSlice(2)); alloc.free(r.pending.dataSlice(2));
r.texture.msgSend(void, objc.sel("release"), .{}); r.texture.msgSend(void, objc.sel("release"), .{});
}, },
@ -130,10 +130,10 @@ pub const Image = union(enum) {
=> return, => return,
.ready => |obj| .{ .unload_ready = obj }, .ready => |obj| .{ .unload_ready = obj },
.pending_grey_alpha => |p| .{ .unload_pending = p.dataSlice(2) }, .pending_gray_alpha => |p| .{ .unload_pending = p.dataSlice(2) },
.pending_rgb => |p| .{ .unload_pending = p.dataSlice(3) }, .pending_rgb => |p| .{ .unload_pending = p.dataSlice(3) },
.pending_rgba => |p| .{ .unload_pending = p.dataSlice(4) }, .pending_rgba => |p| .{ .unload_pending = p.dataSlice(4) },
.replace_grey_alpha => |r| .{ .unload_replace = .{ .replace_gray_alpha => |r| .{ .unload_replace = .{
r.pending.dataSlice(2), r.texture, r.pending.dataSlice(2), r.texture,
} }, } },
.replace_rgb => |r| .{ .unload_replace = .{ .replace_rgb => |r| .{ .unload_replace = .{
@ -160,7 +160,7 @@ pub const Image = union(enum) {
const existing: objc.Object = switch (self.*) { const existing: objc.Object = switch (self.*) {
// For pending, we can free the old data and become pending // For pending, we can free the old data and become pending
// ourselves. // ourselves.
.pending_grey_alpha => |p| { .pending_gray_alpha => |p| {
alloc.free(p.dataSlice(2)); alloc.free(p.dataSlice(2));
self.* = img; self.* = img;
return; return;
@ -194,7 +194,7 @@ pub const Image = union(enum) {
// If we were already pending a replacement, then we free our // If we were already pending a replacement, then we free our
// existing pending data and use the same texture. // existing pending data and use the same texture.
.replace_grey_alpha => |r| existing: { .replace_gray_alpha => |r| existing: {
alloc.free(r.pending.dataSlice(2)); alloc.free(r.pending.dataSlice(2));
break :existing r.texture; break :existing r.texture;
}, },
@ -217,7 +217,7 @@ pub const Image = union(enum) {
// We now have an existing texture, so set the proper replace key. // We now have an existing texture, so set the proper replace key.
self.* = switch (img) { self.* = switch (img) {
.pending_grey_alpha => |p| .{ .replace_grey_alpha = .{ .pending_gray_alpha => |p| .{ .replace_gray_alpha = .{
.texture = existing, .texture = existing,
.pending = p, .pending = p,
} }, } },
@ -290,7 +290,7 @@ pub const Image = union(enum) {
}, },
// GA needs to be converted to RGBA, too. // GA needs to be converted to RGBA, too.
.pending_grey_alpha => |*p| { .pending_gray_alpha => |*p| {
const data = p.dataSlice(2); const data = p.dataSlice(2);
const rgba = try gaToRgba(alloc, data); const rgba = try gaToRgba(alloc, data);
alloc.free(data); alloc.free(data);
@ -298,7 +298,7 @@ pub const Image = union(enum) {
self.* = .{ .pending_rgba = p.* }; self.* = .{ .pending_rgba = p.* };
}, },
.replace_grey_alpha => |*r| { .replace_gray_alpha => |*r| {
const data = r.pending.dataSlice(2); const data = r.pending.dataSlice(2);
const rgba = try gaToRgba(alloc, data); const rgba = try gaToRgba(alloc, data);
alloc.free(data); alloc.free(data);

View File

@ -45,13 +45,13 @@ pub const Image = union(enum) {
/// ///
/// This data is owned by this union so it must be freed once the /// This data is owned by this union so it must be freed once the
/// image is uploaded. /// image is uploaded.
pending_grey_alpha: Pending, pending_gray_alpha: Pending,
pending_rgb: Pending, pending_rgb: Pending,
pending_rgba: Pending, pending_rgba: Pending,
/// This is the same as the pending states but there is a texture /// This is the same as the pending states but there is a texture
/// already allocated that we want to replace. /// already allocated that we want to replace.
replace_grey_alpha: Replace, replace_gray_alpha: Replace,
replace_rgb: Replace, replace_rgb: Replace,
replace_rgba: Replace, replace_rgba: Replace,
@ -88,12 +88,12 @@ pub const Image = union(enum) {
pub fn deinit(self: Image, alloc: Allocator) void { pub fn deinit(self: Image, alloc: Allocator) void {
switch (self) { switch (self) {
.pending_grey_alpha => |p| alloc.free(p.dataSlice(2)), .pending_gray_alpha => |p| alloc.free(p.dataSlice(2)),
.pending_rgb => |p| alloc.free(p.dataSlice(3)), .pending_rgb => |p| alloc.free(p.dataSlice(3)),
.pending_rgba => |p| alloc.free(p.dataSlice(4)), .pending_rgba => |p| alloc.free(p.dataSlice(4)),
.unload_pending => |data| alloc.free(data), .unload_pending => |data| alloc.free(data),
.replace_grey_alpha => |r| { .replace_gray_alpha => |r| {
alloc.free(r.pending.dataSlice(2)); alloc.free(r.pending.dataSlice(2));
r.texture.destroy(); r.texture.destroy();
}, },
@ -128,10 +128,10 @@ pub const Image = union(enum) {
=> return, => return,
.ready => |obj| .{ .unload_ready = obj }, .ready => |obj| .{ .unload_ready = obj },
.pending_grey_alpha => |p| .{ .unload_pending = p.dataSlice(2) }, .pending_gray_alpha => |p| .{ .unload_pending = p.dataSlice(2) },
.pending_rgb => |p| .{ .unload_pending = p.dataSlice(3) }, .pending_rgb => |p| .{ .unload_pending = p.dataSlice(3) },
.pending_rgba => |p| .{ .unload_pending = p.dataSlice(4) }, .pending_rgba => |p| .{ .unload_pending = p.dataSlice(4) },
.replace_grey_alpha => |r| .{ .unload_replace = .{ .replace_gray_alpha => |r| .{ .unload_replace = .{
r.pending.dataSlice(2), r.texture, r.pending.dataSlice(2), r.texture,
} }, } },
.replace_rgb => |r| .{ .unload_replace = .{ .replace_rgb => |r| .{ .unload_replace = .{
@ -157,7 +157,7 @@ pub const Image = union(enum) {
// the self pointer directly. // the self pointer directly.
const existing: gl.Texture = switch (self.*) { const existing: gl.Texture = switch (self.*) {
// For pending, we can free the old data and become pending ourselves. // For pending, we can free the old data and become pending ourselves.
.pending_grey_alpha => |p| { .pending_gray_alpha => |p| {
alloc.free(p.dataSlice(2)); alloc.free(p.dataSlice(2));
self.* = img; self.* = img;
return; return;
@ -191,7 +191,7 @@ pub const Image = union(enum) {
// If we were already pending a replacement, then we free our // If we were already pending a replacement, then we free our
// existing pending data and use the same texture. // existing pending data and use the same texture.
.replace_grey_alpha => |r| existing: { .replace_gray_alpha => |r| existing: {
alloc.free(r.pending.dataSlice(2)); alloc.free(r.pending.dataSlice(2));
break :existing r.texture; break :existing r.texture;
}, },
@ -214,7 +214,7 @@ pub const Image = union(enum) {
// We now have an existing texture, so set the proper replace key. // We now have an existing texture, so set the proper replace key.
self.* = switch (img) { self.* = switch (img) {
.pending_grey_alpha => |p| .{ .replace_grey_alpha = .{ .pending_gray_alpha => |p| .{ .replace_gray_alpha = .{
.texture = existing, .texture = existing,
.pending = p, .pending = p,
} }, } },
@ -246,7 +246,7 @@ pub const Image = union(enum) {
=> true, => true,
.ready, .ready,
.pending_grey_alpha, .pending_gray_alpha,
.pending_rgb, .pending_rgb,
.pending_rgba, .pending_rgba,
=> false, => false,
@ -288,7 +288,7 @@ pub const Image = union(enum) {
}, },
// GA needs to be converted to RGBA, too. // GA needs to be converted to RGBA, too.
.pending_grey_alpha => |*p| { .pending_gray_alpha => |*p| {
const data = p.dataSlice(2); const data = p.dataSlice(2);
const rgba = try gaToRgba(alloc, data); const rgba = try gaToRgba(alloc, data);
alloc.free(data); alloc.free(data);
@ -296,7 +296,7 @@ pub const Image = union(enum) {
self.* = .{ .pending_rgba = p.* }; self.* = .{ .pending_rgba = p.* };
}, },
.replace_grey_alpha => |*r| { .replace_gray_alpha => |*r| {
const data = r.pending.dataSlice(2); const data = r.pending.dataSlice(2);
const rgba = try gaToRgba(alloc, data); const rgba = try gaToRgba(alloc, data);
alloc.free(data); alloc.free(data);

View File

@ -304,7 +304,7 @@ vertex CellTextVertexOut cell_text_vertex(
fragment float4 cell_text_fragment( fragment float4 cell_text_fragment(
CellTextVertexOut in [[stage_in]], CellTextVertexOut in [[stage_in]],
texture2d<float> textureGreyscale [[texture(0)]], texture2d<float> textureGrayscale [[texture(0)]],
texture2d<float> textureColor [[texture(1)]] texture2d<float> textureColor [[texture(1)]]
) { ) {
constexpr sampler textureSampler( constexpr sampler textureSampler(
@ -325,7 +325,7 @@ fragment float4 cell_text_fragment(
float4 premult = float4(in.color.rgb * in.color.a, in.color.a); float4 premult = float4(in.color.rgb * in.color.a, in.color.a);
// Then premult the texture color // Then premult the texture color
float a = textureGreyscale.sample(textureSampler, in.tex_coord).r; float a = textureGrayscale.sample(textureSampler, in.tex_coord).r;
premult = premult * a; premult = premult * a;
return premult; return premult;

View File

@ -31,7 +31,7 @@ pub const default: Palette = default: {
} }
} }
// Grey ramp // Gray ramp
assert(i == 232); assert(i == 232);
assert(@TypeOf(i) == u8); assert(@TypeOf(i) == u8);
while (i > 0) : (i +%= 1) { while (i > 0) : (i +%= 1) {

View File

@ -367,11 +367,11 @@ pub const Transmission = struct {
// The following are not supported directly via the protocol // The following are not supported directly via the protocol
// but they are formats that a png may decode to that we // but they are formats that a png may decode to that we
// support. // support.
grey_alpha, gray_alpha,
pub fn bpp(self: Format) u8 { pub fn bpp(self: Format) u8 {
return switch (self) { return switch (self) {
.grey_alpha => 2, .gray_alpha => 2,
.rgb => 3, .rgb => 3,
.rgba => 4, .rgba => 4,
.png => unreachable, // Must be validated before .png => unreachable, // Must be validated before

View File

@ -145,7 +145,7 @@ pub const LoadingImage = struct {
.png => stat_size, .png => stat_size,
// For these formats we have a size we must have. // For these formats we have a size we must have.
.grey_alpha, .rgb, .rgba => |f| size: { .gray_alpha, .rgb, .rgba => |f| size: {
const bpp = f.bpp(); const bpp = f.bpp();
break :size self.image.width * self.image.height * bpp; break :size self.image.width * self.image.height * bpp;
}, },
@ -447,7 +447,7 @@ pub const LoadingImage = struct {
self.image.width = @intCast(width); self.image.width = @intCast(width);
self.image.height = @intCast(height); self.image.height = @intCast(height);
self.image.format = switch (bpp) { self.image.format = switch (bpp) {
2 => .grey_alpha, 2 => .gray_alpha,
3 => .rgb, 3 => .rgb,
4 => .rgba, 4 => .rgba,
else => unreachable, // validated above else => unreachable, // validated above

View File

@ -4,6 +4,8 @@ extend-exclude = [
"pkg/*", "pkg/*",
"src/stb/*", "src/stb/*",
"*.xib", "*.xib",
# "grey" color names are valid
"src/terminal/res/rgb.txt",
# Do not self-check # Do not self-check
"typos.toml", "typos.toml",
# Fonts # Fonts
@ -36,6 +38,8 @@ iterm = "iterm"
ACCES = "ACCES" ACCES = "ACCES"
wdth = "wdth" wdth = "wdth"
Strat = "Strat" Strat = "Strat"
grey = "gray"
greyscale = "grayscale"
[type.swift.extend-words] [type.swift.extend-words]
inout = "inout" inout = "inout"