Commit Graph
51 Commits
Author SHA1 Message Date
Wez Furlong 86bf251f3f add some more metrics around get_lines_with_hyperlinks_applied + others 2021-08-01 14:50:50 -07:00
Wez Furlong 267885ce0b workaround a guillotiere issue
We don't need to free any allocations, so we can use the simple
allocator instead and avoid the issue.

refs: https://github.com/nical/guillotiere/issues/25
2021-08-01 00:12:19 -07:00
Wez Furlong 4c0d789ac3 zeno -> tiny_skia
Mostly so that we can turn off anti-aliasing for smaller sizes,
but it also happens to be more complete anyway.
2021-06-25 22:55:42 -07:00
Wez Furlong a0d39989df simplify Color data type
There's something fishy with colorspaces and blending.
This commit removes the `window::Color` type and replaces
it and the confusing array of color types exposed by the
`palette` crate with a pair of much simpler types:

`LinearRgb` - a tuple of f32 linear color components
`SrgbaPixel` - the u32 sRGBA pixel representation

This doesn't change anything about rendering, it just
makes it a bit simpler and makes the SrgbaPixel -> LinearRgb
conversion happen slightly earlier which shaves off some
ad-hoc conversions.

Refs: https://github.com/wez/wezterm/issues/544
2021-03-21 16:54:22 -07:00
Wez Furlong 09081d2189 improve texture upload performance, part 2
Continuing along the same lines as the prior commit, the goal
of this commit is to remove the buffer transformation that was
part of uploading the texture to the GPU provided surface.

In order to do so:

* The sense of our local textures needs to change from bgra32 to rgba32.
  bgra32 was a hangover from earlier versions of our window crate that
  allowed direct-to-fb writes in software mode.  We had to pick bgra32
  for that for the broadest OS compatibility.  I believe that that
  constraint has been totally removed, although there is a chance that
  this will flip the colors on macos.
* There was an additional linear-to-srgb conversion inlined in that
  buffer transformation.  I have no idea where that is needed because
  the source data is carefully constructed as SRGB.  I don't yet know
  how to signal that, but for now I've moved that gamma correction
  into the shader when we sample the texture.

With this change, timg playback now has vtparse as the hottest
region of code.

refs: #537
2021-03-14 09:14:30 -07:00
Wez Furlong b8dcfba9a4 improve texture upload performance
Two issues highlighted by profiling:

* Clearing the texture takes a non-trivial percentage of the profile.
  The docs suggest that it is better to create a new texture than
  to update large portions of a texture, so add some plumbing so
  that we can do that in the first texture-full case.

* Next on the list is the code that translates from linear BGRA to
  SRGBA.  This is present for reasons that I believe are now legacy,
  but for the moment: those two primitives now have faster and
  easier implementations, so simplify to those.

This improves the timg video playback performance by ~10% for me.

refs: #537
2021-03-13 23:18:15 -08:00
Wez Furlong 333f5f9750 fix a rounding issue when computing block glyphs
The leftmost pixel was being set to at least 1 by the scale
function.

Fix that up by computing the x coordinate without calling
the scale function.

refs: https://github.com/wez/wezterm/issues/536
2021-03-13 11:29:57 -08:00
Wez Furlong 3e44abcca8 Adopt new shaper logic in gui
Connect the gui to the new shaping logic; this means that we
can now correctly render fg/bg color when the cursor moves
through the cells that comprise a ligature.

refs: https://github.com/wez/wezterm/issues/478
2021-02-22 19:17:24 -08:00
Wez Furlong ee17e4e174 Add shaper post-processing function
This function is intended to deal with certain kinds of ligatures
and certain combining sequences that don't have corresponding glyphs.

It isn't hooked up to the gui yet, but does have unit tests that
are probably mostly correct.

refs: https://github.com/wez/wezterm/issues/478
2021-02-22 19:17:24 -08:00
Wez Furlong cc4cdd81b3 window: remove avx code in bitmaps/mod.rs
I don't think it is worth the complexity of keeping this around;
we rarely do direct bitmap stuff any more.
2020-12-29 14:26:57 -08:00
Wez Furlong 4c22de9f6d window: make opengl always required 2020-12-29 12:13:23 -08:00
Jeremy Fitzhardinge e95c7ad855 Fix compiler warning by moving x86-64 specific variable into the guard 2020-11-11 20:31:18 -08:00
Wez Furlong 52908712c6 wezterm: add excess padding for image protocols
When allocating space in the texture atlas, we typically use
a small padding to avoid accidentally interpolating textures
into glyphs.

When it comes to rendering images via iterm2 or sixel image
protocols, the image emitted by the user may not exactly fill
the cell dimensions, and due to the how the shader works to
apply those textures we could end up revealing nearby images
in the texture when displaying an unrelated image.

This commit adjusts the texture atlas allocation when making
space for image protocol textures; excess padding based on
an overestimate of the cell dimensions is added to the right
and bottom of the image, guaranteeing that that border will
be filled with transparent pixels.

This is a bit wasteful of texture space, but isn't egregiously
bad and is easy to reason about and makes things look less
janky.

refs: #292
2020-10-24 12:46:49 -07:00
Wez Furlong f4066747d2 wezterm: improve texture atlas allocation
This commit uses the guillotine algorithm to assign rectangles,
which is superior to the dumb algorithm previously in use.

In addition, in the first pass of painting, if we get a texture
space error, we clear the atlas and try again without increasing
it size, which should serve as the ultimate defrag.

Subsequent passes will cause the texture to grow if needed.

refs: #306
2020-10-23 13:57:58 -07:00
Wez Furlong 14c73f7122 window: linux: set window icon
Teach the window layer about window icons and implement the
plumbing for this on X11.

