Skip to content

render: a forced slot larger than the buffer no longer stretches it - #243

Open
sachahjkl wants to merge 1 commit into
bea4dev:mainfrom
sachahjkl:fix/resize-no-stretch
Open

sachahjkl wants to merge 1 commit into
bea4dev:mainfrom
sachahjkl:fix/resize-no-stretch

Conversation

@sachahjkl

Copy link
Copy Markdown
Contributor

Problem

When a window grows faster than its client draws (an interactive resize, for example), the forced slot of the window is larger than the client's last buffer. ClippedSurfaceElement draws a quad that covers the slot, and the texture coordinates map that whole quad onto the buffer. The old buffer is then stretched over the larger slot until the client commits a buffer of the new size. The window content visibly scales during the resize.

Fix

  • backend/clipped_surface.rs: new compute_sample_fit(element, drawn, transform). If the drawn quad differs from the surface's own geometry and the buffer transform is Normal, it returns a scale and an offset so that buffer = quad * scale - offset in 0..1 coordinates. The buffer keeps its own size and position in the quad. The UV compensation now projects onto the surface's own geometry when the fit is enabled, and onto the whole quad otherwise (as before, which handles the 1 px larger quad without blur).
  • New uniforms sample_fit_scale, sample_fit_offset and sample_fit_enabled, registered with the program and set per element. The solid-colour constructor uses a disabled fit.
  • backend/clipped_surface.frag: when the fit is enabled, the sample coordinates are first mapped through the fit, then through the existing compensation. At the end they are clamped to half a texel inside the buffer, so the area past the buffer repeats the buffer's edge texels instead of sampling the other side or blending.

A transformed buffer (rotated or flipped) keeps the old behaviour.

Tests

Unit tests added in clipped_surface.rs:

  • no_fit_when_the_quad_is_the_surface
  • a_grown_slot_keeps_the_buffer_at_its_size
  • a_slot_grown_up_and_left_offsets_the_buffer
  • a_transformed_buffer_is_not_fitted

cargo test --workspace passes, except two tests that also fail on upstream main in our environment: evaluator::tests::embedded_runtime_ipc_does_not_leak_fds_across_reloads and input_method_keyboard_grab_gets_the_keymap_of_the_keys_it_is_sent.

The shader change is not covered by an automated test. It has been running daily in the author's own session (a Windows-7-like desktop on ShojiWM).

… own size: its edge texels fill the rest until the next buffer, instead of the buffer stretched over the slot while a window grows

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant