This adds an OpenGL text renderer. It uses textures to store glyph
information and renders the characters by assembling a vertex-list first.
To improve performance, we use texture-atlases.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This reworks the text renderer system to make it easier to write backends.
We also allow returning errors during rendering now.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We should reset all used vertex-attrib-arrays, otherwise, we have to reset
them before drawing as we cannot sure that some other renderer left them
on.
As a rule we always assume a reset state similar to our assumption that no
VBO is bound during rendering.
This is a quite bad side-effect from OpenGL being a state-machine. As we
are a library, we cannot make any undocumented assumptions about the
OpenGL state. Therefore, we try to be as strict as possible.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This allows configuring the bblit backend during kmscon-build. If other
rendering backends are preferred, you can now compile kmscon without the
bblit backend.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This implements the static 2D blitting callbacks for the DRM backend. It
uses OpenGL to push the images with textures through the rendering
pipeline. Please note that this is horribly slow when used like 2D
blitting. However, it is a safe backend and better than nothing.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We currently return "true" if the hashtable is invalid which is
irritating. Fix this to be "false".
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We need to hash the key instead of the whole entry, otherwise, we have
dead/wrong entries in the hash-table after a rehash-round.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
These are the same helpers that were previously removed, however, they are
now part of the static-kmscon library and can be stripped away by the
linker.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The genshader program now takes all input shaders as arguments so we can
easily add new shaders. We also name the constants after the shader file
to be as flexible as possible.
This also moves the generated shaders into the static-kmscon library. The
linker will strip unused symbols, anyway, so we aren't loosing anything
here.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The static-* code does not depend on the log subsystem so it should not
include the header nor define some internal logging helpers.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The bit-blitting renderer does not really use the helper structure so
remove it and simplify the code a lot.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We are in a state where redrawing the console can take a significant
amount of time on slower machines. Therefore, we definitely need gcc code
optimizations which help here a _lot_. However, they are currently bundled
to the debug flags.
This splits this into two options. We still need this flag to get getter
backtraces. Otherwise, those inlined functions are horrible to track done.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
As gcc is not aware of out list-semantics, it warns about uninitialized
variables when in fact we know that they must be initialized. Suppress
some by initializing the variables to NULL.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The console layer guarantees that all glyphs are sent to the renderer so
there is no need to clear the screen before redrawing.
This reduces flickering of single-buffered video backends.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The freetype2 renderer uses ft2 and fontconfig to provide a very
simplistic renderer. We also simplify the logic of the whole subsystem a
lot and guarantee that each glyph will have the same size now.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When compiling without xkbcommon we currently get compiler errors as the
uxkb_available variable hasn't been correctly renamed previously.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This fixes the console and terminal layer to use the new text renderer
instead of the old one.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Whoops, we were checking the wrong variable. Fix the OOM check to
correctly catch the right errors.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The bblit text-renderer is the most basic renderer which simply blits or
blends the glyphs into the framebuffer memory. It cannot be used with
displays that do not provide framebuffer access but only 3D access.
However, 3D rendering is currently broken, anyway, so we can ignore it.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The text-renderer subsystem provides a way to register arbitrary
text-rendering backends. These backends use the font-objects to draw the
console into a framebuffer.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We need to actually increase the character count, otherwise, we will never
have a measurement set.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
VPA and VPR are used to change the current line but keep the column. One
does an absolute positioning and one a relative positioning.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
SU and SD are used to scroll-up and scroll-down the visible buffer.
Margins are kept and the cursor position does not change. This is a valid
vt510 CSI.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Xterm supports CSIs which simply move the visible buffer up/down so we
need these helpers to perform such operations from the VTE layer.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When drawing single glyphs we often have the glyph as alpha-only buffer so
we can draw it with any color we want. blit() requires a full image that
can be copied, so the new blend() helper is introduced which takes a
foreground and background color and blends in an image. Only plain-alpha
buffers are currently supported.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Whoops, we missed the last line for all blit()/fill() operations. Fix the
decrement to correctly count as many lines as given.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The dummy fbdev backend included this function to allow outside access to
the framebuffer. This has for long been replaced with blit() and fill()
helpers and it was never actually implemented. Hence, remove the helper
function.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When opengl rendering is not available on the target device, we now fall
back to software rendering. Instead of drawing a nice gradient we now draw
a white screen to the target device to avoid heavy calculations.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When using unaccelerated video we want to be able to fill a region of the
target framebuffer with a solid color. Hence, this adds the fill() helper
function with similar semantics to blit() but it uses a solid RGB color
value to fill in the framebuffers.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Instead of passing width/height separately, we now use the values from the
buffer object. The caller has to manipulate the buffer object to change
these values. In fact, they can simply create a buffer object on the stack
with the same values copied from the real buffer and just adjust the
offset, width, height and stride. With the help of the stride value, it is
possible to even shrink the buffer horizontally.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Since we moved to a runtime backend system for the input subsystem, we
cannot access the internal keysym_to_string() helpers anymore. Hence, use
the recently introduced uterm-input forwarding helper.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
There is no much gain from having an internal kbd_desc_keysym_to_string()
function if we cannot get access to the kbd_desc object. Therefore, add a
forward helper to uterm_input() which forwards the call to its internal
kbd_desc object. This allows outside access to the keysym_to_string()
function.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The pango font backend is similar to the currently used older backend but
provides the new API. It is modular so we can disable it if not needed.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When rendering underlines we need the baseline attribute. Therefore,
replace the unused x/y offsets with a baseline attribute.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
There is no need to include config.h manually so remove this to avoid
compilation errors when compiling external applications.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The 8x16 font is a static in-memory font that can be used as safe
fallback. It does not allow scaling or other font decorations so it's
really just for very basic text-layouts.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>