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 | |
| 20 | typedef void* gr_surface; |
| 21 | typedef unsigned short gr_pixel; |
| 22 | |
| 23 | int gr_init(void); |
| 24 | void gr_exit(void); |
| 25 | |
| 26 | int gr_fb_width(void); |
| 27 | int gr_fb_height(void); |
| 28 | gr_pixel *gr_fb_data(void); |
| 29 | void gr_flip(void); |
Dees_Troy | 70237dc | 2013-02-28 21:31:48 +0000 | [diff] [blame] | 30 | int gr_fb_blank(int blank); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 31 | |
| 32 | void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); |
| 33 | void gr_fill(int x, int y, int w, int h); |
| 34 | |
| 35 | int gr_textEx(int x, int y, const char *s, void* font); |
| 36 | int gr_textExW(int x, int y, const char *s, void* font, int max_width); |
| 37 | int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height); |
| 38 | int twgr_text(int x, int y, const char *s); |
| 39 | static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); } |
| 40 | int gr_measureEx(const char *s, void* font); |
| 41 | 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] | 42 | int gr_maxExW(const char *s, void* font, int max_width); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 43 | |
| 44 | int gr_getFontDetails(void* font, unsigned* cheight, unsigned* maxwidth); |
| 45 | static inline void gr_font_size(int *x, int *y) { gr_getFontDetails(NULL, (unsigned*) y, (unsigned*) x); } |
| 46 | |
| 47 | void* gr_loadFont(const char* fontName); |
| 48 | |
| 49 | void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); |
| 50 | unsigned int gr_get_width(gr_surface surface); |
| 51 | unsigned int gr_get_height(gr_surface surface); |
| 52 | int gr_get_surface(gr_surface* surface); |
| 53 | int gr_free_surface(gr_surface surface); |
| 54 | |
Vojtech Bocek | 03fd6c5 | 2014-03-13 18:46:34 +0100 | [diff] [blame] | 55 | int gr_save_screenshot(const char *dest); |
| 56 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 57 | // input event structure, include <linux/input.h> for the definition. |
| 58 | // see http://www.mjmwired.net/kernel/Documentation/input/ for info. |
| 59 | struct input_event; |
| 60 | |
| 61 | int ev_init(void); |
| 62 | void ev_exit(void); |
Dees_Troy | b7ecc09 | 2013-08-24 12:15:41 +0000 | [diff] [blame] | 63 | int ev_get(struct input_event *ev, unsigned dont_wait); |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 64 | int ev_has_mouse(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 65 | |
| 66 | // Resources |
| 67 | |
| 68 | // Returns 0 if no error, else negative. |
| 69 | int res_create_surface(const char* name, gr_surface* pSurface); |
| 70 | void res_free_surface(gr_surface surface); |
| 71 | |
| 72 | // Needed for AOSP: |
| 73 | int ev_wait(int timeout); |
| 74 | void ev_dispatch(void); |
| 75 | int ev_get_input(int fd, short revents, struct input_event *ev); |
| 76 | |
Samer Diab (S.a.M.e.R_d) | 71e9b04 | 2014-01-07 20:18:47 +0000 | [diff] [blame] | 77 | int vibrate(int timeout_ms); |
| 78 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 79 | #endif |