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.
40 #include "kmscon_module.h"
41 #include "uterm_video.h"
46 struct kmscon_text_ops;
50 struct shl_register_record *record;
51 const struct kmscon_text_ops *ops;
54 struct kmscon_font *font;
55 struct kmscon_font *bold_font;
56 struct uterm_display *disp;
62 struct kmscon_text_ops {
64 struct kmscon_module *owner;
65 int (*init) (struct kmscon_text *txt);
66 void (*destroy) (struct kmscon_text *txt);
67 int (*set) (struct kmscon_text *txt);
68 void (*unset) (struct kmscon_text *txt);
69 int (*prepare) (struct kmscon_text *txt);
70 int (*draw) (struct kmscon_text *txt,
71 uint32_t id, const uint32_t *ch, size_t len,
73 unsigned int posx, unsigned int posy,
74 const struct tsm_screen_attr *attr);
75 int (*render) (struct kmscon_text *txt);
76 void (*abort) (struct kmscon_text *txt);
79 int kmscon_text_register(const struct kmscon_text_ops *ops);
80 void kmscon_text_unregister(const char *name);
82 int kmscon_text_new(struct kmscon_text **out, const char *backend);
83 void kmscon_text_ref(struct kmscon_text *txt);
84 void kmscon_text_unref(struct kmscon_text *txt);
86 int kmscon_text_set(struct kmscon_text *txt,
87 struct kmscon_font *font,
88 struct kmscon_font *bold_font,
89 struct uterm_display *disp);
90 void kmscon_text_unset(struct kmscon_text *txt);
91 unsigned int kmscon_text_get_cols(struct kmscon_text *txt);
92 unsigned int kmscon_text_get_rows(struct kmscon_text *txt);
94 int kmscon_text_prepare(struct kmscon_text *txt);
95 int kmscon_text_draw(struct kmscon_text *txt,
96 uint32_t id, const uint32_t *ch, size_t len,
98 unsigned int posx, unsigned int posy,
99 const struct tsm_screen_attr *attr);
100 int kmscon_text_render(struct kmscon_text *txt);
101 void kmscon_text_abort(struct kmscon_text *txt);
103 int kmscon_text_draw_cb(struct tsm_screen *con,
104 uint32_t id, const uint32_t *ch, size_t len,
106 unsigned int posx, unsigned int posy,
107 const struct tsm_screen_attr *attr,
108 tsm_age_t age, void *data);
110 /* modularized backends */
112 extern struct kmscon_text_ops kmscon_text_bblit_ops;
113 extern struct kmscon_text_ops kmscon_text_bbulk_ops;
114 extern struct kmscon_text_ops kmscon_text_gltex_ops;
115 extern struct kmscon_text_ops kmscon_text_pixman_ops;
117 #endif /* KMSCON_TEXT_H */