Modify it to adjust Tizen IVI enviroment
[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 <libtsm.h>
38 #include <stdlib.h>
39 #include "font.h"
40 #include "kmscon_module.h"
41 #include "uterm_video.h"
42
43 /* text renderer */
44
45 struct kmscon_text;
46 struct kmscon_text_ops;
47
48 struct kmscon_text {
49         unsigned long ref;
50         struct shl_register_record *record;
51         const struct kmscon_text_ops *ops;
52         void *data;
53
54         struct kmscon_font *font;
55         struct kmscon_font *bold_font;
56         struct uterm_display *disp;
57         unsigned int cols;
58         unsigned int rows;
59         bool rendering;
60 };
61
62 struct kmscon_text_ops {
63         const char *name;
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,
72                      unsigned int width,
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);
77 };
78
79 int kmscon_text_register(const struct kmscon_text_ops *ops);
80 void kmscon_text_unregister(const char *name);
81
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);
85
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);
93
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,
97                      unsigned int width,
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);
102
103 int kmscon_text_draw_cb(struct tsm_screen *con,
104                         uint32_t id, const uint32_t *ch, size_t len,
105                         unsigned int width,
106                         unsigned int posx, unsigned int posy,
107                         const struct tsm_screen_attr *attr,
108                         tsm_age_t age, void *data);
109
110 /* modularized backends */
111
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;
116
117 #endif /* KMSCON_TEXT_H */