2 * kmscon - Bit-Blitting Text Renderer Backend
4 * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files
8 * (the "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * SECTION:text_bblit.c
28 * @short_description: Bit-Blitting Text Renderer Backend
31 * The bit-blitting renderer requires framebuffer access to the output device
32 * and simply blits the glyphs into the buffer.
41 #include "uterm_video.h"
43 #define LOG_SUBSYSTEM "text_bblit"
45 static int bblit_set(struct kmscon_text *txt)
47 unsigned int sw, sh, fw, fh;
48 struct uterm_mode *mode;
50 fw = txt->font->attr.width;
51 fh = txt->font->attr.height;
52 mode = uterm_display_get_current(txt->disp);
55 sw = uterm_mode_get_width(mode);
56 sh = uterm_mode_get_height(mode);
64 static int bblit_draw(struct kmscon_text *txt,
65 uint32_t id, const uint32_t *ch, size_t len,
67 unsigned int posx, unsigned int posy,
68 const struct tsm_screen_attr *attr)
70 const struct kmscon_glyph *glyph;
72 struct kmscon_font *font;
78 font = txt->bold_font;
83 ret = kmscon_font_render_empty(font, &glyph);
85 ret = kmscon_font_render(font, id, ch, len, &glyph);
89 ret = kmscon_font_render_inval(font, &glyph);
96 ret = uterm_display_fake_blend(txt->disp, &glyph->buf,
97 posx * txt->font->attr.width,
98 posy * txt->font->attr.height,
99 attr->br, attr->bg, attr->bb,
100 attr->fr, attr->fg, attr->fb);
102 ret = uterm_display_fake_blend(txt->disp, &glyph->buf,
103 posx * txt->font->attr.width,
104 posy * txt->font->attr.height,
105 attr->fr, attr->fg, attr->fb,
106 attr->br, attr->bg, attr->bb);
112 struct kmscon_text_ops kmscon_text_bblit_ops = {