Skip to main content

Module image_surface

Module image_surface 

Source
Expand description

The image’s own surface (feature wayland): on a Wayland compositor with colour management, the viewport draws its image into a surface of its own, below the window, that the compositor is told the encoding of; egui’s interface stays sRGB on the window’s surface (docs/wayland-colour.md).

Experimental: may change in any release (docs/stability.md).
  • install (once, with eframe’s creation context) joins the compositor through the main window’s handles and records what it offers (Offer): its colour manager’s announcements, the formats and colour spaces a subsurface can be presented in.
  • Every other window gets an image surface of its own, under its own surface and negotiated for what that window wants: set up with its handles (install_window), or the first frame it draws the image once set_window_source says where windows’ handles are read; freed when the window closes (close_window, or at the next frame once egui no longer knows the window). egui’s interface keeps egui-wgpu’s one surface format in every window.
  • Each frame, a window’s viewports negotiate what the application wants for that window (display::want) against its offer (negotiate_window):
    • Route::Tagged: a subsurface egui-pop tags itself through wp_color_management_v1 (BT.2020 with a 2.2 power, for one; KWin, sway, Weston);
    • Route::Wsi: a subsurface presented in a colour space the driver’s window system integration declares (Display P3 where the compositor announces the sRGB transfer: GNOME, Hyprland);
    • Route::Window: the window’s surface, sRGB, and why (display::Resolution::reason).
  • With an image surface, the viewport renders its tiles there, presents it just before egui presents the window (both apply in the same compositor frame), and punches a transparent hole in the interface where the image is: overlays, menus and tooltips drawn after stay above it. The window must be transparent (ViewportBuilder::with_transparent(true)), or the hole would show black.

The EGUI_POP_IMAGE_SURFACE variable turns it off, or keeps the driver’s colour spaces only (no-tag). The debug bridge’s viewport collector reports it (report), with the compositor’s preferred image description for each window; the window registry (windows.list) shows each window’s (egui_pop_core::window_surface).

Re-exports§

pub use egui_pop_wayland::raw_window_handle;

Structs§

Layout
Where an image surface sits for an image rectangle.
Negotiation
Where the image goes for a wanted target, and why not better.
Offer
What the platform offers an image surface.
Options
How install sets up image surfaces.

Enums§

Route
Where the image is drawn.

Constants§

VARIABLE
The environment variable: off (no image surface), no-tag (the driver’s colour spaces only), anything else or unset (both).

Traits§

WindowHandles
A window’s raw handles, as set_window_source gives them.

Functions§

clear_colour
An sRGB colour encoded for a target (the image surface’s background).
close_window
Frees a window’s image surface (the window closed): its subsurfaces and connection go, its state is forgotten. Windows egui no longer knows are freed this way at the next frame.
install
Sets up image surfaces for the main window: rs is the render state the GPU path was installed on (crate::gpu::install), window the main window’s handles (eframe’s creation context). Returns what the platform offers; viewports in the main window use it from the next frame. Other windows get theirs with install_window, or as they draw the image once set_window_source says where their handles are.
install_offer
Records what a window’s platform offers without joining it: no surface is made, only the negotiation and its state (a test’s fake compositor, or a host presenting the image surface itself). The viewport’s widget then sends the image to that surface: use it where something presents it.
install_window
Sets up the image surface of another window (viewport), with its own handles, after install (whose render state it shares): its own parent surface, negotiated for what that window wants. Returns what the platform offers it; it is freed when the window closes (close_window). Without install first, none and why.
layout
The image surface’s place for a rectangle [x0, y0, x1, y1] in window pixels, at scale physical pixels per logical one; None for an empty one.
named_primaries
The protocol’s name for primaries (custom ones have none).
named_transfer
The protocol’s name for a transfer (extended sRGB has none).
negotiate
Where the image goes for wanted, given what the platform offers: the window’s surface for sRGB or without an image surface; else a surface tagged by egui-pop when it may and the compositor takes the encoding; else one in a colour space the driver declares; else the window’s, with why each step failed.
negotiate_window
Where the image of viewport goes for what it wants (display::want): negotiates against that window’s offer when the wish changes, records the image surface’s target and why (display::set_image_surface, and the window’s entry in windows.list). The viewport calls it each frame it draws the image on the GPU path; call it yourself only with an offer from install_offer (tests).
offer
What install found for the main window, if it ran.
offer_of
What the platform offers a window’s image surface, once set up.
report
What the image surfaces of ctx are doing, for the debug bridge: the main window’s at the top level (as before), every window’s in windows.
set_window_source
Says where the handles of a window opened after install are read (egui_pop::api::runner::window on egui-pop’s runner), and how such windows are built (options): a window drawing the image gets its own image surface the first frame its handles are known, freed when it closes. A window whose builder said how it was built (egui_pop_core::window_surface::set_transparency) is taken as said: transparent, it gets a surface whatever options say; opaque, none, with the builder’s reason.
windows
The windows with an image surface set up, the main window first.