Skip to content

rust: Port the scene item crop arithmetic in obs-scene.c to obs-scene #1937

Closed

Description

@rdoupe

Unit

Port the scene item crop arithmetic in libobs/obs-scene.c.h / obs-scene.h to rust/obs-scene, in a new module crop, next to extent (#1922). The helpers #1840 made defined on every input are:

  • obs_scene_cropped_size(): the 64-bit crop sum against the source size;
  • obs_scene_scale_crop(): the nested-scene rescale, saturating with NaN mapped to 0;
  • obs_scene_crop_offset();
  • the negative-crop clamp in obs_sceneitem_set_crop().

These stay in C: calc_cx/calc_cy, update_nested_scene_crop (it computes the factors and writes the item), update_item_transform, render_item, the load clamp in scene_load_item, and crop_equal and the change check in the setter.

Plan (one PR)

  1. A behaviour-neutral move of the helpers into libobs/obs-scene-crop.c.h (with its header), with hidden entry points and no EXPORT.
  2. Characterization test_scene_item_crop, with these cases:
    • sums equal to and over the size, and sums past the int range;
    • negative crops through obs_sceneitem_set_crop (clamped);
    • a nested scene that grows and shrinks, through the exported setter and getter;
    • factors that are NaN, ±inf or huge, and crops at INT_MIN/INT_MAX.
  3. RED, then GREEN: the safe Rust core plus shims in a libobs.ported-scene-crop group. The exported symbols are unchanged.
  4. Tier 3 parity against the original C: a proptest over full i32 crops, u32 sizes and any-bit f32 factors, bit-equal. Also a deliberate-break check and port_comparison numbers.

These real-libobs tests must stay green on every lane: test_transform_clipboard, the group tests (test_group_child_drift, test_group_empty_bounds), and the crop tests from #1840.

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions