Skip to content

libvncclient: add framebuffer viewport mode#722

Open
marcofortina wants to merge 1 commit into
LibVNC:masterfrom
marcofortina:feature/libvncclient-framebuffer-viewport
Open

libvncclient: add framebuffer viewport mode#722
marcofortina wants to merge 1 commit into
LibVNC:masterfrom
marcofortina:feature/libvncclient-framebuffer-viewport

Conversation

@marcofortina
Copy link
Copy Markdown
Contributor

@marcofortina marcofortina commented May 17, 2026

Summary

Adds an opt-in LibVNCClient framebuffer viewport mode for applications that only
want to keep a sub-rectangle of the remote framebuffer locally instead of
allocating the full remote framebuffer.

Changes

  • Add rfbClientSetFrameBufferViewport(client, x, y, w, h).
  • Add rfbClientClearFrameBufferViewport(client).
  • Store the viewport in rfbClient in remote framebuffer coordinates.
  • Use the viewport as the default update rectangle.
  • Allocate only viewport_w * viewport_h pixels in the default framebuffer allocator.
  • Clip the default Raw/Fill drawing callbacks to the local viewport buffer.
  • Keep CopyRect safe by not requesting CopyRect by default in viewport mode and by ignoring CopyRect operations whose source/destination are outside the local viewport.
  • Limit default encoding negotiation in viewport mode to viewport-safe encodings: Hextile, CoRRE, RRE and Raw.
  • Reject changing or clearing the viewport after client->frameBuffer has already been allocated, because the framebuffer size/stride has already been chosen.
  • Document the lifecycle and callback limitations in the public API comments.
  • Add client_viewporttest covering invalid viewport rejection, update rectangle setup, reduced framebuffer drawing/clipping, and post-allocation lifecycle guards.

Validation

Recommended local validation before merge:

git diff --check

rm -rf build-8-patch
cmake -S . -B build-8-patch \
  -DWITH_EXAMPLES=OFF \
  -DWITH_TESTS=ON \
  -DWITH_OPENSSL=OFF \
  -DWITH_GNUTLS=OFF \
  -DWITH_GCRYPT=OFF \
  -DWITH_SDL=OFF \
  -DWITH_GTK=OFF \
  -DWITH_QT=OFF \
  -DWITH_FFMPEG=OFF \
  -DWITH_XCB=OFF \
  -DWITH_LIBSSHTUNNEL=OFF \
  -DWITH_SYSTEMD=OFF \
  -DWITH_JPEG=OFF \
  -DCMAKE_BUILD_TYPE=Debug
cmake --build build-8-patch --parallel 1
ctest --test-dir build-8-patch --output-on-failure

Notes

This feature is intentionally conservative. It is meant for applications that
use LibVNCClient's default framebuffer allocator and default drawing callbacks.
Applications that override drawing callbacks such as GotBitmap, GotFillRect
or GotCopyRect must apply the same remote-to-local viewport mapping in their
own callbacks.

The viewport must be configured before rfbClientInitialise() or before any
application-provided framebuffer allocation. Changing it after framebuffer
allocation is rejected to avoid making the local framebuffer size/stride
inconsistent with the requested update rectangle.

Closes #8.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support partial frame buffers

2 participants