Add Device::present_bound_surface API#361
Merged
Merged
Conversation
In order to present a widget surface that is bound to a context, a user of `surfman` must currently: - Unbind the surface - Present the surface - Rebind the surface On EGL platforms unbinding the surface calls: ``` eglMakeCurrent(egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_context); ``` The expected resize story for Wayland is: 1. The server calls the application's `configure` callback with the new window size. 2. The application calls `wl_egl_window_resize`. 3. The application waits for the next frame callback. 4. The application redraws into the surface at the new size. Notably, `wl_egl_window_resize` *does not* resize the surface immediately. Resizing happens later in a driver-defined way. In Servo we handle this by: 1. Receiving the `winit` resize signal. 2. Unbinding the surface (calls `eglMakeCurrent` with `NO_SURFACE` values). 3. Resizing the surface (calls `wl_egl_window_resize`) 4. Rebinding the surface. 5. Waiting for the redraw signal from `winit` (presumably triggered by the Wayland frame callback). 6. Repainting the contents at the new size using OpenGL. 7. Unbinding the surface 8. Presenting the surface (calls `eglSwapBuffers`) 9. Rebinding the surface Either calling `eglMakeCurrent` before calling `eglSwapBuffers` or calling `eglSwapBuffers` with no surface boudn, means that the driver is failing to properly resize the surface after `wl_egl_window_resize`. In general, constantly having to call `eglMakeCurrent` multiple times in order to call `eglSwapBuffers` is both disruptive and not how typical OpenGL applications work. So this change adds a way to present the surface without having to first unbind it from the context. A followup change will address resizing. It does make any changes to existing APIs. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
0092623 to
30799c3
Compare
jdm
approved these changes
Jun 5, 2026
mrobinson
added a commit
to mrobinson/surfman
that referenced
this pull request
Jun 7, 2026
Much like servo#361, this change adds a `Device::resize_bound_surface` API so that widget surfaces can be resized without introducing a spurious `eglMakeCurrent` with `NO_SURFACE`. This will greatly improve resizing behavior in Servo. Signed-off-by: Martin Robinson <martin@abandonedwig.info>
mrobinson
added a commit
to mrobinson/surfman
that referenced
this pull request
Jun 7, 2026
Much like servo#361, this change adds a `Device::resize_bound_surface` API so that widget surfaces can be resized without introducing a spurious `eglMakeCurrent` with `NO_SURFACE`. This will greatly improve resizing behavior in Servo. Signed-off-by: Martin Robinson <martin@abandonedwig.info>
mrobinson
added a commit
to mrobinson/surfman
that referenced
this pull request
Jun 7, 2026
Much like servo#361, this change adds a `Device::resize_bound_surface` API so that widget surfaces can be resized without introducing a spurious `eglMakeCurrent` with `NO_SURFACE`. This will greatly improve resizing behavior in Servo. Signed-off-by: Martin Robinson <martin@abandonedwig.info>
mrobinson
added a commit
to mrobinson/surfman
that referenced
this pull request
Jun 7, 2026
Much like servo#361, this change adds a `Device::resize_bound_surface` API so that widget surfaces can be resized without introducing a spurious `eglMakeCurrent` with `NO_SURFACE`. This will greatly improve resizing behavior in Servo. Signed-off-by: Martin Robinson <martin@abandonedwig.info>
mrobinson
added a commit
to mrobinson/surfman
that referenced
this pull request
Jun 7, 2026
Much like servo#361, this change adds a `Device::resize_bound_surface` API so that widget surfaces can be resized without introducing a spurious `eglMakeCurrent` with `NO_SURFACE`. This will greatly improve resizing behavior in Servo. Signed-off-by: Martin Robinson <martin@abandonedwig.info>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In order to present a widget surface that is bound to a context, a user
of
surfmanmust currently:On EGL platforms unbinding the surface calls:
The expected resize story for Wayland is:
configurecallback with the newwindow size.
wl_egl_window_resize.Notably,
wl_egl_window_resizedoes not resize the surfaceimmediately. Resizing happens later in a driver-defined way.
In Servo we handle this by:
winitresize signal.eglMakeCurrentwithNO_SURFACEvalues).
wl_egl_window_resize)winit(presumably triggered bythe Wayland frame callback).
eglSwapBuffers)Either calling
eglMakeCurrentbefore callingeglSwapBuffersorcalling
eglSwapBufferswith no surface bound, means that the driver isfailing to properly resize the surface after
wl_egl_window_resize. Ingeneral, constantly having to call
eglMakeCurrentmultiple times inorder to call
eglSwapBuffersis both disruptive and not how typicalOpenGL applications work.
So this change adds a way to present the surface without having to first
unbind it from the context. A followup change will address resizing. It
does not make any changes to existing APIs.