-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a canvas renderer #935
Comments
|
Looks super cool! But i have two questions: |
@lucat1 feedback welcome: var term = new Terminal({
fontSize: 10,
fontFamily: 'Hack',
lineHeight: 1.2
});
term.setOption('fontSize', 12);
term.setOption('fontFamily', 'courier');
term.setOption('lineHeight', 1);
term.setTheme({
background: '#333',
red: '#F00',
brightRed: '#F22',
// ... (can be a partial list)
}); The theme interface is currently: export interface ITheme {
foreground?: string;
background?: string;
cursor?: string;
black?: string;
red?: string;
green?: string;
yellow?: string;
blue?: string;
magenta?: string;
cyan?: string;
white?: string;
brightBlack?: string;
brightRed?: string;
brightGreen?: string;
brightYellow?: string;
brightBlue?: string;
brightMagenta?: string;
brightCyan?: string;
brightWhite?: string;
} |
This looks very promising and performance improvements are always welcome😍 As feedback I have two ideas:
Then I have a few questions:
I really love the idea of canvas, and I really hope it will give better performance especially when resizing since both in Electron and on the web it's quite laggy. |
@lucat1 great feedback/questions 😃
I was actually thinking this as I wrote up my comment 😄; could just make it an option so it works in the constructor too.
I think there is
Good ideas. This sort of thing did cross my mind, maybe "themes" and "colors" should be differentiated. Maybe this could be a good idea for an addon, it could bundle multiple names themes and expose
The 256 colors include the 16 ansi colors defined in the theme. The others (240) cannot be changed. I don't think it's a good idea to allow people to change this as they have strictly defined colors. True color can be supported fairly easily, it just needs the buffer memory improvements to come #791
There is still some CSS, but it's very slim now as there are no color styles, no cursor styles, no link styles, etc.
In the current model this would need to be a setting. |
One thing I am concerned about (and I am still all for canvas rendering) is that I also pull out HTML from |
Do you mean saving and restoring the current buffer? There's the serialization stuff that's planned for v3 still #613 when @parisk frees up, we're targeting November so there's still plenty of time. If worst comes to worst you can stick on 2.9 until it's supported. If you just need to pull out the data then you could reach into the |
I did mean just "pulling out the data" but I did want to preserve styling. Would that still be possible? |
@vincentwoo harder but still doable, may break across versions of course. You can grab character data off the buffer object, they include attributes on the characters which encode the color/style. |
Canvas renderer is way too slow for me. I need 60 fps full screen random characters and attributes buttery smoothness. My use case is a full screen roguelike browser game. What about opening up this api for custom renderers? I know #1294 is on the way but I was thinking about something more webgl-y https://www.eventbrite.com/engineering/its-2015-and-drawing-text-is-still-hard-webgl-threejs/ cheers 🍻 |
A full webgl approach may be able to boost perf more, it would be fun to experiment to see how much time could be saved by using it. Currently I'm working in the opposite direction; a fallback to DOM since some systems don't handle canvas/webgl solutions #1360 |
@Tyriar For my typical benchmark call Maybe it is worth to investigate a cell based redraw thingy, idk ... (just wanted to let you know, I am not familiar with that part of the emulator anyway) |
@odrzutowiec Might be better to open a new issue since the original one is about having a canvas renderer at all and therefore closed while your issue is more about a specific performance detail... Btw Im pretty sure you are seeing the non atlas cached performance for the canvas thing here, which might raise a different question (more clever atlas caching strategy?) |
@jerch that's how it was, and yeah it was a lot faster. The reason it switched back is because characters need to overlap in order for parts of characters not to be cut off. I plan on getting to minimizing draws eventually. @odrzutowiec that does seem a bit slow, what browser/version/os are you on? Let's create a separate issue to discuss. Also only ascii is optimized currently, there's a lot of opportunity to speed up for non-ascii characters. |
A work in progress is already well under way. The performance benefits seem to far outweigh anything that can be accomplished in the DOM.
The main drawbacks of using canvas over the DOM:
<a>
and just put it somewhere. This needs more handling code to work in a canvas.I'll list most of the improvements and bug fixes that canvas provided in the PR which should be out soon 😄
Marking as breaking as we need new API around colors and font styles which will be managed in TS.
The text was updated successfully, but these errors were encountered: