blob: 8ef04445c3af65f05bef169bf44c9086667796a4 [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);
42
43int gr_textEx(int x, int y, const char *s, void* font);
44int gr_textExW(int x, int y, const char *s, void* font, int max_width);
45int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height);
Dees_Troy51a0e822012-09-05 15:24:24 -040046static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); }
47int gr_measureEx(const char *s, void* font);
48static inline int gr_measure(const char *s) { return gr_measureEx(s, NULL); }
Dees Troy31218ec2014-02-25 20:35:56 +000049int gr_maxExW(const char *s, void* font, int max_width);
Dees_Troy51a0e822012-09-05 15:24:24 -040050
Vojtech Bocek76ee9032014-09-07 15:01:56 +020051int gr_getMaxFontHeight(void *font);
Dees_Troy51a0e822012-09-05 15:24:24 -040052
53void* gr_loadFont(const char* fontName);
Vojtech Bocek76ee9032014-09-07 15:01:56 +020054void gr_freeFont(void *font);
55
56#ifndef TW_DISABLE_TTF
57void *gr_ttf_loadFont(const char *filename, int size, int dpi);
58void gr_ttf_freeFont(void *font);
59int gr_ttf_textExWH(void *context, int x, int y, const char *s, void *pFont, int max_width, int max_height);
60int gr_ttf_measureEx(const char *s, void *font);
61int gr_ttf_maxExW(const char *s, void *font, int max_width);
62int gr_ttf_getMaxFontHeight(void *font);
63void gr_ttf_dump_stats(void);
64#endif
Dees_Troy51a0e822012-09-05 15:24:24 -040065
66void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
67unsigned int gr_get_width(gr_surface surface);
68unsigned int gr_get_height(gr_surface surface);
69int gr_get_surface(gr_surface* surface);
70int gr_free_surface(gr_surface surface);
71
Ethan Yonker63e414f2015-02-06 15:44:39 -060072// Functions in graphics_utils.c
Vojtech Bocek03fd6c52014-03-13 18:46:34 +010073int gr_save_screenshot(const char *dest);
74
Dees_Troy51a0e822012-09-05 15:24:24 -040075// input event structure, include <linux/input.h> for the definition.
76// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
77struct input_event;
78
79int ev_init(void);
80void ev_exit(void);
thatde72b6d2015-02-08 08:55:00 +010081int ev_get(struct input_event *ev, int timeout_ms);
Vojtech Bocek1fc30fc2014-01-29 18:37:19 +010082int ev_has_mouse(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040083
84// Resources
85
86// Returns 0 if no error, else negative.
87int res_create_surface(const char* name, gr_surface* pSurface);
88void res_free_surface(gr_surface surface);
Ethan Yonker63e414f2015-02-06 15:44:39 -060089int res_scale_surface(gr_surface source, gr_surface* destination, float scale_w, float scale_h);
Dees_Troy51a0e822012-09-05 15:24:24 -040090
91// Needed for AOSP:
92int ev_wait(int timeout);
93void ev_dispatch(void);
94int ev_get_input(int fd, short revents, struct input_event *ev);
95
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +000096int vibrate(int timeout_ms);
97
Dees_Troy51a0e822012-09-05 15:24:24 -040098#endif