46 Commits

Author SHA1 Message Date
David Herrmann
af31f251f3 console: merge console_cell.c into console.c
We currently have too much layers in the console subsystem. This reduces
performance and produces ugly hacks like our "*_clear_region" function. We
now merge both files so we can directly access the buffer-structure.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 14:34:55 +01:00
David Herrmann
096f0cadc7 Move to new uterm infrastructure
This fixes all compositor/output/context/etc. uses and replaces them by
the new uterm API.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 14:18:50 +01:00
David Herrmann
cdb3d112a6 vte: implement backspace control
Add new helper to console subsystem which performs a backspace
operation. We must take care of auto-wrap mode so we cannot simply use
the *_move_left() function.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 16:02:21 +01:00
David Herrmann
d3951da865 console: add helper to erase current position
This helper erases the current cursor position.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:14:45 +01:00
David Herrmann
b02e8c8332 console: fix pending-wrap bug in erase helpers
When erasing from the cursor position to line/screen end we must include
the current cursor position in the clear-region. We already did this but
missed the fact that there might be a pending-wrap so we might miss the
current position. Fix this.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:11:34 +01:00
David Herrmann
fb6dd53aa8 console: enable auto_wrap by default
vt100 have auto_wrap enabled by default so we should do so, too.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:10:12 +01:00
David Herrmann
9a5f1df8cd console: fix bug in *_erase_screen()
We must erase the whole screen and not only until the current cursor
position. Probably a copy-paste typo.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:06:06 +01:00
David Herrmann
5e53cda8f5 console: fix bug in *_move_left()
We must take care of pending-wraps when moving left so we do not miss a
single character.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:04:43 +01:00
David Herrmann
f0bcc37cee console: add to line movement helpers
Add two helpers to move to the end or home of the current line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 14:36:32 +01:00
David Herrmann
f85244ead9 console: add erase-helpers
Add functions to erase several parts of the screen.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-04 18:31:10 +01:00
David Herrmann
d8ff83c5cb console: add basic cursor movements
Add functions to move the cursor up/down/left/right. We must take care
of integer overflows here as the application may send us arbitrarily big
numbers.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-04 15:50:03 +01:00
David Herrmann
466fcc3b06 console: add auto-wrap mode
If auto-wrap mode is enabled we automatically advance the cursor to the
next line if we hit the end of line. Otherwise, we simply continue
overwriting the last character in the line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-04 15:49:14 +01:00
David Herrmann
497d3840dc console: add *_move_to() function
*_move_to() can be used to position the pointer at an arbitrary position
inside the buffer. If in relative-addressing mode, you cannot position
it outside the scroll-region, though.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-04 15:25:44 +01:00
David Herrmann
5a0ba19d91 console: make console wrapper margin aware
Keep reference to top-most and bottom-most line of scroll buffer in
console wrapper. The margin_top and margin_bottom indexes are different
from them used in the buffer handler! We use indexes now instead of line
counts. This makes the handling much easier.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-04 14:49:06 +01:00
David Herrmann
2b8caca91c console: remove *_buffer_newline()
This function is no longer needed as we now have proper scrolling
functions. This also adjusts the buffer tests to be more appropriate.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-04 14:34:33 +01:00
David Herrmann
af3a1f3e50 console: move kmscon_console_rotate to *_newline
We do no rotation so rename the function to the more appropriate name
kmscon_console_newline.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-02 17:01:54 +01:00
David Herrmann
5a3801386a font: rewrite font backend
We now properly draw fonts with OpenGL. We now use FreeType2 instead of
pango to avoid big dependencies.

We also add a DejaVu font so we currently don't have to deal with font
selection.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-22 22:44:12 +01:00
David Herrmann
7085084b1d context: use GL_TRIANGLES instead of GL_QUADS
GL_QUADS may actually be not supported on some embedded platforms so we
use GL_TRIANGLES.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-20 16:11:30 +01:00
David Herrmann
83cec439c6 console: use new drawing pipeline
Instead of drawing with fixed-function GL pipeline we now use our own
shader for texture drawing. This also fixes test_console to no longer
depend on GL.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-20 15:45:58 +01:00
David Herrmann
84f29458e5 console: avoid code duplication in cairo destruction code
We can use our destruction function to avoid code duplication.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-20 15:35:32 +01:00
David Herrmann
05a1747f00 console: take reference of compositor
To switch to the new drawing subsystem we need a reference to a valid
compositor object so we can retrieve the GL context.
This also applies to the terminal object.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-18 18:09:08 +01:00
Ran Benita
58b9f1fdb6 a few cosmetic changes
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-09 20:20:58 +01:00
David Herrmann
c203b3a83d font: move font handling into new subsystem
We use a new font factory which is used to create a new font. It will later also
be used to cache fonts and select proper system fonts.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 18:27:09 +01:00
David Herrmann
a7128cc683 Adjust all code to use new kmscon_symbol_t
This is a big performance boost and reduces the code size quite a bit.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 17:43:57 +01:00
David Herrmann
0f44dfdde8 test_console: fix console deinitialization bug
We must not destroy the compositor object if there is still a console using the
GL context. Otherwise we get a SEGFAULT when calling any gl* function.

