feat: xorg viewer scale modes, resize fix, arch notes

Scale modes (STRETCH/FIT/FILL/1:1) with CENTER/TOP_LEFT anchor:
- UV crop via u_uv_scale/u_uv_offset uniforms in vertex shader
- glViewport sub-rect + glClear for FIT and 1:1 modes
- xorg_viewer_set_scale() / xorg_viewer_set_anchor() setters
- Stub implementations for both

Resize fix: glfwSetWindowUserPointer + framebuffer_size_callback calls
render() synchronously during resize so image tracks window edge
immediately. Forward declaration added to fix implicit decl error.

Q/Escape close the window via key_callback.

xorg_cli: --scale and --anchor arguments added.

architecture.md:
- Scale mode table and anchor docs in Frame Viewer Sink section
- Render loop design note: frame-driven not timer-driven, resize callback
  rationale, threading note (GL context ownership, frame queue)
- Text overlay section: tier 1 bitmap atlas (Pillow build tool, skyline
  packing, quad rendering), tier 2 HarfBuzz+FreeType, migration path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-28 21:30:28 +00:00
parent ef0319b45b
commit 7fd79e6120
6 changed files with 413 additions and 56 deletions

View File

@@ -11,6 +11,7 @@ DISCOVERY_OBJ = $(BUILD)/discovery/discovery.o
CONFIG_OBJ = $(BUILD)/config/config.o
PROTOCOL_OBJ = $(BUILD)/protocol/protocol.o
TEST_IMAGE_OBJ = $(BUILD)/test_image/test_image.o
XORG_OBJ = $(BUILD)/xorg/xorg.o
CLI_SRCS = \
media_ctrl_cli.c \
@@ -20,7 +21,8 @@ CLI_SRCS = \
config_cli.c \
protocol_cli.c \
query_cli.c \
test_image_cli.c
test_image_cli.c \
xorg_cli.c
CLI_OBJS = $(CLI_SRCS:%.c=$(CLI_BUILD)/%.o)
@@ -34,7 +36,8 @@ all: \
$(CLI_BUILD)/config_cli \
$(CLI_BUILD)/protocol_cli \
$(CLI_BUILD)/query_cli \
$(CLI_BUILD)/test_image_cli
$(CLI_BUILD)/test_image_cli \
$(CLI_BUILD)/xorg_cli
# Module objects delegate to their sub-makes.
$(COMMON_OBJ): ; $(MAKE) -C $(ROOT)/src/modules/common
@@ -46,6 +49,7 @@ $(DISCOVERY_OBJ): ; $(MAKE) -C $(ROOT)/src/modules/discovery
$(CONFIG_OBJ): ; $(MAKE) -C $(ROOT)/src/modules/config
$(PROTOCOL_OBJ): ; $(MAKE) -C $(ROOT)/src/modules/protocol
$(TEST_IMAGE_OBJ): ; $(MAKE) -C $(ROOT)/src/modules/test_image
$(XORG_OBJ): ; $(MAKE) -C $(ROOT)/src/modules/xorg
# Compile each CLI source to its own .o (generates .d alongside).
$(CLI_BUILD)/%.o: %.c | $(CLI_BUILD)
@@ -76,6 +80,9 @@ $(CLI_BUILD)/query_cli: $(CLI_BUILD)/query_cli.o $(COMMON_OBJ) $(SERIAL_OBJ) $(T
$(CLI_BUILD)/test_image_cli: $(CLI_BUILD)/test_image_cli.o $(TEST_IMAGE_OBJ)
$(CC) $(CFLAGS) -o $@ $^
$(CLI_BUILD)/xorg_cli: $(CLI_BUILD)/xorg_cli.o $(TEST_IMAGE_OBJ) $(XORG_OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(PKG_LDFLAGS)
$(CLI_BUILD):
mkdir -p $@
@@ -90,6 +97,7 @@ clean:
$(CLI_BUILD)/config_cli \
$(CLI_BUILD)/protocol_cli \
$(CLI_BUILD)/query_cli \
$(CLI_BUILD)/test_image_cli
$(CLI_BUILD)/test_image_cli \
$(CLI_BUILD)/xorg_cli
-include $(CLI_OBJS:%.o=%.d)