blob: 25a785a5b320dbc79dca8ca2dda30e701bc0cf88 [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 Yonkerb7a54a32015-10-05 10:16:27 -050020#include "../gui/placement.h"
21
Dees Troyf171e102014-11-06 22:19:58 +010022typedef void* gr_surface;
Dees_Troy51a0e822012-09-05 15:24:24 -040023typedef unsigned short gr_pixel;
24
Vojtech Bocek76ee9032014-09-07 15:01:56 +020025#define FONT_TYPE_TWRP 0
Vojtech Bocek76ee9032014-09-07 15:01:56 +020026#define FONT_TYPE_TTF 1
Vojtech Bocek76ee9032014-09-07 15:01:56 +020027
Dees_Troy51a0e822012-09-05 15:24:24 -040028int gr_init(void);
29void gr_exit(void);
30
31int gr_fb_width(void);
32int gr_fb_height(void);
33gr_pixel *gr_fb_data(void);
34void gr_flip(void);
Dees_Troy70237dc2013-02-28 21:31:48 +000035int gr_fb_blank(int blank);
Dees_Troy51a0e822012-09-05 15:24:24 -040036
37void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
that9876ac32015-02-15 21:40:59 +010038void gr_clip(int x, int y, int w, int h);
39void gr_noclip();
Dees_Troy51a0e822012-09-05 15:24:24 -040040void gr_fill(int x, int y, int w, int h);
Vojtech Bocekdb378b62015-03-05 20:02:57 +010041void gr_line(int x0, int y0, int x1, int y1, int width);
42gr_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 -040043
44int gr_textEx(int x, int y, const char *s, void* font);
Ethan Yonkerb7a54a32015-10-05 10:16:27 -050045int gr_textEx_scaleW(int x, int y, const char *s, void* pFont, int max_width, int placement, int scale);
Dees_Troy51a0e822012-09-05 15:24:24 -040046int 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
Vojtech Bocek76ee9032014-09-07 15:01:56 +020055void *gr_ttf_loadFont(const char *filename, int size, int dpi);
Ethan Yonkerb7a54a32015-10-05 10:16:27 -050056void *gr_ttf_scaleFont(void *font, int max_width, int measured_width);
Vojtech Bocek76ee9032014-09-07 15:01:56 +020057void gr_ttf_freeFont(void *font);
58int gr_ttf_textExWH(void *context, int x, int y, const char *s, void *pFont, int max_width, int max_height);
59int gr_ttf_measureEx(const char *s, void *font);
60int gr_ttf_maxExW(const char *s, void *font, int max_width);
61int gr_ttf_getMaxFontHeight(void *font);
62void gr_ttf_dump_stats(void);
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
Ethan Yonker63e414f2015-02-06 15:44:39 -060070// Functions in graphics_utils.c
Vojtech Bocek03fd6c52014-03-13 18:46:34 +010071int gr_save_screenshot(const char *dest);
72
Dees_Troy51a0e822012-09-05 15:24:24 -040073// input event structure, include <linux/input.h> for the definition.
74// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
75struct input_event;
76
77int ev_init(void);
78void ev_exit(void);
thatde72b6d2015-02-08 08:55:00 +010079int ev_get(struct input_event *ev, int timeout_ms);
Vojtech Bocek1fc30fc2014-01-29 18:37:19 +010080int ev_has_mouse(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040081
82// Resources
83
84// Returns 0 if no error, else negative.
85int res_create_surface(const char* name, gr_surface* pSurface);
86void res_free_surface(gr_surface surface);
Ethan Yonker63e414f2015-02-06 15:44:39 -060087int res_scale_surface(gr_surface source, gr_surface* destination, float scale_w, float scale_h);
Dees_Troy51a0e822012-09-05 15:24:24 -040088
89// Needed for AOSP:
90int ev_wait(int timeout);
91void ev_dispatch(void);
92int ev_get_input(int fd, short revents, struct input_event *ev);
93
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +000094int vibrate(int timeout_ms);
95
Dees_Troy51a0e822012-09-05 15:24:24 -040096#endif