diff options
author | Joe Wilm <joe@jwilm.com> | 2016-06-09 20:39:40 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-06-14 07:39:06 -0700 |
commit | bd8bd26c8bd6f9dfc988e222b57a71cf94902c4d (patch) | |
tree | 5e7211ac03e5481b8fb8b89f3b6c6a4246247f29 /src/renderer/mod.rs | |
parent | 2395066318fea516bc0efbc7aecfb90a0d2548da (diff) |
Add support for macOS
Alacritty now runs on macOS using CoreText for font rendering.
The font rendering subsystems were moved into a separate crate called
`font`. The font crate provides a unified (albeit limited) API which
wraps CoreText on macOS and FreeType/FontConfig on other platforms. The
unified API differed slightly from what the original Rasterizer for
freetype implemented, and it was updated accordingly.
The cell separation properties (sep_x and sep_y) are now premultiplied
into the cell width and height. They were previously passed through as
uniforms to the shaders; removing them prevents a lot of redundant work.
`libc` has some differences between Linux and macOS. `__errno_location`
is not available on macOS, and the `errno` crate was brought in to
provide a cross-platform API for dealing with errno.
Differences in `openpty` were handled by implementing a macOS specific
version. It would be worth investigating a way to unify the
implementations at some point.
A type mismatch with TIOCSCTTY was resolved with a cast.
Differences in libc::passwd struct fields were resolved by using
std::mem::uninitialized instead of zeroing the struct ourselves. This
has the benefit of being much cleaner.
The thread setup had to be changed to support both macOS and Linux.
macOS requires that events from the window be handled on the main
thread. Failure to do so will prevent the glutin window from even
showing up! For this reason, the renderer and parser were moved to their
own thread, and the input is received on the main thread. This is
essentially reverse the setup prior to this commit. Renderer
initialization (and thus font cache initialization) had to be moved to
the rendering thread as well since there's no way to make_context(null)
with glx on Linux. Trying to just call make_context a second time on the
rendering thread had resulted in a panic!.
Diffstat (limited to 'src/renderer/mod.rs')
-rw-r--r-- | src/renderer/mod.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index a0051aaa..dff20070 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -13,7 +13,7 @@ use gl::types::*; use gl; use notify::{Watcher as WatcherApi, RecommendedWatcher as Watcher, op}; -use text::{Rasterizer, RasterizedGlyph, FontDesc}; +use font::{Rasterizer, RasterizedGlyph, FontDesc}; use grid::{self, Grid, Cell, CellFlags}; use term; @@ -45,9 +45,6 @@ pub struct ShaderProgram { /// Cell dimensions (pixels) u_cell_dim: GLint, - /// Cell separation (pixels) - u_cell_sep: GLint, - /// Background pass flag /// /// Rendering is split into two passes; 1 for backgrounds, and one for text @@ -649,24 +646,22 @@ impl ShaderProgram { } // get uniform locations - let (projection, term_dim, cell_dim, cell_sep, background) = unsafe { + let (projection, term_dim, cell_dim, background) = unsafe { ( gl::GetUniformLocation(program, cptr!(b"projection\0")), gl::GetUniformLocation(program, cptr!(b"termDim\0")), gl::GetUniformLocation(program, cptr!(b"cellDim\0")), - gl::GetUniformLocation(program, cptr!(b"cellSep\0")), gl::GetUniformLocation(program, cptr!(b"backgroundPass\0")), ) }; - assert_uniform_valid!(projection, term_dim, cell_dim, cell_sep); + assert_uniform_valid!(projection, term_dim, cell_dim); let shader = ShaderProgram { id: program, u_projection: projection, u_term_dim: term_dim, u_cell_dim: cell_dim, - u_cell_sep: cell_sep, u_background: background, }; @@ -690,7 +685,6 @@ impl ShaderProgram { unsafe { gl::Uniform2f(self.u_term_dim, props.width, props.height); gl::Uniform2f(self.u_cell_dim, props.cell_width, props.cell_height); - gl::Uniform2f(self.u_cell_sep, props.sep_x, props.sep_y); } } |