aboutsummaryrefslogtreecommitdiff
path: root/src/renderer
AgeCommit message (Collapse)Author
2017-01-02Rework font loadingJoe Wilm
This work started because we wanted to be able to simply say "monospace" on Linux and have it give us some sort of font. The config format for fonts changed to accomodate this new paradigm. As a result, italic and bold can have different families from the normal (roman) face. The fontconfig based font resolution probably works a lot better than the CoreText version at this point. With CoreText, we simply iterate over fonts and check it they match the requested properties. What's worse is that the CoreText version requires a valid family. With fontconfig, it will just provide the closest matching thing and use it (unless a specific style is requested).
2017-01-01Improve error handling for shader initializationJoe Wilm
Shader initialization errors at startup should print a nice message now.
2016-12-31Print nice error messages for font loading errorsJoe Wilm
Resolves #22.
2016-12-31Propagate font rasterizer errorsJoe Wilm
This allows consumers of the font crate to handle errors instead of the library panicking.
2016-12-29Add super hacky underline drawingJoe Wilm
Using underscores because it's easy. It's also wrong. cc #11
2016-12-16Misc formatting fixesJoe Wilm
2016-12-16Rustup and clippyJoe Wilm
All of the changes in this commit are due to clippy lints.
2016-12-11Cleaning up main; Added window moduleJoe Wilm
Adds a wrapper for the glutin::Window which provides strongly typed APIs and more convenient interfaces. Moves some gl calls into the opengl-based renderer. The point of most of the changes here is to clean up main().
2016-12-11Refactor color list managementJoe Wilm
There's now a ColorList type that provides strongly typed indexing for not only usize but NamedColor as well. Previously, the `NamedColor` was casted to a `usize` when indexing the colors. Additionally, only one copy of the ColorList needs to exist;it's borrowed from the `Config` when rendering, and the renderer doesn't need a copy.
2016-12-11Add support for indexed colorsJoe Wilm
ANSI escape sequences like `\x1b[48;5;10m` were not supported until now. Specifically, the second attribute, 5, says that the following attribute is a color index. The ref tests were updated since `enum Color` variants changed.
2016-12-11Rename RenderApi::render_grid() to render_cells()Joe Wilm
This probably should have been renamed in the original refactor, but oh well. `render_cells()` takes a generic parameter `I` which is any `Iterator<Item=IndexedCell>` and is thus no longer coupled to the grid type. Renaming it reflects that.
2016-12-11Refactor cell selection out of rendererJoe Wilm
The terminal now has a `renderable_cells()` function that returns a `RenderableCellIter` iterator. This allows reuse of the cell selection code by multiple renderers, makes it testable, and makes it independently optimizable. The render API now takes an `Iterator<Item=IndexedCell>` to support both the new renderable cells iterator and the `render_string()` method which generates its own iterator. The `vim_large_window_scoll` ref test was added here because it provides a nice large and busy grid to benchmark the cell selection with.
2016-11-19Add support for recording/running ref testsJoe Wilm
Ref tests use a recording of the terminal protocol and a serialization of the grid state to check that the parsing and action handling systems produce the correct result. Ref tests may be recorded by running alacritty with `--ref-test` and closing the terminal by using the window "X" button. At that point, the recording is fully written to disk, and a serialization of important state is recorded. Those files should be moved to an appropriate folder in the `tests/ref/` tree, and the `ref_test!` macro invocation should be updated accordingly. A couple of changes were necessary to make this work: * Ref tests shouldn't create a pty; the pty was refactored out of the `Term` type. * Repeatable lines/cols were needed; on startup, the terminal is resized * by default to 80x24 though that may be changed by passing `--dimensions w h`. * Calculating window size based on desired rows/columns and font metrics required making load_font callable multiple times. * Refactor types into library crate so they may be imported in an integration test. * A whole bunch of types needed symmetric serialization and deserialization. Mostly this was just adding derives, but the custom deserialization of Rgb had to change to a deserialize_with function. This initially adds one ref test as a sanity check, and more will be added in subsequent commits. This initial ref tests just starts the terminal and runs `ll`.
2016-11-11Workaround for cutoff glyphsJoe Wilm
There's an issue where drawing the cell backgrounds will overwrite part of a neighboring glyph. The real solution here is to figure out glyph metrics properly, but simply limiting to 2 draw calls per frame (first background, then all the glyphs) makes the problem "go away".
2016-10-28Support drawing bold test with bright colorsJoe Wilm
This feature is on by default
2016-10-28Merge branch 'reload-colors'Joe Wilm
2016-10-28Set colors on CPUJoe Wilm
Indexing colors on the vertex shader added complexity and after profiling suggests perf is basically the same. This commit will still be here in case it makes sense to try this again at some point.
2016-10-27Move config reloading to separate threadJoe Wilm
This feature was previously shoved into the renderer due to initial proof of concept. Now, providing config updates to other systems is possible. This will be especially important for key bindings!
2016-10-27Live shader reloading is now a featureJoe Wilm
Which means it can be disabled in release builds. No more working on a renderer feature and actually breaking the Alacritty your editor is running inside.
2016-10-24Move color indexing to vertex shaderJoe Wilm
Move more work to GPU from CPU. Some very non-scientific profiling suggests this is implementation is more performant, but more work should be done there.
2016-10-24Fix some compiler warningsJoe Wilm
2016-10-23Proof of concept live reloading for colorsJoe Wilm
The architecture here is really poor. Need to move file watching into a dedicated location and probably have an spmc broadcast queue. other modules besides rendering will care about config reloading in the future.
2016-10-15Make colors configurable from fileJoe Wilm
Added solarized dark color scheme for testing purposes. Resolves #1.
2016-08-12Support bold/italic font rendering on macOSJoe Wilm
This patch adds support for rendering italic fonts and bold fonts. The `font` crate has a couple of new paradigms to support this: font keys and glyph keys. `FontKey` is a lightweight (4 byte) identifier for a font loaded out of the rasterizer. This replaces `FontDesc` for rasterizing glyphs from a loaded font. `FontDesc` had the problem that it contained two strings, and the glyph cache needs to store a copy of the font key for every loaded glyph. `GlyphKey` is now passed to the glyph rasterization method instead of a simple `char`. `GlyphKey` contains information including font, size, and the character. The rasterizer APIs do not define what happens when loading the same font from a `FontDesc` more than once. It is assumed that the application will track the resulting `FontKey` instead of asking the font to be loaded multiple times.
2016-07-16Fix bug rendering inverted cellsJoe Wilm
Cells with no content that had the cell::INVERSE flag were not being rendered. This was noticeable in `man` where the bar at the bottom would have gaps in it.
2016-07-04Fix some compiler warningsJoe Wilm
Unused things have been removed.
2016-07-04Use "invert" cursor instead of drawing blockJoe Wilm
The cursor now matches perfectly cell widths and actually shows the character underneath.
2016-07-03Move ::grid::index to ::indexJoe Wilm
The grid and term modules already rely on the index types, and ansi is about to be updated with strongly typed APIs. Since Cursor, Line, and Column are fundamental to the code in several modules, namespacing them under one of them seems less correct than a module that stands by itself.
2016-07-03Grid API is now generic and strongly typedJoe Wilm
The Grid no longer knows about a `Cell` and is instead generic. The `Cell` type is coupled to the `term` module already, and it's been moved there to reflect the strong relationship. Grid APIs previously accepted `usize` for many arguments. If the caller intended rows to be columns, but the function accepted them in reverse, there would be no compiler error. Now there is, and this should prevent such bugs from entering the code. The Grid internals grew significantly to accomodate the strongly typed APIs. There is now a `grid::index` module which defines Cursor, Line, and Column. The Grid APIs are all based on these types now. Indexing for Ranges proved to be somewhat awkward. A new range had to be constructed in the implementation. If the optimizer can't figure out what's going on in that case, the ranges may not be a zero-cost abstraction.
2016-06-29Add license headers to source filesJoe Wilm
2016-06-29Implement terminal resizingJoe Wilm
The resize event is received from glutin on the update thread, but the renderer needs to be informed as well for updating the viewport and projection matrix. This is achieved with an mpsc::channel. To support resizing, the grid now offers methods for growing and shrinking, and there are several implementations available for clear_region based on different Range* types. Core resize logic is all in Term::resize. It attempts to keep as much context as possible when shinking the window. When growing, it's basically just adding rows.
2016-06-28Refactor Tty and Grid creation into Term::newJoe Wilm
This moves more logic out of main() and prepares the Term type to handle resizing. By providing all size data to Term, it is now possible to implement a resize function there which handles all resizing logic save for the rendering subsystem.
2016-06-14Add support for macOSJoe Wilm
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!.
2016-06-09Fix all trivial compiler warningsJoe Wilm
Of note are the `ansi` and `grid` modules becoming public. There are several bits of unused code in each of these. In the case of `grid`, the unused parts are generally useful, like some indexing implementations. In ansi, there are pieces that will be used once the parser is more complete. In any case, these modules are fairly generic and mostly usable outside of Alacritty. Unused cargo packages were also removed.
2016-06-06Add support for drawing background colorsJoe Wilm
2016-06-06Support dynamic character loadingJoe Wilm
The glyph cache was previously initialized with a list of glyphs from INIT_LIST, and never updated again. This meant that code points not included in that list were not displayed. Now, the glyph cache has gained the ability to load new glyphs at render time. This seems to have lightly decreased performance for some reason.
2016-06-06Batching flushes on texture changeJoe Wilm
This fixes a bug when multiple atlases are required.
2016-06-06Refactor Instanced Drawing to use Vertex ArraysJoe Wilm
Per-instanced data was previously stored in uniforms. This required several OpenGL calls to upload all of the data, and it was more complex to prepare (several vecs vs one). Additionally, drawing APIs are now accessible through a `RenderApi` (obtained through `QuadRenderer::with_api`) which enables some RAII patterns. Specifically, checks for batch flushing are handled in Drop.
2016-06-04Optimize Rendering with batched draw callsJoe Wilm
Draw calls are now batched for performance. Render times on git log at the default size are now ~200usec.
2016-06-04Add iterator methods to Grid and Row typesJoe Wilm
The iterator methods simplify logic in the main grid render function. To disambiguate iterator methods from those returning counts (and to free up names), the `rows()` and `cols()` methods on `Grid` have been renamed to `num_rows()` and `num_cols()`, respectively.
2016-06-04Optimize renderingJoe Wilm
This moves some logic that was previously being done per-character into the vertex shader. At this time, we've traded CPU computation for additional gl::Uniform2f calls. This is only a marginal improvement. However, this patch positions the renderer well for instanced drawing, and that will be a huge performance win.
2016-06-04Add live-reload for shadersJoe Wilm
Recompiling the entire program whenever a shader changes is slow, and it can interrupt flow. Shader reloads are essentially instantaneous now. If the new shader fails to compile, no state is changed; the previous program continues to be used.
2016-06-03render: cleanup active_tex handlingJoe Wilm
- Removes a spammy printn! - Sets active_tex to zero wherever gl::BindTexture is called with zero
2016-06-03Move debug timerJoe Wilm
It was near the left side; it will be less in-the-way on the right.
2016-06-02Use texture atlas for glyphsJoe Wilm
This dramatically reduces the number of BindTexture calls needed when rendering the grid. Draw times for a moderately full terminal of the default size are ~1ms with this patch.
2016-06-02Refactor renderer functions out of main.rsJoe Wilm
This moves the rendering logic to draw the grid, to draw strings, and to draw the cursor into the renderere module. In addition to being an organizational improvement, this also allowed for some optimizations managing OpenGL state. Render times for a moderate screen of text dropped from ~10ms to ~4ms.
2016-06-02Initial support for Terminal Emulation (woo!)Joe Wilm
This patch introduces basic support for terminal emulation. Basic means commands that don't use paging and are not full screen applications like vim or tmux. Some paging applications are working properly, such as as `git log`. Other pagers work reasonably well as long as the help menu is not accessed. There is now a central Rgb color type which is shared by the renderer, terminal emulation, and the pty parser. The parser no longer owns a Handler. Instead, a mutable reference to a Handler is provided whenever advancing the parser. This resolved some potential ownership issues (eg parser owning the `Term` type would've been unworkable).
2016-05-21Add render time meterJoe Wilm
Optimization is impossible without measurement!
2016-05-20Correct sub-pixel font rendering with OpenGLJoe Wilm
Uses the GL_ARB_blend_func_extended to get single-pass, per-channel alpha blending. gl_generator is now used instead of gl to enable the extension. The background color is removed since that presumably needs to run in a separate pass.
2016-04-11Use subpixel font renderingJoe Wilm
OpenGL only supports shared alpha blending. Subpixel font rendering requires using the font RGB values as alpha masks for the corresponding RGB channels. To support this, blending is implemented in the fragment shader.