blob: 699b08ca6bb7bc652e94ec1af998bc157c7708bf [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
Ethan Yonkera27d02f2014-11-06 10:24:39 -060020typedef struct {
21 int width;
22 int height;
23 int row_bytes;
24 int pixel_bytes;
25 unsigned char* data;
26} GRSurface;
27
28typedef GRSurface* gr_surface;
29
Dees_Troy51a0e822012-09-05 15:24:24 -040030typedef unsigned short gr_pixel;
31
Vojtech Bocek76ee9032014-09-07 15:01:56 +020032#define FONT_TYPE_TWRP 0
33
34#ifndef TW_DISABLE_TTF
35#define FONT_TYPE_TTF 1
36#endif
37
Dees_Troy51a0e822012-09-05 15:24:24 -040038int gr_init(void);
39void gr_exit(void);
40
41int gr_fb_width(void);
42int gr_fb_height(void);
43gr_pixel *gr_fb_data(void);
44void gr_flip(void);
Dees_Troy70237dc2013-02-28 21:31:48 +000045int gr_fb_blank(int blank);
Dees_Troy51a0e822012-09-05 15:24:24 -040046
47void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
48void gr_fill(int x, int y, int w, int h);
49
50int gr_textEx(int x, int y, const char *s, void* font);
51int gr_textExW(int x, int y, const char *s, void* font, int max_width);
52int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height);
Dees_Troy51a0e822012-09-05 15:24:24 -040053static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); }
54int gr_measureEx(const char *s, void* font);
55static inline int gr_measure(const char *s) { return gr_measureEx(s, NULL); }
Dees Troy31218ec2014-02-25 20:35:56 +000056int gr_maxExW(const char *s, void* font, int max_width);
Dees_Troy51a0e822012-09-05 15:24:24 -040057
Vojtech Bocek76ee9032014-09-07 15:01:56 +020058int gr_getMaxFontHeight(void *font);
Dees_Troy51a0e822012-09-05 15:24:24 -040059
60void* gr_loadFont(const char* fontName);
Vojtech Bocek76ee9032014-09-07 15:01:56 +020061void gr_freeFont(void *font);
62
63#ifndef TW_DISABLE_TTF
64void *gr_ttf_loadFont(const char *filename, int size, int dpi);
65void gr_ttf_freeFont(void *font);
66int gr_ttf_textExWH(void *context, int x, int y, const char *s, void *pFont, int max_width, int max_height);
67int gr_ttf_measureEx(const char *s, void *font);
68int gr_ttf_maxExW(const char *s, void *font, int max_width);
69int gr_ttf_getMaxFontHeight(void *font);
70void gr_ttf_dump_stats(void);
71#endif
Dees_Troy51a0e822012-09-05 15:24:24 -040072
73void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
74unsigned int gr_get_width(gr_surface surface);
75unsigned int gr_get_height(gr_surface surface);
76int gr_get_surface(gr_surface* surface);
77int gr_free_surface(gr_surface surface);
78
Vojtech Bocek03fd6c52014-03-13 18:46:34 +010079int gr_save_screenshot(const char *dest);
80
Dees_Troy51a0e822012-09-05 15:24:24 -040081// input event structure, include <linux/input.h> for the definition.
82// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
83struct input_event;
84
85int ev_init(void);
86void ev_exit(void);
Dees_Troyb7ecc092013-08-24 12:15:41 +000087int ev_get(struct input_event *ev, unsigned dont_wait);
Vojtech Bocek1fc30fc2014-01-29 18:37:19 +010088int ev_has_mouse(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040089
90// Resources
91
92// Returns 0 if no error, else negative.
93int res_create_surface(const char* name, gr_surface* pSurface);
94void res_free_surface(gr_surface surface);
95
96// Needed for AOSP:
97int ev_wait(int timeout);
98void ev_dispatch(void);
99int ev_get_input(int fd, short revents, struct input_event *ev);
100
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +0000101int vibrate(int timeout_ms);
102
Dees_Troy51a0e822012-09-05 15:24:24 -0400103#endif