Skip to content

test: Characterize scene bounds placement - #1640

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

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

Conversation

@nathan-v

Copy link
Copy Markdown
Contributor

Refs #1637

What and why

The placement half of calculate_bounds_data moves out of obs-scene.c.h before the Rust port. The scene still resolves absolute versus relative bounds (size_to_absolute needs the scene) and then calls obs_bounds_place. That function fits the scale, aligns the origin, optionally crops, and keeps a flipped item in the box. add_alignment moves with it. Transitions and item alignment still call add_alignment. The declaration in obs-internal.h is unchanged.

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

obs_bounds_place and add_alignment are not exported. test_scene_bounds_place compiles obs-scene-bounds-place.c.h and obs-scene-bounds.c.h and pins the current C, odd cases included. 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):

  • add_alignment uses integer division toward zero. RIGHT wins when LEFT and RIGHT are both set. BOTTOM wins when TOP and BOTTOM are both set. Center is the bit being clear.
  • A non-flipped crop sets that axis of the origin to 0, which drops the alignment just computed for it.
  • A flipped center doubles that origin. A flipped left or top subtracts the diff. The two crop sides are swapped.
  • roundf of 0.5 is 1, half away from zero.
  • The crop threshold is a strict < -0.1. -0.0625 does not crop. -0.25 does, and then rounds to a 0 crop. The sentinel and the origin show the branch ran.
  • The box written back is (uint32_t) of the bounds, so 10.9 becomes 10.
  • OBS_BOUNDS_NONE ignores the crop flag even when both axes overflow. A cropping type takes the width axis when width_diff < -0.1. This test does not feed a negative box into that cast.
  • An empty source keeps its scale (Browser sources breaks Group transformation obsproject/obs-studio#4245). Alignment still runs against the box.
  • Max-only can scale like inner, and it does not crop.
  • Scale-to-height can crop the width. Scale-to-width can crop the height.

RED → GREEN

  • RED commit: none. This is the move and the characterization. The port follows on rust: Port the scene bounds placement in obs-scene.c to obs-scene #1637.
  • 311bb927d libobs: Move scene bounds placement out of obs-scene.c
  • 2f5adc3ca test: Characterize scene bounds placement. test_scene_bounds_place 16/16, compiled -Wall -Wextra -Werror and run under UBSan.
  • The scene unity TU (libobs.core-source) and the new group both compile with the macOS libobs flags (-Werror, -fvisibility=hidden). nm -m shows _add_alignment and _obs_bounds_place as private external. The scene TU references both and does not define them.
  • 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. clang-format 22.1.3 and gersemi 0.25.0 are clean on the changed files. soldr cargo fmt --all --check, workspace clippy -D warnings, and soldr cargo dylint --all -- --workspace --lib --bins passed.
  • ./lint stopped in pre-existing macOS host tests (readelf, -Wl,-soname, /var versus /private/var, Windows facade compiles). 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 (a flag change under cmake/ or build-aux/ runs 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)

calculate_bounds_data still resolves absolute versus relative bounds, which
needs the scene. The fit, alignment, crop and flip that follow it now live
in obs_bounds_place, and add_alignment moved with them. Same behavior. The
Rust port of this unit comes later.
obs_bounds_place and add_alignment are not exported, so the test compiles
the C and pins what it does today, odd cases included. Sixteen cases, and
no display.
@nathan-v
nathan-v requested a review from zackees as a code owner October 21, 2026 18:24
@zackees
zackees enabled auto-merge October 21, 2026 18:25
@zackees
zackees added this pull request to the merge queue Oct 21, 2026
Merged via the queue into obs-rust:master with commit cbb5d87 Oct 21, 2026
25 checks passed
@vpacher vpacher mentioned this pull request Oct 21, 2026
5 tasks done
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