2 * kmscon - Text Renderer
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.
28 * The Text-Renderer subsystem provides a simple way to draw text into a
29 * framebuffer. The system is modular and several different backends are
30 * available that can be used.
39 #include "tsm_screen.h"
45 struct kmscon_text_ops;
49 struct shl_register_record *record;
50 const struct kmscon_text_ops *ops;
53 struct kmscon_font *font;
54 struct kmscon_font *bold_font;
55 struct uterm_display *disp;
61 struct kmscon_text_ops {
63 int (*init) (struct kmscon_text *txt);
64 void (*destroy) (struct kmscon_text *txt);
65 int (*set) (struct kmscon_text *txt);
66 void (*unset) (struct kmscon_text *txt);
67 int (*prepare) (struct kmscon_text *txt);
68 int (*draw) (struct kmscon_text *txt,
69 uint32_t id, const uint32_t *ch, size_t len,
71 unsigned int posx, unsigned int posy,
72 const struct tsm_screen_attr *attr);
73 int (*render) (struct kmscon_text *txt);
74 void (*abort) (struct kmscon_text *txt);
77 int kmscon_text_register(const struct kmscon_text_ops *ops);
78 void kmscon_text_unregister(const char *name);
80 int kmscon_text_new(struct kmscon_text **out, const char *backend);
81 void kmscon_text_ref(struct kmscon_text *txt);
82 void kmscon_text_unref(struct kmscon_text *txt);
84 int kmscon_text_set(struct kmscon_text *txt,
85 struct kmscon_font *font,
86 struct kmscon_font *bold_font,
87 struct uterm_display *disp);
88 void kmscon_text_unset(struct kmscon_text *txt);
89 unsigned int kmscon_text_get_cols(struct kmscon_text *txt);
90 unsigned int kmscon_text_get_rows(struct kmscon_text *txt);
92 int kmscon_text_prepare(struct kmscon_text *txt);
93 int kmscon_text_draw(struct kmscon_text *txt,
94 uint32_t id, const uint32_t *ch, size_t len,
96 unsigned int posx, unsigned int posy,
97 const struct tsm_screen_attr *attr);
98 int kmscon_text_render(struct kmscon_text *txt);
99 void kmscon_text_abort(struct kmscon_text *txt);
101 int kmscon_text_prepare_cb(struct tsm_screen *con, void *data);
102 int kmscon_text_draw_cb(struct tsm_screen *con,
103 uint32_t id, const uint32_t *ch, size_t len,
105 unsigned int posx, unsigned int posy,
106 const struct tsm_screen_attr *attr, void *data);
107 int kmscon_text_render_cb(struct tsm_screen *con, void *data);
109 /* modularized backends */
111 #ifdef BUILD_ENABLE_RENDERER_BBLIT
113 int kmscon_text_bblit_load(void);
114 void kmscon_text_bblit_unload(void);
118 static inline int kmscon_text_bblit_load(void)
123 static inline void kmscon_text_bblit_unload(void)
129 #ifdef BUILD_ENABLE_RENDERER_BBULK
131 int kmscon_text_bbulk_load(void);
132 void kmscon_text_bbulk_unload(void);
136 static inline int kmscon_text_bbulk_load(void)
141 static inline void kmscon_text_bbulk_unload(void)
147 #ifdef BUILD_ENABLE_RENDERER_GLTEX
149 int kmscon_text_gltex_load(void);
150 void kmscon_text_gltex_unload(void);
154 static inline int kmscon_text_gltex_load(void)
159 static inline void kmscon_text_gltex_unload(void)
165 static inline void kmscon_text_load_all(void)
167 kmscon_text_bbulk_load();
168 kmscon_text_bblit_load();
169 kmscon_text_gltex_load();
172 static inline void kmscon_text_unload_all(void)
174 kmscon_text_gltex_unload();
175 kmscon_text_bblit_unload();
176 kmscon_text_bbulk_unload();
179 #endif /* KMSCON_TEXT_H */