In future we may need propoper dependencies here. We use reference counts so
this should be easy to implement.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-26 14:46:22 +01:00
David Herrmann
676b03cb5c console: add newline function
kmscon_console_newline() can be used to produce a newline. Writing \n doesn't
work as this would write \n as character into the cell and not produce a
newline.
The console does not perform any parsing so we provide a separate function.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-26 14:24:31 +01:00
David Herrmann
4ca6eeae82 console: calculate width by font
Remove the *_set_res() function entirely. Instead, the *_resize() function now
accepts a height argument which is used as quality hint. Internally, we compute
the texture width by the selected font plus the given height. This simplifies
the API and the internal handling and improves output on non-standard
resolutions or with non-standard fonts.
Until now it was only optimized for my 16x9 output but 5x4 output was quite
garbled.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-26 12:45:54 +01:00
David Herrmann
a20e5c3a18 console: allow resizing the console
Forward resizing requests to the buffer but correctly update our size cache and
the cursor position.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-21 16:39:51 +01:00
David Herrmann
d75404742b console: support writing to console
Add kmscon_console_write() to write a character to the current position of the
cursor. The cursor is automatically moved to the next cell.

Also extend the test_console example to use this new function.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-21 16:30:06 +01:00
David Herrmann
fbd9446135 console: use new buffer implementation
Use the new kmscon_buffer in the console subsystem.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-18 12:58:47 +01:00
David Herrmann
0d1acc526f Change license to MIT license
Further commits will need a Signed-off-by line, otherwise I cannot accept them.
MIT license is compatible with GPL so we still can switch to GPL in the future
if we want.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-02 13:23:22 +01:00
David Herrmann
6072bf445f Console: Fix cell-selection when drawing glyphs
We didn't calculate the correct cell number when drawing a cell. Fix that.

Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-01 18:33:49 +01:00
David Herrmann
77963ec305 Add kmscon_console_write() function
This function can be used to change the content of the current cell. It
automatically moves the cursor to the next cell.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-27 19:31:26 +01:00
David Herrmann
0cf9a7a03c Add cursor movement helpers
Add functions to move the cursor of a console.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-27 15:50:59 +01:00
David Herrmann
c4d6c554fd Calculate font size properly
We set the font size to the absolute size we have per cell instead of using a
fixed font-size.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 17:12:17 +01:00
David Herrmann
607a5eed54 Set console resolution to 800x600 by default
This sets the console resolution to 800x600 on startup. We no longer have a
console with an invalid resolution after startup so we now can start calculating
font sizes properly.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 17:04:52 +01:00
David Herrmann
7149b5dd37 Draw console
Properly draw all cells of a console on redraw.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 16:54:40 +01:00
David Herrmann
c8855d47b2 Reset cairo surface when drawing console
We must use SOURCE operator to reset the surface. Otherwise, we end up doing
nothing here because our alpha value is 0.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 16:48:59 +01:00
David Herrmann
c455d8f9f0 Set each cell to '?' for testing purposes
Each cell of a console is initialized to '?' to allow testing the glyph
operations.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 16:47:50 +01:00
David Herrmann
8b93b07db3 Refresh texture when redrawing console
We need to refresh the GL texture data when redrawing the console. Otherwise, we
always end up with the first frame mapped onto the GL quad object.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 16:46:44 +01:00
David Herrmann
27047fddbf Create font when resizing console
When resizing a kmscon_console object we automatically create a new font because
all cached objects get invalid now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 16:43:17 +01:00
David Herrmann
bab0068bed Set default console size to 80x24
Create for every new console a default cell-size of 80x24.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 18:25:59 +01:00
David Herrmann
9a853a796f Add cells to console objects
A console has a fixed line and column count. Each entry is represented by a
kmscon_cell object. The console can be resized on the fly.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 18:21:41 +01:00
David Herrmann
173d38c0f5 Add console drawing-logic
A console may be displayed on multiple outputs. We allow different screen
resolutions on these outputs so we need a way to map the console image onto
different outputs.

We simply render the console image into a cairo surface with a user-given
resolution. This should be set to the highest resultion of the used outputs. The
application can now map this image onto the different framebuffers. This will
scale the image if the target framebuffer is smaller than the cairo surface.

We also do not clear the framebuffer. This should be done by the user. This
allows us to draw with alpha values and blend the console on top of the current
framebuffer. We do not have to care for background images and the application
has full control of where the console is shown.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 17:49:21 +01:00
David Herrmann
cfdbaeb50e Fix kmscon_console_unref name
The name of the unref function was wrong. Fix this from kmscon_con_unref to
kmscon_console_unref.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 15:47:23 +01:00
David Herrmann
f85eb100f9 Add console subsystem dummy
Add dummy files for the console subsystem. This subsystem will be used to draw a
console to a framebuffer. It uses pango and cairo for text-rendering and will
provide all required modification functions that the terminal emulation will
require.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 00:41:15 +01:00