blob: cb9f8a3853d09751d268d828f835afd4bc143e5f [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _MINUI_H_
18#define _MINUI_H_
19
20typedef void* gr_surface;
21typedef unsigned short gr_pixel;
22
Vojtech Bocek76ee9032014-09-07 15:01:56 +020023#define FONT_TYPE_TWRP 0
24
25#ifndef TW_DISABLE_TTF
26#define FONT_TYPE_TTF 1
27#endif
28
Dees_Troy51a0e822012-09-05 15:24:24 -040029int gr_init(void);
30void gr_exit(void);
31
32int gr_fb_width(void);
33int gr_fb_height(void);
34gr_pixel *gr_fb_data(void);
35void gr_flip(void);
Dees_Troy70237dc2013-02-28 21:31:48 +000036int gr_fb_blank(int blank);
Dees_Troy51a0e822012-09-05 15:24:24 -040037
38void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
39void gr_fill(int x, int y, int w, int h);
40
41int gr_textEx(int x, int y, const char *s, void* font);
42int gr_textExW(int x, int y, const char *s, void* font, int max_width);
43int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height);
Dees_Troy51a0e822012-09-05 15:24:24 -040044static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); }
45int gr_measureEx(const char *s, void* font);
46static inline int gr_measure(const char *s) { return gr_measureEx(s, NULL); }
Dees Troy31218ec2014-02-25 20:35:56 +000047int gr_maxExW(const char *s, void* font, int max_width);
Dees_Troy51a0e822012-09-05 15:24:24 -040048
Vojtech Bocek76ee9032014-09-07 15:01:56 +020049int gr_getMaxFontHeight(void *font);
Dees_Troy51a0e822012-09-05 15:24:24 -040050
51void* gr_loadFont(const char* fontName);
Vojtech Bocek76ee9032014-09-07 15:01:56 +020052void gr_freeFont(void *font);
53
54#ifndef TW_DISABLE_TTF
55void *gr_ttf_loadFont(const char *filename, int size, int dpi);
56void gr_ttf_freeFont(void *font);
57int gr_ttf_textExWH(void *context, int x, int y, const char *s, void *pFont, int max_width, int max_height);
58int gr_ttf_measureEx(const char *s, void *font);
59int gr_ttf_maxExW(const char *s, void *font, int max_width);
60int gr_ttf_getMaxFontHeight(void *font);
61void gr_ttf_dump_stats(void);
62#endif
Dees_Troy51a0e822012-09-05 15:24:24 -040063
64void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
65unsigned int gr_get_width(gr_surface surface);
66unsigned int gr_get_height(gr_surface surface);
67int gr_get_surface(gr_surface* surface);
68int gr_free_surface(gr_surface surface);
69
Vojtech Bocek03fd6c52014-03-13 18:46:34 +010070int gr_save_screenshot(const char *dest);
71
Dees_Troy51a0e822012-09-05 15:24:24 -040072// input event structure, include <linux/input.h> for the definition.
73// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
74struct input_event;
75
76int ev_init(void);
77void ev_exit(void);
Dees_Troyb7ecc092013-08-24 12:15:41 +000078int ev_get(struct input_event *ev, unsigned dont_wait);
Vojtech Bocek1fc30fc2014-01-29 18:37:19 +010079int ev_has_mouse(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040080
81// Resources
82
83// Returns 0 if no error, else negative.
84int res_create_surface(const char* name, gr_surface* pSurface);
85void res_free_surface(gr_surface surface);
86
87// Needed for AOSP:
88int ev_wait(int timeout);
89void ev_dispatch(void);
90int ev_get_input(int fd, short revents, struct input_event *ev);
91
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +000092int vibrate(int timeout_ms);
93
Dees_Troy51a0e822012-09-05 15:24:24 -040094#endif