43 Commits

Author SHA1 Message Date
Qwerasd
34abe2ceba fix(macos): prevent transparency leakage/flash in new/resized surfaces
By using the `CAMetalLayer`'s `backgroundColor` property instead of
drawing the background color in our shader, it is always stretched to
cover the full surface, even when live-resizing, and it doesn't require
us to draw a frame for it to be initialized so there's no transparent
flash when a new surface is created (as in a new split/tab).

This commit also allows for hot reload of `background-opacity`,
`window-vsync`, and `window-colorspace`.
2025-01-14 20:23:21 -05:00
Qwerasd
fca336c32d Metal: blend in Display P3 color space, add option for linear blending
This commit is quite large because it's fairly interconnected and can't
be split up in a logical way. The main part of this commit is that alpha
blending is now always done in the Display P3 color space, and depending
on the configured `window-colorspace` colors will be converted from sRGB
or assumed to already be Display P3 colors. In addition, a config option
`text-blending` has been added which allows the user to configure linear
blending (AKA "gamma correction"). Linear alpha blending also applies to
images and makes custom shaders receive linear colors rather than sRGB.

In addition, an experimental option has been added which corrects linear
blending's tendency to make dark text look too thin and bright text look
too thick. Essentially it's a correction curve on the alpha channel that
depends on the luminance of the glyph being drawn.
2025-01-13 13:50:29 -08:00
Qwerasd
4ca6413ec9 renderer: do not constrain color glyphs
There is no reason to and I do not know where this assumption came from.
It's very possible for a colored glyph to (intentionally!) exceed the
cell bounds, and we shouldn't be stopping this...
2024-12-19 11:21:57 -05:00
Mitchell Hashimoto
3392659e1f Revert "macos: enable Metal shader logging"
This reverts commit aad101565abff3368af76e8c2e93cbe7c278a89f.
2024-11-20 15:01:27 -08:00
Mitchell Hashimoto
aad101565a macos: enable Metal shader logging
This enables the compile options and Xcode configuration so that logging
in Metal shaders shows up in our Xcode debug console. This doesn't add
any log messages, but makes it so that when we iterate on the shaders in
the future, we can add and see logs to help us out.
2024-11-19 18:59:41 -08:00
Mitchell Hashimoto
7aa2e2b24f renderer: some tweaks 2024-10-02 15:44:06 -07:00
Qwerasd
dfc0894d5d fix(renderer): make all decorations and combining marks visible under cursor
Metal needed to be changed to account for wide chars having decorations
on the right half and OpenGL needed to account for multiple glyphs being
under the cursor at once (decorations and combining marks) as well as
wide chars.
2024-10-02 17:18:26 -04:00
Qwerasd
74d24a53ab correct diagram/description (+Y is down not up) 2024-09-25 11:41:12 -06:00
Qwerasd
10b8ca3c69 spelling: normalize grey -> gray 2024-08-11 18:31:01 -04:00
Qwerasd
d68906563e renderer/metal: properly support padding color = background (not extend) 2024-08-08 19:03:39 -04:00
Qwerasd
6339f9bae9 renderer: metal shaders rework
- Significant changes to optimize memory usage.
- Adjusted formatting of the metal shader code to improve readability.
- Normalized naming conventions in shader code.
- Abstracted repetitive code for attribute descriptors to a helper
function.
2024-08-07 17:39:31 -04:00
Mitchell Hashimoto
e5a087e143 renderer/metal: fix warnings compiling metal shader 2024-08-06 10:43:57 -07:00
Mitchell Hashimoto
389cc95394 renderer/metal: powerline enum value used wrong value 2024-08-06 10:22:08 -07:00
Leah Amelia Chen
503dfae6ff renderer: exempt Powerline cells from minimum contrast requirements
With a minimum contrast set, the colored glyphs that Powerline uses
would sometimes be set to white or black while the surrounding background
colors remain unchanged, breaking up contiguous colors on segments of
the Powerline.

This no longer happens with this patch as Powerline glyphs are now
special-cased and exempt from the minimum contrast adjustment.
2024-08-06 15:28:50 +08:00
Mitchell Hashimoto
ea551990eb renderer: disable window-padding-color=extend in certain scenarios
There are scenarios where this configuration looks bad. This commit
introduces some heuristics to prevent it. Here are the heuristics:

  * Extension is always enabled on alt screen.
  * Extension is disabled if a row contains any default bg color. The
    thinking is that in this scenario, using the default bg color looks
    just fine.
  * Extension is disabled if a row is marked as a prompt (using semantic
    prompt sequences). The thinking here is that prompts often contain
    perfect fit glyphs such as Powerline glyphs and those look bad when
    extended.

