wasm: show color atlas in example web app

This commit is contained in:
Mitchell Hashimoto
2022-12-05 21:33:54 -08:00
parent 10f708ee65
commit 41cbc1a323
3 changed files with 19 additions and 6 deletions

View File

@ -42,6 +42,7 @@ fetch(url.href).then(response =>
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_greyscale,
group_cache_atlas_color,
atlas_new, atlas_new,
atlas_free, atlas_free,
atlas_debug_canvas, atlas_debug_canvas,
@ -90,9 +91,17 @@ fetch(url.href).then(response =>
//face_debug_canvas(face); //face_debug_canvas(face);
// Debug our atlas canvas // Debug our atlas canvas
const atlas = group_cache_atlas_greyscale(group_cache); {
const id = atlas_debug_canvas(atlas); const atlas = group_cache_atlas_greyscale(group_cache);
document.getElementById("atlas-canvas").append(zjs.deleteValue(id)); const id = atlas_debug_canvas(atlas);
document.getElementById("atlas-canvas").append(zjs.deleteValue(id));
}
{
const atlas = group_cache_atlas_color(group_cache);
const id = atlas_debug_canvas(atlas);
document.getElementById("atlas-color-canvas").append(zjs.deleteValue(id));
}
//face_free(face); //face_free(face);
}); });

View File

@ -7,9 +7,9 @@
</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 font rendering canvas should show below. This shows a single glyph.</p> <p>The current <b>greyscale</b> font atlas is rendered below.</p>
<div><div id="face-canvas" style="display: inline-block; border: 1px solid red;"></div></div>
<p>The current 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>
<div><div id="atlas-color-canvas" style="display: inline-block; border: 1px solid blue;"></div></div>
</body> </body>
</html> </html>

View File

@ -311,6 +311,10 @@ pub const Wasm = struct {
export fn group_cache_atlas_greyscale(self: *GroupCache) *font.Atlas { export fn group_cache_atlas_greyscale(self: *GroupCache) *font.Atlas {
return &self.atlas_greyscale; return &self.atlas_greyscale;
} }
export fn group_cache_atlas_color(self: *GroupCache) *font.Atlas {
return &self.atlas_color;
}
}; };
test "resize" { test "resize" {