blob: 1744928dde6c50051082ee32a400b2571303ce25 [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
Vojtech Bocek76ee9032014-09-07 15:01:56 +020024#define FONT_TYPE_TTF 1
Vojtech Bocek76ee9032014-09-07 15:01:56 +020025
Dees_Troy51a0e822012-09-05 15:24:24 -040026int gr_init(void);
27void gr_exit(void);
28
29int gr_fb_width(void);
30int gr_fb_height(void);
31gr_pixel *gr_fb_data(void);
32void gr_flip(void);
Dees_Troy70237dc2013-02-28 21:31:48 +000033int gr_fb_blank(int blank);
Dees_Troy51a0e822012-09-05 15:24:24 -040034
35void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
that9876ac32015-02-15 21:40:59 +010036void gr_clip(int x, int y, int w, int h);
37void gr_noclip();
Dees_Troy51a0e822012-09-05 15:24:24 -040038void gr_fill(int x, int y, int w, int h);
Vojtech Bocekdb378b62015-03-05 20:02:57 +010039void gr_line(int x0, int y0, int x1, int y1, int width);
40gr_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 -040041
42int gr_textEx(int x, int y, const char *s, void* font);
43int gr_textExW(int x, int y, const char *s, void* font, int max_width);
44int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height);
Dees_Troy51a0e822012-09-05 15:24:24 -040045static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); }
46int gr_measureEx(const char *s, void* font);
47static inline int gr_measure(const char *s) { return gr_measureEx(s, NULL); }
Dees Troy31218ec2014-02-25 20:35:56 +000048int gr_maxExW(const char *s, void* font, int max_width);
Dees_Troy51a0e822012-09-05 15:24:24 -040049
Vojtech Bocek76ee9032014-09-07 15:01:56 +020050int gr_getMaxFontHeight(void *font);
Dees_Troy51a0e822012-09-05 15:24:24 -040051
Vojtech Bocek76ee9032014-09-07 15:01:56 +020052void *gr_ttf_loadFont(const char *filename, int size, int dpi);
53void gr_ttf_freeFont(void *font);
54int gr_ttf_textExWH(void *context, int x, int y, const char *s, void *pFont, int max_width, int max_height);
55int gr_ttf_measureEx(const char *s, void *font);
56int gr_ttf_maxExW(const char *s, void *font, int max_width);
57int gr_ttf_getMaxFontHeight(void *font);
58void gr_ttf_dump_stats(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040059
60void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
61unsigned int gr_get_width(gr_surface surface);
62unsigned int gr_get_height(gr_surface surface);
63int gr_get_surface(gr_surface* surface);
64int gr_free_surface(gr_surface surface);
65
Ethan Yonker63e414f2015-02-06 15:44:39 -060066// Functions in graphics_utils.c
Vojtech Bocek03fd6c52014-03-13 18:46:34 +010067int gr_save_screenshot(const char *dest);
68
Dees_Troy51a0e822012-09-05 15:24:24 -040069// input event structure, include <linux/input.h> for the definition.
70// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
71struct input_event;
72
73int ev_init(void);
74void ev_exit(void);
thatde72b6d2015-02-08 08:55:00 +010075int ev_get(struct input_event *ev, int timeout_ms);
Vojtech Bocek1fc30fc2014-01-29 18:37:19 +010076int ev_has_mouse(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040077
78// Resources
79
80// Returns 0 if no error, else negative.
81int res_create_surface(const char* name, gr_surface* pSurface);
82void res_free_surface(gr_surface surface);
Ethan Yonker63e414f2015-02-06 15:44:39 -060083int res_scale_surface(gr_surface source, gr_surface* destination, float scale_w, float scale_h);
Dees_Troy51a0e822012-09-05 15:24:24 -040084
85// Needed for AOSP:
86int ev_wait(int timeout);
87void ev_dispatch(void);
88int ev_get_input(int fd, short revents, struct input_event *ev);
89
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +000090int vibrate(int timeout_ms);
91
Dees_Troy51a0e822012-09-05 15:24:24 -040092#endif