Commit Graph
5 Commits
Author SHA1 Message Date
Behdad EsfahbodandClaude Opus 4.6 216fb4fb43 [gpu] Refactor demo to virtual renderer interface
Replace backend-specific branches with a demo_renderer_t base class
that both GL and Metal implement. This eliminates all if(metal) checks
in the view code and makes adding future backends (WebGPU) clean.

- Add demo-renderer.h with virtual interface
- Add demo-renderer-gl.cc wrapping existing GL code
- Rewrite demo-metal.mm to implement renderer interface
- Move VBO/VAO management from demo_buffer into GL renderer
- Fix Metal vsync (CAMetalLayer.displaySyncEnabled)
- Fix dark mode crash on Metal (was calling GL directly)
- Add set_background to renderer for clear color control

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 13:42:57 -06:00
Behdad EsfahbodandClaude Opus 4.6 6910b9a3ed [gpu] Add Metal backend for macOS demo
Add MSL shader translations of the Slug GPU text rasterizer, and a
Metal rendering backend for hb-gpu-demo selectable via --metal flag.

Library changes:
- Add HB_GPU_SHADER_LANG_MSL enum value
- Add hb-gpu-vertex.msl and hb-gpu-fragment.msl
- Extend gen-gpu-shader-artifacts.py for MSL

Demo changes:
- Add demo-metal.h/mm with CAMetalLayer rendering
- Add external atlas backend for non-GL paths
- Add demo_buffer_get_vertices for Metal draw path
- Skip GL init when using Metal (GLFW_NO_API)
- Add --metal command-line flag

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 13:36:28 -06:00
Behdad Esfahbod f7d154bc97 Revert "[gpu] Right-align RTL lines to average width"
This reverts commit d87651e02fe44afcb57974b8f807d26462c7469c.
2026-03-28 12:56:20 -06:00
Behdad EsfahbodandClaude Opus 4.6 a41f194bef [gpu] Right-align RTL lines to average width
Detect RTL direction from shaped buffers and right-align those
lines in the demo.  Uses the average width of RTL lines as the
alignment target for a balanced look.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 12:54:26 -06:00
Behdad EsfahbodandClaude Opus 4.6 25e69d9b96 [gpu] Port hb-gpu-demo to options.hh infrastructure
Replace the manual getopt-based demo main with the standard
main_font_text_t / shape_consumer_t composition, getting all
harfbuzz options for free: --variations, --features, --script,
--direction, --face-index, --font-funcs, etc.

New gpu_output_t (in util/gpu-output.hh) implements the output
interface, feeding shaped glyphs to the demo's GL renderer.

Add demo_buffer_add_glyph() and demo_buffer_current_line() to
demo-buffer for glyph-at-a-time insertion (vs the old batch
add_text which did its own shaping).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 16:34:04 -06:00