text: remove old font definitions
[platform/upstream/kmscon.git] / src / text.h
1 /*
2  * kmscon - Text Renderer
3  *
4  * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
5  *
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:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
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.
24  */
25
26 /*
27  * Text Renderer
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.
31  */
32
33 #ifndef KMSCON_TEXT_H
34 #define KMSCON_TEXT_H
35
36 #include <errno.h>
37 #include <stdlib.h>
38 #include "font.h"
39 #include "tsm_screen.h"
40 #include "uterm.h"
41
42 /* text renderer */
43
44 struct kmscon_text;
45 struct kmscon_text_ops;
46
47 struct kmscon_text {
48         unsigned long ref;
49         struct shl_register_record *record;
50         const struct kmscon_text_ops *ops;
51         void *data;
52
53         struct kmscon_font *font;
54         struct kmscon_font *bold_font;
55         struct uterm_display *disp;
56         unsigned int cols;
57         unsigned int rows;
58         bool rendering;
59 };
60
61 struct kmscon_text_ops {
62         const char *name;
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,
70                      unsigned int width,
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);
75 };
76
77 int kmscon_text_register(const struct kmscon_text_ops *ops);
78 void kmscon_text_unregister(const char *name);
79
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);
83
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);
91
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,
95                      unsigned int width,
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);
100
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,
104                         unsigned int width,
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);
108
109 /* modularized backends */
110
111 #ifdef BUILD_ENABLE_RENDERER_BBLIT
112
113 int kmscon_text_bblit_load(void);
114 void kmscon_text_bblit_unload(void);
115
116 #else
117
118 static inline int kmscon_text_bblit_load(void)
119 {
120         return -EOPNOTSUPP;
121 }
122
123 static inline void kmscon_text_bblit_unload(void)
124 {
125 }
126
127 #endif
128
129 #ifdef BUILD_ENABLE_RENDERER_BBULK
130
131 int kmscon_text_bbulk_load(void);
132 void kmscon_text_bbulk_unload(void);
133
134 #else
135
136 static inline int kmscon_text_bbulk_load(void)
137 {
138         return -EOPNOTSUPP;
139 }
140
141 static inline void kmscon_text_bbulk_unload(void)
142 {
143 }
144
145 #endif
146
147 #ifdef BUILD_ENABLE_RENDERER_GLTEX
148
149 int kmscon_text_gltex_load(void);
150 void kmscon_text_gltex_unload(void);
151
152 #else
153
154 static inline int kmscon_text_gltex_load(void)
155 {
156         return -EOPNOTSUPP;
157 }
158
159 static inline void kmscon_text_gltex_unload(void)
160 {
161 }
162
163 #endif
164
165 static inline void kmscon_text_load_all(void)
166 {
167         kmscon_text_bbulk_load();
168         kmscon_text_bblit_load();
169         kmscon_text_gltex_load();
170 }
171
172 static inline void kmscon_text_unload_all(void)
173 {
174         kmscon_text_gltex_unload();
175         kmscon_text_bblit_unload();
176         kmscon_text_bbulk_unload();
177 }
178
179 #endif /* KMSCON_TEXT_H */