aboutsummaryrefslogtreecommitdiff
path: root/render.h (unfollow)
Commit message (Collapse)AuthorLines
2026-02-02wayland: wait for pre-apply damage thread before destroying a terminal instanceDaniel Eklöf-0/+1
It's possible, but unlikely, that we've pushed a "pre-apply damage" job to the renderer thread queue (or that we've pushed it, and the a thread is now working on it) when we shutdown a terminal instance. This is sometimes caught in an assertion in term_destroy(), where we check the queue length is 0. Other times, or in release builds, we might crash in the thread, or in the shutdown logic when freeing the buffer chains associated with the terminal instance. Fix by ensuring there's no pre-apply damage operation queued, or running, before shutting down a terminal instance. Closes #2263
2025-10-10render: when double-buffering, pre-apply previous frame's damage earlyDaniel Eklöf-0/+2
Foot likes it when compositor releases buffer immediately, as that means we only have to re-render the cells that have changed since the last frame. For various reasons, not all compositors do this. In this case, foot is typically forced to switch between two buffers, i.e. double-buffer. In this case, each frame starts with copying over the damage from the previous frame, to the new frame. Then we start rendering the updated cells. Bringing over the previous frame's damage can be slow, if the changed area was large (e.g. when scrolling one or a few lines, or on full screen updates). It's also done single-threaded. Thus it not only slows down frame rendering, but pauses everything else (i.e. input processing). All in all, it reduces performance and increases input latency. But we don't have to wait until it's time to render a frame to copy over the previous frame's damage. We can do that as soon as the compositor has released the buffer (for the frame _before_ the previous frame). And we can do this in a thread. This frees up foot to continue processing input, and reduces frame rendering time since we can now start rendering the modified cells immediately, without first doing a large memcpy(3). In worst case scenarios (or perhaps we should consider them best case scenarios...), I've seen up to a 10x performance increase in frame rendering times (this obviously does *not* include the time it takes to copy over the previous frame's damage, since that doesn't affect neither input processing nor frame rendering). Implemented by adding a callback mechanism to the shm abstraction layer. Use it for the grid buffers, and kick off a thread that copies the previous frame's damage, and resets the buffers age to 0 (so that foot understands it can start render to it immediately when it later needs to render a frame). Since we have certain way of knowing if a compositor releases buffers immediately or not, use a bit of heuristics; if we see 10 consecutive non-immediate releases (that is, we reset the counter as soon as we do see an immediate release), this new "pre-apply damage" logic is enabled. It can be force-disabled with tweak.pre-apply-damage=no. We also need to take care to wait for the thread before resetting the render's "last_buf" pointer (or we'll SEGFAULT in the thread...). We must also ensure we wait for the thread to finish before we start rendering a new frame. Under normal circumstances, the wait time is always 0, the thread has almost always finished long before we need to render the next frame. But it _can_ happen. Closes #2188
2025-05-01config: tweak.surface-bit-depth now defaults to 'auto'Daniel Eklöf-2/+0
When set to 'auto', use 10-bit surfaces if gamma-correct blending is enabled, and 8-bit surfaces otherwise. Note that we may still fallback to 8-bit surfaces (without disabling gamma-correct blending) if the compositor does not support 10-bit surfaces. Closes #2082
2025-05-01config: tweak.surface-bit-depth now defaults to 'auto'Daniel Eklöf-2/+0
When set to 'auto', use 10-bit surfaces if gamma-correct blending is enabled, and 8-bit surfaces otherwise. Note that we may still fallback to 8-bit surfaces (without disabling gamma-correct blending) if the compositor does not support 10-bit surfaces. Closes #2082
2025-03-05render: gamma-correct blendingDaniel Eklöf-0/+2
This implements gamma-correct blending, which mainly affects font rendering. The implementation requires compile-time availability of the new color-management protocol (available in wayland-protocols >= 1.41), and run-time support for the same in the compositor (specifically, the EXT_LINEAR TF function and sRGB primaries). How it works: all colors are decoded from sRGB to linear (using a lookup table, generated in the exact same way pixman generates it's internal conversion tables) before being used by pixman. The resulting image buffer is thus in decoded/linear format. We use the color-management protocol to inform the compositor of this, by tagging the wayland surfaces with the 'ext_linear' image attribute. Sixes: all colors are sRGB internally, and decoded to linear before being used in any sixels. Thus, the image buffers will contain linear colors. This is important, since otherwise there would be a decode/encode penalty every time a sixel is blended to the grid. Emojis: we require fcft >= 3.2, which adds support for sRGB decoding color glyphs. Meaning, the emoji pixman surfaces can be blended directly to the grid, just like sixels. Gamma-correct blending is enabled by default *when the compositor supports it*. There's a new option to explicitly enable/disable it: gamma-correct-blending=no|yes. If set to 'yes', and the compositor does not implement the required color-management features, warning logs are emitted. There's a loss of precision when storing linear pixels in 8-bit channels. For this reason, this patch also adds supports for 10-bit surfaces. For now, this is disabled by default since such surfaces only have 2 bits for alpha. It can be enabled with tweak.surface-bit-depth=10-bit. Perhaps, in the future, we can enable it by default if: * gamma-correct blending is enabled * the user has not enabled a transparent background
2025-01-18render: Expose render_overlayAlexander Orzechowski-0/+2
This function updates the overlay that foot uses. It will be used to update the overlay when the flash effect ends.
2025-01-09render: Expose render_overlayAlexander Orzechowski-0/+2
This function updates the overlay that foot uses. It will be used to update the overlay when the flash effect ends.
2024-09-13toplevel-icon: implement OSC-1, CSI 20/21/22/23 tDaniel Eklöf-0/+1
* The toplevel icon is now set to the app-id, unless "overridden" by OSC-1 or OSC-0. * Implemented OSC-1 * OSC-0 extended to also set the icon * Implemented CSI 20 t - report window icon * Implemented CSI 21 t - report window title * Implemented CSI 22 ; 1 t - push window icon * Implemented CS 23 ; 1 t - pop window icon * Extended CSI 22/23 ; 0 t to also push/pop the icon * Verify app-id set by OSC-176 is valid UTF-8 * Verify icon set by OSC-0/1 is valid UTF-8
2024-02-06osc: add support for osc 176 (app ID)delthas-0/+1
This adds support for a new OSC escape sequence: OSC 176, that lets terminal programs tell the terminal the name of the app that is running. foot then sets the app ID of the toplevel to that ID, which lets the compositor know which app is running, and typically sets the appropriate icon, window grouping, ... See: https://gist.github.com/delthas/d451e2cc1573bb2364839849c7117239
2024-02-05feature: add resize-by-cells option to constrain window sizes...Andrew J. Hesford-2/+9
...to multiples of the cell size, and preserve grid size when changing fonts or display scales in floating windows.
2023-07-03refactor: track current xcursor using an enum, instead of a char pointerDaniel Eklöf-1/+1
2022-02-07render: add render_xcursor_is_valid()Daniel Eklöf-1/+3
Returns true if the provided cursor name is non-NULL, and exist in the currently loaded xcursor theme.
2022-01-15replace gettimeofday with clock_gettimePranjal Kole-0/+1
POSIX.1-2008 has marked gettimeofday(2) as obsolete, recommending the use of clock_gettime(2) instead. CLOCK_MONOTONIC has been used instead of CLOCK_REALTIME because it is unaffected by manual changes in the system clock. This makes it better for our purposes, namely, measuring the difference between two points in time. tv_sec has been casted to long in most places since POSIX does not define the actual type of time_t.
2021-11-29input: Add support for xdg_toplevl.show_window_menu()Jonas Ådahl-0/+9
This makes, if the compositor supports it, the window menu appear when right clicking on the title bar.
2021-02-07urls: initial support for detecting URLs and rendering jump-labelsDaniel Eklöf-0/+1
The jump labels work, but is currently hardcoded to use xdg-open
2020-10-11render: remove render_refresh_margins()Daniel Eklöf-1/+0
2020-10-10selection: use appropriate check for PRIMARY pasteSergey Nazaryev-30/+3
Assume it could be a copy-paste typo. We should check PRIMARY, not CLIPBOARD. Without this fix, we can't use PRIMARY until we copy anything to CLIPBOARD.
2020-09-29render: remove render_refresh_margins()Daniel Eklöf-1/+0
2020-09-01render: implement render_refresh_margins()Daniel Eklöf-0/+1
For now, it will reset term->render.last_buf to NULL, and then calls grid_render() to do a full screen refresh.
2020-07-09multi-seat: improve handling of multiple (mouse) pointersDaniel Eklöf-1/+1
* xcursor always set for all pointers * xcursor sometimes not updated when it should be * mouse grabbed state wasn't per seat, but global (i.e. "does at least one seat enable mouse grabbing") * selection enabled state wasn't per seat
2020-07-08multi-seat: enable xcursor theme support againDaniel Eklöf-1/+1
2020-03-25render: pace title updatesDaniel Eklöf-1/+1
Synchronize window title updates with window rendering.
2020-03-06render: never render CSD and/or search box "immediately"Daniel Eklöf-5/+2
Handle the CSDs and the search box the same way we handle the main grid; when we need to redraw them, call render_refresh_{csd,search}(). This sets a flag that is checked after each FDM iteration. All actual rendering is done here. This also ties the commits of the Wayland sub-surfaces to the commit of the main surface.
2020-03-02csd: initial implementation of minimize/maximize/close buttonsDaniel Eklöf-0/+1
2020-02-29render: csd: split up positioning from renderingDaniel Eklöf-0/+1
2020-02-25render: render_resize_*() returns a boolean indicating whether size changed.Daniel Eklöf-2/+3
2020-02-25render: export render_csd()Daniel Eklöf-0/+1
2020-02-08render: add render_resize_force()Daniel Eklöf-0/+2
This forces a full resize operation, even though actual window size (or scale) hasn't changed.
2020-01-12term/render: move {enable,disable}_application_synchronized_updates()Daniel Eklöf-3/+0
From render -> terminal
2020-01-12render: rename render_{enable,disable}_refresh()Daniel Eklöf-2/+3
2020-01-12render: add render_{enable,disable}_refresh()Daniel Eklöf-0/+2
Calling render_disable_refresh() causes update requests to that terminal to be ignored. Calling render_enable_refresh() re-enables updates.
2020-01-04render: throttle xcursor updatesDaniel Eklöf-1/+1
With a bad behaving client (e.g. 'less' with mouse support enabled), we can end up with a *lot* of xcursor updates (so much, that we flooded the wayland socket before we implemented a blocking wayl_flush()). Since there's little point in updating the cursor more than once per frame interval, use frame callbacks to throttle the updates. This works more or lesslike normal terminal refreshes: render_xcursor_set() stores the last terminal (window) that had (and updated) the cursor. The renderer's FDM hook checks if we have such a pending terminal set, and if so, tries to refresh the cursor. This is done by first checking if we're already waiting for a callback from a previous cursor update, and if so we do nothing; the callback will update the cursor for the next frame. If we're *not* already waiting for a callback, we update the cursor immediately.
2020-01-04render: trigger terminal refreshes in an FDM hookDaniel Eklöf-2/+5
In some cases, we end up calling render_refresh() multiple times in the same FDM iteration. This means will render the first update immediately, and then set the 'pending' flag, causing the updated content to be rendered in the next frame. This can cause flicker, or flashes, since we're presenting one or more intermediate frames until the final content is shown. Not to mention that it is inefficient to render multiple frames like this. Fix by: * render_refresh() only sets a flag in the terminal * install an FDM hook; this hook loops all terminals and executes what render_refresh() _used_ to do (that is, render immediately if we're not waiting for a frame callback, otherwise set 'pending' flag). for all terminals that have the 'refresh_needed' flag set.
2020-01-03render: remove 'refresh' from render_resize()Daniel Eklöf-1/+1
2020-01-03render: resize() now only calls refresh() if asked toDaniel Eklöf-1/+1
2019-12-19render: attrs_to_font: const:ifyDaniel Eklöf-1/+1
2019-10-27wayland: move reload_cursor_theme() and update_cursor_surface() to waylandDaniel Eklöf-2/+0
2019-08-29search: move render() function to the 'render' moduleDaniel Eklöf-0/+1
2019-08-21render: reload cursor theme when scale (may) have changedDaniel Eklöf-1/+3
2019-08-12output: track output we're mapped on, and use maximum scaleDaniel Eklöf-1/+1
Our surface may be on multiple outputs at the same time. In this case, we use the largest scale factor, and let the compositor down scale on the "other" output(s).
2019-08-12output: resize on scale changesDaniel Eklöf-1/+1
2019-07-29wip: initial multithreaded rendererDaniel Eklöf-0/+6
2019-07-24render: add render_refresh()Daniel Eklöf-0/+1
2019-07-18render: cache generated glyphs for regular ASCII charactersDaniel Eklöf-1/+1
To avoid having to re-generate glyphs, cache the glyphs. For now, we only cache ASCII characters, as this allows us to lookup the cache by simply indexing with the character (into a 256-entry array).
2019-07-16render: implement 'underline'Daniel Eklöf-1/+1
2019-07-05render: load cursor theme from XCURSOR_THEME and XCURSOR_SIZEDaniel Eklöf-0/+1
2019-07-05render: break out rendering functions to render.{c,h}Daniel Eklöf-0/+10