For Wayland there is no direct way to specify the icon; instead
the application ID is used to locate an appropriate .desktop filename.
We set the app id from the classname but that didn't match the installed
name for our desktop file which is namespaced under my domain, so change
the window class to match that and enable the window icon on Wayland.

refs: https://github.com/wez/wezterm/issues/172#issuecomment-619938047
2020-05-02 12:07:34 -07:00
Wez Furlong 59de97034a belt and suspenders to clip the copy region
a debug assertion triggers for me on macos because we were trying
to copy out of bounds.  This makes the copy routine safe again.
2020-01-05 17:58:14 -08:00
Wez Furlong bd0859bef6 Make it possible to more easily tweak atlas padding 2019-12-28 11:55:42 -08:00
Wez Furlong f493139305 clippy 2019-12-21 23:13:26 -08:00
Wez Furlong 9a2c7a1485 failure -> anyhow + thiserror 2019-12-14 21:43:05 -08:00
Wez Furlong 51c2646eee fonts: remove some unused code and fixup some warnings 2019-12-14 12:29:38 -08:00
Wez Furlong a9b0197075 fonts: add an Allsorts shaper
Adds the ability to specify `--font-shaper Allsorts` and use that
for metrics and shaping.

It is sufficient to expand things like ligatures, but there's something
slightly off about how the metrics are computed and they differ slightly
from the freetype renderer, which leads to some artifacts when rendering
with opengl.

One of my tests is to `grep message src/main.rs` to pull out the line
that has a selection of emoji.  The heart emoji is missing from that
line currently.

Refs: https://github.com/wez/wezterm/issues/66
2019-12-14 08:46:06 -08:00
Wez Furlong 00b9f188f3 window: improve avx bounds check 2019-11-28 09:00:13 -08:00
Wez Furlong 517084ff2f clippy 2019-11-24 07:20:41 -08:00
Wez Furlong e3f6375551 fix brightness/color of emoji in the opengl renderer 2019-11-03 22:01:35 -08:00
Wez Furlong 4116d7d523 remove byte-swapping workaround for opengl
We handle this with a temporary buffer for the upload, which is
a little gross but avoids leaking that implementation aspect
out to the rest of the code.
2019-10-27 10:07:14 -07:00
Wez Furlong d97a84f984 render iterm2 image protocol in the software renderer
This is still a bit rough because the terminal parser doesn't
understand the pixel sizes, so it relies on the hard coded
cell dimensions being accurate.
2019-10-26 23:30:39 -07:00
Wez Furlong c6ce005b2a make new opengl frontend basically work on macos
It doesn't yet handle underlines or strikethrough.
Notably, live resizing now works, which is nice!
2019-10-24 08:27:11 -07:00
Wez Furlong 999e651b17 window: impl Texture2d for SrgbTexture2d 2019-10-07 08:34:54 -07:00
Wez Furlong 378e7b326f only use simd if the region is wide enough
Refs: https://github.com/wez/wezterm/issues/40
2019-10-07 07:41:11 -07:00
Wez Furlong 85311373a5 clippy 2019-10-01 22:20:52 -07:00
Wez Furlong 29095f8560 software: remove a little bit of overhead from draw_image 2019-09-30 08:36:23 -07:00
Wez Furlong b2212c3105 software: improve alpha blending for draw_line 2019-09-30 08:17:47 -07:00
Wez Furlong b5e07005b7 software: fix aligment check 2019-09-30 07:52:31 -07:00
Wez Furlong b0efba9300 improve linear f32 -> srgb8 conversion
This uses a combination of lookup tables and simd to reduce the
cpu utilization by about ~15% compared to the prior brute force
implementation.
2019-09-30 00:45:35 -07:00
Wez Furlong 07fcc96f5a window: disable alignment based optimization for fill_pixel 2019-09-29 20:59:20 -07:00
Wez Furlong c6fd88d8c5 add basic simd support for clearing rectangles 2019-09-29 20:24:26 -07:00
Wez Furlong 569408de66 software: handle OutOfTextureSpace condition 2019-09-29 12:42:51 -07:00
Wez Furlong 389c477b16 software: ligatures now render, but scaled emoji need work 2019-09-28 10:06:47 -07:00
Wez Furlong 8e38f34b6d fix a couple of warnings 2019-09-22 21:02:02 -07:00
Wez Furlong 68f81e23f7 software render can now render basic glyphs 2019-09-22 08:12:52 -07:00
Wez Furlong 0d7d438270 separate Sprite and SpriteSlice impls 2019-09-21 14:25:12 -07:00
Wez Furlong 709990b9e7 use euclid crate for point/rect 2019-09-21 13:05:50 -07:00
Wez Furlong 3dce78bd9c copy and adapt our opengl texture atlas code for the window crate 2019-09-21 09:00:08 -07:00
Wez Furlong 050dde6b4f clean up draw_image api 2019-09-21 07:44:28 -07:00
Wez Furlong 896586809f add Rect::bottom_right 2019-09-21 07:31:44 -07:00
Wez Furlong 6d902d8a39 introduce a Rect type 2019-09-21 00:19:31 -07:00
Wez Furlong 6d23be0164 use Image to generate underline glyphs 2019-09-15 19:09:08 -07:00
Wez Furlong e6265c93a4 add arbitrary line drawing with anti-aliasing 2019-09-15 19:09:08 -07:00
Wez Furlong 311760df90 introduce a paint context trait 2019-09-15 19:09:08 -07:00
Wez Furlong a88f0f1beb improve performance for clear operations 2019-09-15 19:09:08 -07:00