summaryrefslogtreecommitdiff
path: root/src/renderer
AgeCommit message (Collapse)Author
2017-09-05Update notifyJonathan Schleußer
2017-08-20Add background_opacity option to set terminal transparency (#331)Gabriel Martinez
The option is an Alpha struct that ensures that the contained float is between 0.0 and 1.0. Background colors are multiplied by the opacity to properly alpha blend them.
2017-07-28Support background and foreground color escape codes (#662)Tuomas Siipola
2017-07-03Revert "Reduce InstanceData footprint"Joe Wilm
This reverts commit 3cdba291242cc1c1684bff7f8242262b1cdeb582. On some systems, the target commit actually caused a massive performance issue rather than fixing one.
2017-07-01Reduce InstanceData footprintJoe Wilm
The InstanceData type in the rendering subsystem was previously 16 floats which occupied a total of 64 bytes per instance. This meant that for every character or background cell drawn, 64 bytes were sent to the GPU. In the case of a 400x100 cell grid, a total of 2.5MB would be sent. This patch reduces InstanceData's size to 26 bytes, a 60% improvement! Using the above example for comparison, a worst case of 1MB would be transferred. The motivation for this patch comes from macOS. Once the terminal grid would reach a certain size, performance experienced a sharp and dramatic drop (render times would go from ~3ms to ~16ms). I don't want to speculate too much on the underlying issue, but suffice it to say that this patch alleviates the problem in my testing.
2017-06-01avoid named field shorthandMartin Algesten
2017-05-31somewhat DRYer code for font loadingMartin Algesten
2017-05-06Work around ICEJoe Wilm
2017-05-06Add window padding optionTuomas Siipola
Padding can be configured by using the `padding` field in the config file, like so: padding: x: 2 y: 2 which would result in a 2px padding within each side of the window.
2017-05-06Fix glyph offsets in cellJoe Wilm
We previously had a hard-coded value for aligning glyphs within cells. The font descent is now used, and the offset should be correct by default.
2017-05-01Combine FontOffset and GlyphOffset structs into Delta structAaron Williamson
The two structs are very similar, so there is no reason for them to be separate. Instead combine them into a single Delta struct, which can be used to shift a point in a two dimensional plane.
2017-05-01Add glyph offset option to user configurationAaron Williamson
Add the ability to move glyphs within their cells on a global basis via an option in the configuration file.
2017-05-01Remove unnecessary size argument to metrics functionAaron Williamson
The changes to metric consumption rendered the size argument unnecessary, remove it.
2017-02-11Move color list to Term structJoe Wilm
The color list needs to be updated by the parser, and this isn't possible if it's on the config. This change makes sense semantically as well since it's really part of the terminal state. This is in preparation for OSC color parsing.
2017-02-07Add visual bell supportMark Andrus Roberts
This commit adds support for a visual bell. Although the Handler in src/ansi.rs warns "Hopefully this is never implemented", I wanted to give it a try. A new config option is added, `visual_bell`, which sets the `duration` and `animation` function of the visual bell. The default `duration` is 150 ms, and the default `animation` is `EaseOutExpo`. To disable the visual bell, set its duration to 0. The visual bell is modeled by VisualBell in src/term/mod.rs. It has a method to ring the bell, `ring`, and another method, `intensity`. Both return the "intensity" of the bell, which ramps down from 1.0 to 0.0 at a rate set by `duration` and `animation`. Whether or not the Processor waits for events is now configurable in order to allow for smooth drawing of the visual bell.
2017-01-26Optimize glyph cache accessJoe Wilm
Loading a glyph from the cache is a very hot operation in the renderer. The original implementation would first check if a glyph was loaded and then call `get()` which would have to search a second time. This showed up as a very slow point in profiles. This patch addresses glyph cache access in two ways: by using a faster hasher optimized for small keys (fnv), and by using the entry API for fetching a cached glyph. The `fnv` hasher is faster than the default and is very efficient for small keys. Using the entry API on the HashMap means only 1 lookup instead of two. The entry API has a downside where the key needs to get cloned on fetches. Reducing the GlyphKey width to 64-bits helps in both areas. Copying an 8-byte wide type is very cheap and thus limits downside of the entry API. The small width also helps with the hasher performance. Over all, this patch reduced typical render times by several hundred microseconds on a 2013 MacBook Pro with a full screen terminal full of text.
2017-01-23Use the log-crate instead of printing to stdoutLukas Lueg
2017-01-06Remove need for inclusive rangesManish Goregaokar
2017-01-05Fix ARMTaylor Trump
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.