Skip to content

test: Characterize scene coordinate conversion - #1647

Merged
zackees merged 2 commits into
obs-rust:masterfrom
nathan-v:test/scene-coords
Oct 21, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
nathan-v:test/scene-coords

Conversation

@nathan-v

Copy link
Copy Markdown
Contributor

Refs #1645

What and why

The absolute and relative conversion in obs-scene.c.h moves out before the Rust port. Position, size, the half-pixel nudge, and the canvas scale go into obs-scene-coords.c.h. The scene still reads the canvas with get_scene_dimensions. It still decides whether to nudge, and whether a group or a nested scene keeps its scale. calculate_bounds_data is unchanged. It still calls size_to_absolute when the bounds are relative.

The new file is its own unity group, libobs.scene-coords, on LIBOBS_SOURCES. It stays C. The port, later, moves the include into a ported group.

The new symbols are not exported. test_scene_coords compiles obs-scene-coords.c.h and pins the current C. No display. It characterizes that C source, so a later Rust swap stays invisible until the symbols are reachable from the test.

Characterized, not endorsed (comments in the test):

  • The nudge is floor(v * 2 + 0.5) / 2. A value already on a half stays. 0.25 goes to 0.5 and 0.75 goes to 1. -0.25 goes to 0 and -0.75 goes to -0.5, so a negative tie does not mirror the positive one.
  • pos_from_absolute and size_from_absolute do not nudge. A nudged pixel value does not come back to the relative value that produced it.
  • Size conversion uses the canvas height only. The wrapper still reads the width, the way the old code did, and then ignores it.
  • A group, or an item whose parent is a group, skips the nudge. A group or a nested scene keeps its scale and never divides by the canvas height.

RED → GREEN

  • RED commit: none. This is the move and the characterization. The port follows on rust: Port the scene coordinate conversion in obs-scene.c to obs-scene #1645.
  • 6e6338361 libobs: Move scene coordinate conversion out
  • eacf1b7f1 test: Characterize scene coordinate conversion. test_scene_coords 8/8, compiled -Wall -Wextra -Werror and run under UBSan.
  • A scratch differential of the old expressions against the new functions compared 43904 values and found 0 mismatches, also under UBSan. That harness is not in the tree.
  • The scene unity TU (libobs.core-source) and the new group both compile with the macOS libobs flags (-Werror, -fvisibility=hidden). nm -m shows the nine new symbols as private external. The scene TU references eight of them and does not define them. obs_scene_nudge_abs is only called from inside the new file.
  • ci/test_build_groups.py, ci/test_ported_sources.py, ci/test_naming.py, ci/test_platform_ifdef_ratchet.py and ci/test_cmocka_sanitize.py passed (50 tests). clang-format 22.1.3 and gersemi 0.25.0 are clean on the changed files.
  • ./lint was not run. On this Mac it stops in pre-existing host tests (readelf, -Wl,-soname, /var versus /private/var). No stamp. Docker Tier 2 was not run here. PR CI runs it.
  • Real app: no behavior change.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (this is the extraction and its characterization; the port follows)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable: no flag change)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): not applicable (no port here)

The absolute and relative conversion is the next piece after
bounds placement. pos and size, the half-pixel nudge, and the
canvas scale move into obs-scene-coords.c.h.

The scene still reads the canvas. It still decides whether to
nudge, and whether a group or nested scene keeps its scale.
No behavior change. The new symbols are hidden.
test_scene_coords compiles obs-scene-coords.c.h on its own and
pins the current C, including the half-pixel nudge. No display.
@nathan-v
nathan-v requested a review from zackees as a code owner October 21, 2026 19:29
@zackees
zackees added this pull request to the merge queue Oct 21, 2026
Merged via the queue into obs-rust:master with commit f3e6260 Oct 21, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants