blob: 6033da7282070b3191470bb12758d57541af8ff7 [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
Dees Troyf171e102014-11-06 22:19:58 +010020typedef void* gr_surface;
Dees_Troy51a0e822012-09-05 15:24:24 -040021typedef 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);
that9876ac32015-02-15 21:40:59 +010039void gr_clip(int x, int y, int w, int h);
40void gr_noclip();
Dees_Troy51a0e822012-09-05 15:24:24 -040041void gr_fill(int x, int y, int w, int h);
Vojtech Bocekdb378b62015-03-05 20:02:57 +010042void gr_line(int x0, int y0, int x1, int y1, int width);
43gr_surface gr_render_circle(int radius, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
Dees_Troy51a0e822012-09-05 15:24:24 -040044
45int gr_textEx(int x, int y, const char *s, void* font);
46int gr_textExW(int x, int y, const char *s, void* font, int max_width);
47int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height);
Dees_Troy51a0e822012-09-05 15:24:24 -040048static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); }
49int gr_measureEx(const char *s, void* font);
50static inline int gr_measure(const char *s) { return gr_measureEx(s, NULL); }
Dees Troy31218ec2014-02-25 20:35:56 +000051int gr_maxExW(const char *s, void* font, int max_width);
Dees_Troy51a0e822012-09-05 15:24:24 -040052
Vojtech Bocek76ee9032014-09-07 15:01:56 +020053int gr_getMaxFontHeight(void *font);
Dees_Troy51a0e822012-09-05 15:24:24 -040054
55void* gr_loadFont(const char* fontName);
Vojtech Bocek76ee9032014-09-07 15:01:56 +020056void gr_freeFont(void *font);
57
58#ifndef TW_DISABLE_TTF
59void *gr_ttf_loadFont(const char *filename, int size, int dpi);
60void gr_ttf_freeFont(void *font);
61int gr_ttf_textExWH(void *context, int x, int y, const char *s, void *pFont, int max_width, int max_height);
62int gr_ttf_measureEx(const char *s, void *font);
63int gr_ttf_maxExW(const char *s, void *font, int max_width);
64int gr_ttf_getMaxFontHeight(void *font);
65void gr_ttf_dump_stats(void);
66#endif
Dees_Troy51a0e822012-09-05 15:24:24 -040067
68void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
69unsigned int gr_get_width(gr_surface surface);
70unsigned int gr_get_height(gr_surface surface);
71int gr_get_surface(gr_surface* surface);
72int gr_free_surface(gr_surface surface);
73
Ethan Yonker63e414f2015-02-06 15:44:39 -060074// Functions in graphics_utils.c
Vojtech Bocek03fd6c52014-03-13 18:46:34 +010075int gr_save_screenshot(const char *dest);
76
Dees_Troy51a0e822012-09-05 15:24:24 -040077// input event structure, include <linux/input.h> for the definition.
78// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
79struct input_event;
80
81int ev_init(void);
82void ev_exit(void);
thatde72b6d2015-02-08 08:55:00 +010083int ev_get(struct input_event *ev, int timeout_ms);
Vojtech Bocek1fc30fc2014-01-29 18:37:19 +010084int ev_has_mouse(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040085
86// Resources
87
88// Returns 0 if no error, else negative.
89int res_create_surface(const char* name, gr_surface* pSurface);
90void res_free_surface(gr_surface surface);
Ethan Yonker63e414f2015-02-06 15:44:39 -060091int res_scale_surface(gr_surface source, gr_surface* destination, float scale_w, float scale_h);
Dees_Troy51a0e822012-09-05 15:24:24 -040092
93// Needed for AOSP:
94int ev_wait(int timeout);
95void ev_dispatch(void);
96int ev_get_input(int fd, short revents, struct input_event *ev);
97
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +000098int vibrate(int timeout_ms);
99
Dees_Troy51a0e822012-09-05 15:24:24 -0400100#endif