This introduces some CPU cost to the extension feature but it should be
minimal and respects dirty tracking. This is unfortunate but the feature
makes many terminal scenarios look much better and the performance cost
is minimal so I believe it is worth it.

Further heuristics are likely warranted but this should be a good
starting set.
2024-08-03 21:56:19 -07:00
Mitchell Hashimoto
9214db3c5f renderer/metal: handle top/left 2024-08-03 16:03:42 -07:00
Mitchell Hashimoto
5309f4d080 renderer/metal: extend background color of grid border into padding 2024-08-03 15:39:02 -07:00
Mitchell Hashimoto
3a7dc355a0 renderer/metal: invert text under cursor again 2024-04-27 22:13:17 -07:00
Mitchell Hashimoto
ced8776120 renderer/metal: grid pos for bg/text should be ushort2
This saves 50% memory per vertex.
2024-04-25 19:16:40 -07:00
Mitchell Hashimoto
d12e3db599 renderer/metal: dedicated cell fg shader 2024-04-22 10:58:23 -07:00
Mitchell Hashimoto
e8b623e829 renderer/metal: dedicated cell bg shader 2024-04-22 10:43:29 -07:00
Mitchell Hashimoto
ad08842e86 renderer/metal: remove strikethrough support from GPU 2024-04-22 10:26:51 -07:00
Mitchell Hashimoto
43c105c363 renderer: constrain emoji to cell width
Fixes #1402
2024-01-28 09:07:49 -08:00
Mitchell Hashimoto
5622ab370f renderer/metal,opengl: premult alpha for fragment shaders for images
Fixes #1346
2024-01-21 14:07:16 -08:00
Mitchell Hashimoto
62e5234da4 renderer: for constrained cells, offset was being doubled
This helps better preserve the centerline for constrained glyphs
2024-01-07 15:02:56 -08:00
Mitchell Hashimoto
0b658c8217 renderer/metal: constrain PUA glyphs if they aren't next to space 2023-12-16 20:07:25 -08:00
Mitchell Hashimoto
e3eba92c0e renderer/metal: only apply min contrast if set and only on non-color fg 2023-12-01 21:26:33 -08:00
Mitchell Hashimoto
7af4009f27 renderer/metal: minimum contrast ratio is configurable 2023-12-01 21:24:38 -08:00
Mitchell Hashimoto
6c859cca82 renderer/metal: minimum contrast experiment
This uses WCAG2 algorithms with a minimum ratio hardcoded of 3:1. This
is not shippable in its current state because we want the ratio to be
configurable and I'm not happy with the way data is being sent to the
shader.
2023-12-01 20:51:16 -08:00
Mitchell Hashimoto
c347148fd7 renderer/metal: CRT effect, ugly hacky code 2023-11-17 21:50:34 -08:00
Mitchell Hashimoto
a5066635f0 renderer: do not downsample oversized glyphs
Fixes #696

We should rely on the rasterizer to create glyphs of the proper size,
including doing CPU resizing if necessary.
2023-10-17 10:55:04 -07:00
Mitchell Hashimoto
0918731d9a renderer/metal: need to set proper alpha for fg mode in shader
Fixes #673
2023-10-16 12:22:51 -07:00
Mitchell Hashimoto
7ff76ca00d terminal/kitty-gfx: respect display c/r params 2023-08-22 14:43:50 -07:00
Mitchell Hashimoto
3bbfee676b terminal/kitty-gfx: process source rectangle display params 2023-08-22 14:33:41 -07:00
Mitchell Hashimoto
84c72bbe46 renderer/metal: honor cell offset graphics command 2023-08-22 13:28:40 -07:00
Mitchell Hashimoto
5a9bbcbc2d renderer/metal: clip image if necessary off top of viewport (scrolling) 2023-08-22 11:32:45 -07:00
Mitchell Hashimoto
cb70d86c00 renderer/metal: emit draw calls for images 2023-08-22 10:12:40 -07:00
Mitchell Hashimoto
e665fc6741 renderer/metal: first pass at an image shader 2023-08-22 09:20:30 -07:00
Mitchell Hashimoto
0ca6957d0c renderer/{metal,opengl}: need to premult our cell alpha to have effect 2023-08-18 18:38:47 -07:00
Mitchell Hashimoto
cf519bcd75 Use procedurally generated sprites for cursors rather than shaders 2023-03-04 15:14:10 -08:00
Mitchell Hashimoto
60b2603304 metal: premult alpha for fg color 2023-02-24 08:39:55 -08:00
Mitchell Hashimoto
379072566f remove underline support from shaders since we now use sprites 2022-11-27 16:18:00 -08:00
Mitchell Hashimoto
18de7cd2ef Move shaders into the renderer dir 2022-11-15 13:10:43 -08:00