Move renderer from alacritty_terminal to alacritty

This commit is contained in:
Kirill Chibisov 2019-11-23 20:08:52 +03:00 committed by Christian Duerr
parent 624b3e2189
commit 474032742b
14 changed files with 48 additions and 70 deletions

4
Cargo.lock generated
View File

@ -29,7 +29,9 @@ dependencies = [
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"font 0.1.0",
"gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.22.0-alpha5 (git+https://github.com/chrisduerr/glutin)",
"image 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
@ -56,9 +58,7 @@ dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"copypasta 0.6.0",
"dunce 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"font 0.1.0",
"gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -14,6 +14,7 @@ clap = "2"
log = "0.4"
time = "0.1.40"
env_logger = "0.7.1"
fnv = "1"
serde = { version = "1", features = ["derive"] }
serde_yaml = "0.8"
serde_json = "1"
@ -26,6 +27,7 @@ font = { path = "../font" }
urlocator = "0.1.0"
[build-dependencies]
gl_generator = "0.14.0"
rustc_tools_util = "0.2.0"
[target.'cfg(not(windows))'.dependencies]

View File

@ -12,7 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use gl_generator::{Api, Fallbacks, GlobalGenerator, Profile, Registry};
use std::env;
use std::fs::File;
use std::path::Path;
fn main() {
let hash = rustc_tools_util::get_commit_hash().unwrap_or_default();
println!("cargo:rustc-env=GIT_HASH={}", hash);
let dest = env::var("OUT_DIR").unwrap();
let mut file = File::create(&Path::new(&dest).join("gl_bindings.rs")).unwrap();
Registry::new(Api::Gl, (4, 5), Profile::Core, Fallbacks::All, ["GL_ARB_blend_func_extended"])
.write_bindings(GlobalGenerator, &mut file)
.unwrap();
}

View File

@ -16,22 +16,13 @@
use std::cmp;
use serde::Deserialize;
use alacritty_terminal::ansi::CursorStyle;
use font::{Metrics, RasterizedGlyph};
use crate::ansi::CursorStyle;
/// Width/Height of the cursor relative to the font width
pub const CURSOR_WIDTH_PERCENTAGE: i32 = 15;
/// A key for caching cursor glyphs
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash, Deserialize)]
pub struct CursorKey {
pub style: CursorStyle,
pub is_wide: bool,
}
pub fn get_cursor_glyph(
cursor: CursorStyle,
metrics: Metrics,

View File

@ -32,14 +32,14 @@ use alacritty_terminal::event::{Event, OnResize};
use alacritty_terminal::index::Line;
use alacritty_terminal::message_bar::MessageBuffer;
use alacritty_terminal::meter::Meter;
use alacritty_terminal::renderer::rects::{RenderLines, RenderRect};
use alacritty_terminal::renderer::{self, GlyphCache, QuadRenderer};
use alacritty_terminal::selection::Selection;
use alacritty_terminal::term::color::Rgb;
use alacritty_terminal::term::{RenderableCell, SizeInfo, Term, TermMode};
use crate::config::Config;
use crate::event::{DisplayUpdate, Mouse};
use crate::renderer::rects::{RenderLines, RenderRect};
use crate::renderer::{self, GlyphCache, QuadRenderer};
use crate::url::{Url, Urls};
use crate::window::{self, Window};

View File

@ -51,13 +51,20 @@ use alacritty_terminal::tty;
mod cli;
mod config;
mod cursor;
mod display;
mod event;
mod input;
mod logging;
mod renderer;
mod url;
mod window;
mod gl {
#![allow(clippy::all)]
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
}
use crate::cli::Options;
use crate::config::monitor::Monitor;
use crate::config::Config;

View File

@ -26,17 +26,16 @@ use font::{self, FontDesc, FontKey, GlyphKey, Rasterize, RasterizedGlyph, Raster
use log::{error, info};
use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use crate::config::{self, Config, Delta, Font, StartupMode};
use crate::cursor::{get_cursor_glyph, CursorKey};
use crate::cursor;
use crate::gl;
use crate::gl::types::*;
use crate::index::{Column, Line};
use crate::renderer::rects::RenderRect;
use crate::term::cell::{self, Flags};
use crate::term::color::Rgb;
use crate::term::SizeInfo;
use crate::term::{self, RenderableCell, RenderableCellContent};
use crate::util;
use alacritty_terminal::config::{self, Config, Delta, Font, StartupMode};
use alacritty_terminal::index::{Column, Line};
use alacritty_terminal::term::cell::{self, Flags};
use alacritty_terminal::term::color::Rgb;
use alacritty_terminal::term::{self, CursorKey, RenderableCell, RenderableCellContent, SizeInfo};
use alacritty_terminal::util;
pub mod rects;
@ -1016,7 +1015,7 @@ impl<'a, C> RenderApi<'a, C> {
// Raw cell pixel buffers like cursors don't need to go through font lookup
let metrics = glyph_cache.metrics;
let glyph = glyph_cache.cursor_cache.entry(cursor_key).or_insert_with(|| {
self.load_glyph(&get_cursor_glyph(
self.load_glyph(&cursor::get_cursor_glyph(
cursor_key.style,
metrics,
self.config.font.offset.x,

View File

@ -15,10 +15,10 @@ use std::collections::HashMap;
use font::Metrics;
use crate::index::{Column, Point};
use crate::term::cell::Flags;
use crate::term::color::Rgb;
use crate::term::{RenderableCell, SizeInfo};
use alacritty_terminal::index::{Column, Point};
use alacritty_terminal::term::cell::Flags;
use alacritty_terminal::term::color::Rgb;
use alacritty_terminal::term::{RenderableCell, SizeInfo};
#[derive(Debug, Copy, Clone)]
pub struct RenderRect {

View File

@ -7,13 +7,13 @@ use urlocator::{UrlLocation, UrlLocator};
use font::Metrics;
use alacritty_terminal::index::Point;
use alacritty_terminal::renderer::rects::{RenderLine, RenderRect};
use alacritty_terminal::term::cell::Flags;
use alacritty_terminal::term::color::Rgb;
use alacritty_terminal::term::{RenderableCell, RenderableCellContent, SizeInfo};
use crate::config::{Config, RelaxedEq};
use crate::event::Mouse;
use crate::renderer::rects::{RenderLine, RenderRect};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Url {

View File

@ -37,11 +37,11 @@ use x11_dl::xlib::{Display as XDisplay, PropModeReplace, XErrorEvent, Xlib};
use alacritty_terminal::config::{Decorations, StartupMode, WindowConfig};
use alacritty_terminal::event::Event;
use alacritty_terminal::gl;
#[cfg(not(windows))]
use alacritty_terminal::term::{SizeInfo, Term};
use crate::config::Config;
use crate::gl;
// It's required to be in this directory due to the `windows.rc` file
#[cfg(not(target_os = "macos"))]

View File

@ -3,7 +3,6 @@ name = "alacritty_terminal"
version = "0.4.1-dev"
authors = ["Joe Wilm <joe@jwilm.com>"]
license = "Apache-2.0"
build = "build.rs"
description = "Library for writing terminal emulators"
readme = "../README.md"
homepage = "https://github.com/jwilm/alacritty"
@ -21,7 +20,6 @@ vte = "0.3"
mio = "0.6"
mio-extras = "2"
log = "0.4"
fnv = "1"
unicode-width = "0.1"
base64 = "0.10.0"
terminfo = "0.6.1"
@ -51,8 +49,5 @@ live-shader-reload = []
nightly = []
bench = []
[build-dependencies]
gl_generator = "0.14.0"
[dev-dependencies]
serde_json = "1.0.0"

View File

@ -1,28 +0,0 @@
// Copyright 2016 Joe Wilm, The Alacritty Project Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use gl_generator::{Api, Fallbacks, GlobalGenerator, Profile, Registry};
use std::env;
use std::fs::File;
use std::path::Path;
fn main() {
let dest = env::var("OUT_DIR").unwrap();
let mut file = File::create(&Path::new(&dest).join("gl_bindings.rs")).unwrap();
Registry::new(Api::Gl, (4, 5), Profile::Core, Fallbacks::All, ["GL_ARB_blend_func_extended"])
.write_bindings(GlobalGenerator, &mut file)
.unwrap();
}

View File

@ -24,7 +24,6 @@ extern crate objc;
pub mod ansi;
pub mod clipboard;
pub mod config;
mod cursor;
pub mod event;
pub mod event_loop;
pub mod grid;
@ -33,7 +32,6 @@ pub mod locale;
pub mod message_bar;
pub mod meter;
pub mod panic;
pub mod renderer;
pub mod selection;
pub mod sync;
pub mod term;
@ -42,8 +40,3 @@ pub mod util;
pub use crate::grid::Grid;
pub use crate::term::Term;
pub mod gl {
#![allow(clippy::all)]
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
}

View File

@ -27,7 +27,6 @@ use crate::ansi::{
};
use crate::clipboard::{Clipboard, ClipboardType};
use crate::config::{Config, VisualBellAnimation, DEFAULT_NAME};
use crate::cursor::CursorKey;
use crate::event::{Event, EventListener};
use crate::grid::{
BidirectionalIterator, DisplayIter, Grid, GridCell, IndexRegion, Indexed, Scroll,
@ -161,6 +160,13 @@ impl<T> selection::Dimensions for Term<T> {
}
}
/// A key for caching cursor glyphs
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash, Deserialize)]
pub struct CursorKey {
pub style: CursorStyle,
pub is_wide: bool,
}
/// Iterator that yields cells needing render
///
/// Yields cells that require work to be displayed (that is, not a an empty