Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1 | /* |
| 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 Troy | f171e10 | 2014-11-06 22:19:58 +0100 | [diff] [blame] | 20 | typedef void* gr_surface; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 21 | typedef unsigned short gr_pixel; |
| 22 | |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 23 | #define FONT_TYPE_TWRP 0 |
| 24 | |
| 25 | #ifndef TW_DISABLE_TTF |
| 26 | #define FONT_TYPE_TTF 1 |
| 27 | #endif |
| 28 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 29 | int gr_init(void); |
| 30 | void gr_exit(void); |
| 31 | |
| 32 | int gr_fb_width(void); |
| 33 | int gr_fb_height(void); |
| 34 | gr_pixel *gr_fb_data(void); |
| 35 | void gr_flip(void); |
Dees_Troy | 70237dc | 2013-02-28 21:31:48 +0000 | [diff] [blame] | 36 | int gr_fb_blank(int blank); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 37 | |
| 38 | void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); |
that | 9876ac3 | 2015-02-15 21:40:59 +0100 | [diff] [blame] | 39 | void gr_clip(int x, int y, int w, int h); |
| 40 | void gr_noclip(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 41 | void gr_fill(int x, int y, int w, int h); |
| 42 | |
| 43 | int gr_textEx(int x, int y, const char *s, void* font); |
| 44 | int gr_textExW(int x, int y, const char *s, void* font, int max_width); |
| 45 | int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 46 | static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); } |
| 47 | int gr_measureEx(const char *s, void* font); |
| 48 | static inline int gr_measure(const char *s) { return gr_measureEx(s, NULL); } |
Dees Troy | 31218ec | 2014-02-25 20:35:56 +0000 | [diff] [blame] | 49 | int gr_maxExW(const char *s, void* font, int max_width); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 50 | |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 51 | int gr_getMaxFontHeight(void *font); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 52 | |
| 53 | void* gr_loadFont(const char* fontName); |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 54 | void gr_freeFont(void *font); |
| 55 | |
| 56 | #ifndef TW_DISABLE_TTF |
| 57 | void *gr_ttf_loadFont(const char *filename, int size, int dpi); |
| 58 | void gr_ttf_freeFont(void *font); |
| 59 | int gr_ttf_textExWH(void *context, int x, int y, const char *s, void *pFont, int max_width, int max_height); |
| 60 | int gr_ttf_measureEx(const char *s, void *font); |
| 61 | int gr_ttf_maxExW(const char *s, void *font, int max_width); |
| 62 | int gr_ttf_getMaxFontHeight(void *font); |
| 63 | void gr_ttf_dump_stats(void); |
| 64 | #endif |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 65 | |
| 66 | void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); |
| 67 | unsigned int gr_get_width(gr_surface surface); |
| 68 | unsigned int gr_get_height(gr_surface surface); |
| 69 | int gr_get_surface(gr_surface* surface); |
| 70 | int gr_free_surface(gr_surface surface); |
| 71 | |
Ethan Yonker | 63e414f | 2015-02-06 15:44:39 -0600 | [diff] [blame] | 72 | // Functions in graphics_utils.c |
Vojtech Bocek | 03fd6c5 | 2014-03-13 18:46:34 +0100 | [diff] [blame] | 73 | int gr_save_screenshot(const char *dest); |
| 74 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 75 | // input event structure, include <linux/input.h> for the definition. |
| 76 | // see http://www.mjmwired.net/kernel/Documentation/input/ for info. |
| 77 | struct input_event; |
| 78 | |
| 79 | int ev_init(void); |
| 80 | void ev_exit(void); |
that | de72b6d | 2015-02-08 08:55:00 +0100 | [diff] [blame] | 81 | int ev_get(struct input_event *ev, int timeout_ms); |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 82 | int ev_has_mouse(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 83 | |
| 84 | // Resources |
| 85 | |
| 86 | // Returns 0 if no error, else negative. |
| 87 | int res_create_surface(const char* name, gr_surface* pSurface); |
| 88 | void res_free_surface(gr_surface surface); |
Ethan Yonker | 63e414f | 2015-02-06 15:44:39 -0600 | [diff] [blame] | 89 | int res_scale_surface(gr_surface source, gr_surface* destination, float scale_w, float scale_h); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 90 | |
| 91 | // Needed for AOSP: |
| 92 | int ev_wait(int timeout); |
| 93 | void ev_dispatch(void); |
| 94 | int ev_get_input(int fd, short revents, struct input_event *ev); |
| 95 | |
Samer Diab (S.a.M.e.R_d) | 71e9b04 | 2014-01-07 20:18:47 +0000 | [diff] [blame] | 96 | int vibrate(int timeout_ms); |
| 97 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 98 | #endif |