aboutsummaryrefslogtreecommitdiff
path: root/render.c (follow)
Commit message (Collapse)AuthorAgeLines
* fcft: update to 0.3.0Daniel Eklöf2019-12-03-10/+4
| | | | | fcft now calculates the underline and strikeout integer positions, making our rendering code much simpler.
* render: limit size of search surface to parent windowDaniel Eklöf2019-12-03-4/+2
| | | | | | This shouldn't be necessary, but Sway acts up when the subsurface exceeds the parent surface (window, in this case) size, and extends the window size (if floating), leaving it with no content
* render: don't allow negative coordinates of the search surfaceDaniel Eklöf2019-12-03-1/+2
| | | | | | While the protocol allows this, it appears Sway offsets (moves) the parent surface when this happens, resulting in a window half without content.
* fcft: include <fcft/fcft.h>, and use fcft/stride.h instead of local copyDaniel Eklöf2019-12-01-1/+1
|
* fcft: use fcft instead of local copy of font.c/font.hDaniel Eklöf2019-12-01-1/+2
|
* render: fix underline/strikeout positioningDaniel Eklöf2019-11-30-6/+8
| | | | | | | | | | | | There were two errors: * We subtracted half the line width instead of adding it to the baseline * We rounded the line positioning and thickness before the positioning calculation. In particular, rounding the thickness before using it to adjust the position was wrong. Now we round just before the pixman call.
* render: font_baseline(): simply use the primary font's ascentDaniel Eklöf2019-11-30-16/+4
| | | | | | This is what we used as baseline for regular glyphs anyway. Thus, we can update that code to call font_baseline() now. This makes it easier to change how we define the baseline in the future.
* render: fix rendering of cursor when cell is reversedDaniel Eklöf2019-11-28-13/+19
| | | | | | When the user had configured the cursor color, we failed to invert (reverse) the foreground and background color when the cursor was on a cell with the 'reverse' attribute set.
* font: move metrics from terminal struct to font structDaniel Eklöf2019-11-26-11/+11
|
* term: add struct cursorDaniel Eklöf2019-11-17-10/+10
|
* render: configure default tab stops when resizing the terminalDaniel Eklöf2019-11-16-0/+5
|
* Revert "render: last_buf may point to a free:d buffer"Daniel Eklöf2019-11-02-18/+8
| | | | This reverts commit 4d3251a93b4ba309d573aca6ff397df44c4ff760.
* render: last_buf may point to a free:d bufferDaniel Eklöf2019-11-01-8/+18
| | | | So, store last buf's width/height separately
* shm: associate a 'cookie' with each bufferDaniel Eklöf2019-11-01-3/+7
| | | | | | | When re-using a buffer from cache, only re-use ones with a matching cookie. This prevents contention between multiple terminal windows.
* shm: get_buffer(): remove 'copies' argument; it's not usedDaniel Eklöf2019-11-01-2/+2
|
* render: limit length of title in call to xdg_toplevel_set_title()Daniel Eklöf2019-11-01-1/+13
| | | | | | Trying to pass a too long title (not sure what "too long" is though...) will trigger a call to abort() inside the wayland-client library.
* render: call wl_display_flush() after renderingDaniel Eklöf2019-11-01-0/+2
| | | | This allows us to remove that call from the main event loop.
* Merge branch 'fdm'Daniel Eklöf2019-10-30-85/+33
|\
| * render worker context: allocate, and let worker threads freeDaniel Eklöf2019-10-28-0/+1
| | | | | | | | | | | | | | | | | | | | Since we now initialize the worker threads from term_init(), which returns before the threads terminate, we can no longer use stack-allocated worker contexts. We _could_ put them in the terminal struct. But a simpler solution is to allocate them in term_init(), and let the threads free them when they don't need them anymore.
| * wayland: move reload_cursor_theme() and update_cursor_surface() to waylandDaniel Eklöf2019-10-27-55/+0
| |
| * wayland: implement wayl_init()Daniel Eklöf2019-10-27-28/+28
| | | | | | | | Wayland instantiation is now done by the wayland backend, not in main.
| * term: wayland struct is now not a part of the terminal structDaniel Eklöf2019-10-27-22/+22
| | | | | | | | | | | | We do however need access to it, so provide a pointer. The difference is that now we can have a *single* wayland instance, but multiple terminal instances.
| * wayland: implement wayl_win_destroy()Daniel Eklöf2019-10-27-6/+6
| |
| * term: move per-window wayland objects from wayland struct to terminal structDaniel Eklöf2019-10-27-23/+25
| | | | | | | | | | | | | | | | Short term, we want to break out the wayland backend from the terminal struct. Long term, we might want to support multiple windows. One step towards both the above is separating global wayland objects from per-window objects.
* | scrollback: regression: fix rendering of scrollback diffs less than a screenDaniel Eklöf2019-10-29-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When doing "small" scrolls (typically done via mouse wheel or similar), we render the scrolling by emitting a "scroll damage". A recent commit changed how scroll damage is rendered; only when the view is at the bottom ("following" the screen output) do we render the damage. To fix this, add a new type of scroll damage, SCROLL_DAMAGE_IN_VIEW and SCROLL_DAMAGE_REVERSE_IN_VIEW. These signal to the renderer that it should always render the damage.
* | render: regression: don't apply scroll damage when view is in scrollbackDaniel Eklöf2019-10-28-12/+15
|/ | | | | | | | | | | | | | When user has scrolled back in the output history, new output should not trigger scrolling. This was true for normal cell rendering, which renders the cells *in view*, not caring where the "front" of the output is. However, we still applied scroll damage. I.e. we memmoved part of the screen. The fix is simple; only apply scroll damage when the view is at the front of the output.
* font: font_from_name() returns an allocated font structDaniel Eklöf2019-10-16-2/+2
|
* render: handle compositors that does buffer swappingDaniel Eklöf2019-09-27-45/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not all compositors support buffer re-use. I.e. they will call the frame callback *before* the previous buffer has been released. Effectively causing us to swap between two buffers. Previously, this made us enter an infinite re-render loop, since we considered the window 'dirty' (and in need of re-draw) when the buffer is different from last redraw. Now, we detect the buffer swapping case; size must match, and we must not have any other condition that require a full repaint. In this case, we can memcpy() the old buffer to the new one, without dirtying the entire grid. We then update only the dirty cells (and scroll damage). Note that there was a bug here, where we erased the old cursor *before* checking for a new buffer. This worked when the buffer had *not* changed. Now that we need to handle the case where it *has* changed, we must do the memcpy() *before* we erase the cursor, or the re-painted cell is lost. This makes foot work on Plasma, without burning CPU. The memcpy() does incur a performance penalty, but we're still (much) faster than e.g. konsole. In fact, we're still mostly on par with Alacritty.
* render: attach buffer *before* generating damageDaniel Eklöf2019-09-27-2/+1
| | | | Fixes 'invisible window' on Plasma
* main: initialize scale to '1'Daniel Eklöf2019-09-26-13/+1
| | | | | | | | | | This ensures we always have a valid (but possibly incorrect) scaling value. This allows us to simplify code that uses the scale - it doesn't have to verify the scale if valid. Furthermore, since render_resize() is the function that actually updates term->scale, make sure to call it *before* updating the cursor (otherwise, the cursor will use the old scaling value).
* render: remove assertion that isn't always trueDaniel Eklöf2019-09-20-1/+0
| | | | It's not true for e.g. Cascadia code.
* render: search box: use colors from the color tableDaniel Eklöf2019-08-30-2/+3
| | | | | | | | | Use the 'yellow' color from the 'regular' range of colors (SGR 33) for background when we have a match, or 'red' from the 'regular' range of colors (SGR 31) when we don't have a match. Foreground uses the 'black' color from the regular range of colors (SGR 30).
* render: draw (cursor) bar using the same thickness as underlinesDaniel Eklöf2019-08-30-5/+7
|
* render: search box: fix glyph spacingDaniel Eklöf2019-08-30-1/+1
| | | | | We're using the same font as in the terminal, so use the same glyph spacing.
* render: render_search_box: draw cursor as a barDaniel Eklöf2019-08-29-0/+6
|
* render: draw_strikeout: use font_baseline() for baseline calculationDaniel Eklöf2019-08-29-1/+1
|
* render: draw_underline: use font_baseline() for baseline calculationDaniel Eklöf2019-08-29-1/+1
|
* render: draw_bar: don't assume height == ascent+descentDaniel Eklöf2019-08-29-2/+4
| | | | | Instead, draw a bar that is ascent+descent tall, positioned around the baseline such that it starts at the ascent and ends at the descent.
* render: add font_baseline() - calculates the y-coordinate for the baselineDaniel Eklöf2019-08-29-0/+19
| | | | | | | | | | The old baseline calculation was copy-pasted to a couple of places, and also assumed that the font's height was equal to ascent+descent. While this is typically true, it isn't necessarily so. Now, we assume that height >= ascent+descent, and then position the baseline in "center" (but adjusted for the descent).
* render: remove INFO log (that really was a debug log)Daniel Eklöf2019-08-29-2/+0
|
* search: move render() function to the 'render' moduleDaniel Eklöf2019-08-29-0/+54
|
* render: reduce amount of dim while searching scrollback historyDaniel Eklöf2019-08-29-4/+10
|
* render: double-dim fg+bg when searching the scrollback bufferDaniel Eklöf2019-08-28-0/+2
| | | | | By toning down the screen content more, the selection (i.e. the search match) pops out much more.
* render: don't dim selection while searchingDaniel Eklöf2019-08-27-1/+1
|
* search: wip: re-direct input while searching, and build a search bufferDaniel Eklöf2019-08-27-7/+21
| | | | | | | | | | | This adds a new state, 'is_searching'. While active, input is re-directed, and stored in a search buffer. In the future, we'll use this buffer and search for its content in the scrollback buffer, and move the view and create a selection on matches. When rendering in 'is_searching', everything is dimmed. In the future, we'll render the current search buffer on-top of the dimmed "regular" terminal output.
* render: center grid in windowDaniel Eklöf2019-08-27-31/+42
| | | | | Instead of placing the upper left corner of the grid at 0,0 in the window, center it.
* render: log frame rendering time with microseconds instead of millisecondsDaniel Eklöf2019-08-24-2/+2
|
* render: change resize debug log message to an info log messageDaniel Eklöf2019-08-23-1/+1
|
* scrolling: optimize row access by assuming number of rows is a power of 2Daniel Eklöf2019-08-22-9/+8
| | | | | | | | | | | | | | | | | | | With this assumption, we can replace 'a % b' with 'a & (b - 1)'. In terms of instructions, this means a fast 'and' instead of a slow 'div'. Further optimize scrolling by: * not double-initializing empty rows. Previously, grid_row_alloc() called calloc(), which was then followed by a memset() when scrolling. This is of course unnecessary. * Don't loop the entire set of visible rows (this was done to ensure all visible rows had been allocated, and to prefetch the cell contents). This isn't necessary; only newly pulled in rows can be NULL. For now, don't prefetch at all.
* render: multiply width/height with *new* scale factor, not oldDaniel Eklöf2019-08-21-2/+2
|
* render: reload cursor theme when scale (may) have changedDaniel Eklöf2019-08-21-0/+42
|
* render: don't 're-calculate fg unnecessarilyDaniel Eklöf2019-08-18-6/+4
|
* render: minor optimizationDaniel Eklöf2019-08-17-1/+1
| | | | | Don't instantiate a pixman color unnecessarily when drawing a block cursor.
* render: use 32-bit pixman calls, where applicableDaniel Eklöf2019-08-17-2/+2
|
* shm/render: there's no need to have one pixman image per threadDaniel Eklöf2019-08-16-2/+2
|
* render: replace all usage of cairo with pixmanDaniel Eklöf2019-08-16-71/+80
|
* wip: render background and glyphs using pixmanDaniel Eklöf2019-08-16-52/+63
|
* Add background alpha supportDaniel Eklöf2019-08-15-2/+2
|
* output: track output we're mapped on, and use maximum scaleDaniel Eklöf2019-08-12-1/+12
| | | | | | 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).
* output: resize on scale changesDaniel Eklöf2019-08-12-2/+8
|
* output: initial support for output scalingDaniel Eklöf2019-08-12-4/+5
| | | | | | * Not updated run-time; only scale at start up used * Multiple monitors (outputs) not supported, as we can't track which output we're on (yet).
* render: fix foreground color for non-block cursorDaniel Eklöf2019-08-12-1/+4
| | | | | | | When rendering either the 'bar' or 'underline' cursor styles, only use the configured "cursor color" if it has actually been configured. If it hasn't, use the current foreground color.
* render: selection may not be "ordered", since it may not have been finalizedDaniel Eklöf2019-08-08-0/+6
|
* selection: ensure start < end in finalizeDaniel Eklöf2019-08-05-24/+16
| | | | | When the selection is finalized, swap start/end if necessary, to make sure start <= end.
* render: make sure the current view is allocated and visibleDaniel Eklöf2019-08-04-8/+8
|
* cell: pack more efficiently and store glyph as a wcharDaniel Eklöf2019-08-02-6/+6
| | | | | | | | | | | The 'attributes' struct is now 8 bytes and naturally packed (used to be 9 bytes, artificially packed). 'cell' struct is now 12 bytes, naturally packed (used to be 13 bytes, artificially packed). Furthermore, the glyph is stored as a wchar instead of a char*. This makes it easier (faster) to do glyph lookup when rendering.
* render: special case worker-count == 0Daniel Eklöf2019-08-01-31/+60
| | | | | Allow render worker count to be 0, in which case the main thread renders the entire screen.
* threads: set thread titlesDaniel Eklöf2019-08-01-0/+8
|
* render: always damage two cells when rendering the cursorDaniel Eklöf2019-07-31-1/+1
| | | | | Hack to render cursor-at-double-width-characters correctly. Should be replaced with something better.
* render: draw cell decorations (cursor, underline etc) correctly for double-width charactersDaniel Eklöf2019-07-31-37/+38
|
* font: initial support for double-width *and* color emoji glyphsDaniel Eklöf2019-07-31-5/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fonts are now loaded with FT_LOAD_COLOR and we recognize and support the FT_PIXEL_MODE_BGRA pixel mode. This is mapped to a CAIRO_FORMAT_ARGB32 surface, that is blitted as-is (instead of used as a mask like we do for gray and mono glyphs). Furthermore, since many emojis are double-width, we add initial support for double-width glyphs. These are assumed to always be utf8. When PRINT:ing an utf8 character, we check its width, and add empty "spacer" cells after the cell with the multi-column glyph. When rendering, we render the columns in each row backwards. This ensures the spacer cells get cleared *before* we render the glyph (so that we don't end up erasing part of the glyph). Finally, emoji fonts are usually bitmap fonts with *large* glyphs. These aren't automatically scaled down. I.e. even if we request a glyph of 13 pixels, we might end up getting a 100px glyph. To handle this, fontconfig must be configured to scale bitmap fonts. When it is, we can look at the 'scalable' and 'pixelsizefixup' properties, and use these to scale the rendered glyph.
* render: make resize log messages debug messagesDaniel Eklöf2019-07-30-1/+1
|
* render: don't pass a struct buffer when all we need is a cairo_tDaniel Eklöf2019-07-30-23/+18
|
* render: don't call wl_surface_set_buffer_scale()Daniel Eklöf2019-07-30-3/+4
| | | | | | Since we don't support scaling, don't call wl_surface_set_buffer_scale(). This way, at least will get auto-scaled by the compositor.
* render: remove #if 0 codeDaniel Eklöf2019-07-30-15/+0
|
* render: fix 'suggest braces around initialization...' warning (clang)Daniel Eklöf2019-07-30-1/+1
|
* render: only explicitly re-render old cursor cell if it isn't dirtyDaniel Eklöf2019-07-30-13/+11
| | | | | If it is dirty, it will be rendered in the normal rendering process.
* render: remove all traces of glyph-sequenceDaniel Eklöf2019-07-30-61/+0
| | | | | This was used to optimize the call(s) to cairo_show_glyphs(), which we aren't using anymore.
* font: add support for fallback fontsDaniel Eklöf2019-07-30-36/+14
| | | | | | | | | | | | | | | A top-level font now has a list of fallback fonts. When a glyph cannot be found, we try each fallback font in turn, until we either find one that has the glyph, or until we've exhausted the list. To make this actually work in practise (read: to make performance acceptable), the cache is re-worked and is now populated on demand. It also supports non-ASCII characters, by using the 4-byte unicode character as index instead. Since having an array that can be indexed by a 4-byte value isn't really viable, we now have a simple hash table instead of an array.
* render: add a 'clean' bit to each cell; only render cells that aren't cleanDaniel Eklöf2019-07-30-3/+8
| | | | | | | | | | | This patch takes a bit from the foreground color value in a cell (todo: split up foreground/background into bitfields with a separate field for 'foreground/background' has been set), and only re-renders cells that aren't marked as clean. Note: we use a 'clean' bit rather than a 'dirty' bit to make it easy to erase cells - we can (keep doing) do that by simply memsetting a cell range to 0.
* wip: initial multithreaded rendererDaniel Eklöf2019-07-29-55/+144
|
* font: populate glyph cache (ASCII characters only) when instantiating fontDaniel Eklöf2019-07-28-76/+13
|
* font: add font_glyph_for_utf8()Daniel Eklöf2019-07-28-73/+11
| | | | | | This function fills in a struct glyph with glyph bitmap data for the provided utf-8 character (essentially a FT_Bitmap wrapped in a cairo surface).
* cairo-ft: remove all usages of cairo-ftDaniel Eklöf2019-07-28-1/+3
|
* render: use FreeType face from font, instead of from cairo's scaled fontDaniel Eklöf2019-07-28-6/+2
|
* font: load FreeType face, and set it's pixel sizesDaniel Eklöf2019-07-28-2/+0
|
* render: poc: use freetype to render glyphsDaniel Eklöf2019-07-26-0/+124
| | | | | | | | | | | | | | Initial POC that uses freetype to render the glyphs. The bitmap produced by freetype contains the alpha value. We use this bitmap in a mask surface and then draw the final glyph with cairo by applying the source rgb using the OVER operator and the freetype generated alpha mask as surface mask. Note that we only support grayscale antialiasing (and no antialiasing). We are probably not setting the antialias options correctly either.
* render: reset "last cursor" when resizingDaniel Eklöf2019-07-26-2/+2
| | | | | The cell pointer is likely invalid since we realloc the grids. Besides. we're redrawing the entire window anyway.
* render: flush glyph sequence after erase previous cursorDaniel Eklöf2019-07-26-4/+8
| | | | | If not, we may have scrolled when we later flush the glyph sequence, causing the glyph to be rendered in wrong location.
* render: add render_row()Daniel Eklöf2019-07-24-7/+13
|
* render: minorDaniel Eklöf2019-07-24-1/+2
|
* render: move local static variables into the terminal structDaniel Eklöf2019-07-24-31/+26
|
* render: move frame_callback to term.renderDaniel Eklöf2019-07-24-6/+6
|
* render: add render_refresh()Daniel Eklöf2019-07-24-2/+8
|
* render: bug: previous cursor wasn't always redrawn correctlyDaniel Eklöf2019-07-24-39/+56
| | | | | | | | | | | | | | | | | | | | The main problem is knowing: * The correct *cell* (to be able to render the *content* when erasing the old cursor) * Whether the cursor has moved (to determine whether to stop the rendering loop or not) * Where on the *screen* the cursor is/was (since the terminal may be partly scrolled back) This patch stores three static variables: * last_cursor is used to compare against current cursor to see if the cursor has moved or not * last_cursor_on_screen is the actual screen coordinates the cursor was rendered at (typically the same as last_cursor, but may be offset by the view) * last_cursor_cell is a pointer to the cell to render
* conf: allow the user to configure a fixed cursor colorDaniel Eklöf2019-07-23-2/+10
| | | | | | | | | | | | | | | | | | | The default is to reverse the foreground/background colors in the cell with the cursor. But, if the user configures a specific set of cursor colors, those will always be used, regardless of other cell attributes (dim, reverse etc). The cursor color is specified as two color values, 'text' and 'cursor'. The block cursor uses the 'cursor' color as background, and the 'text' color for the glyph. All other cursor styles uses the 'cursor' color for the cursor, but uses the cell's foreground color for the glyph (meaning, dim/reverse/etc applies).
* render: implement cursor styles 'bar' and 'underline'Daniel Eklöf2019-07-22-47/+94
|
* term: group 'blink' state together in a structDaniel Eklöf2019-07-22-8/+8
|
* term: group 'flash' state together in a structDaniel Eklöf2019-07-22-4/+4
|
* blink: implement 'blink'Daniel Eklöf2019-07-21-1/+51
|