The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [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 | |
Dima Zavin | 4daf48a | 2011-08-30 11:59:20 -0700 | [diff] [blame] | 20 | #include <stdbool.h> |
| 21 | |
Doug Zongker | 28ce47c | 2011-10-28 10:33:05 -0700 | [diff] [blame] | 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
Doug Zongker | 39cf417 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 26 | typedef struct { |
| 27 | int width; |
| 28 | int height; |
| 29 | int row_bytes; |
| 30 | int pixel_bytes; |
| 31 | unsigned char* data; |
| 32 | } GRSurface; |
| 33 | |
| 34 | typedef GRSurface* gr_surface; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 35 | |
| 36 | int gr_init(void); |
| 37 | void gr_exit(void); |
| 38 | |
| 39 | int gr_fb_width(void); |
| 40 | int gr_fb_height(void); |
Doug Zongker | 39cf417 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 41 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 42 | void gr_flip(void); |
Dima Zavin | 4daf48a | 2011-08-30 11:59:20 -0700 | [diff] [blame] | 43 | void gr_fb_blank(bool blank); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 44 | |
Doug Zongker | 39cf417 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 45 | void gr_clear(); // clear entire surface to current color |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 46 | void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); |
Doug Zongker | c560a67 | 2012-12-18 16:31:27 -0800 | [diff] [blame] | 47 | void gr_fill(int x1, int y1, int x2, int y2); |
Doug Zongker | 39cf417 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 48 | void gr_text(int x, int y, const char *s, int bold); |
| 49 | void gr_texticon(int x, int y, gr_surface icon); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 50 | int gr_measure(const char *s); |
Dima Zavin | 3c7f00e | 2011-08-30 11:58:24 -0700 | [diff] [blame] | 51 | void gr_font_size(int *x, int *y); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 52 | |
| 53 | void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); |
| 54 | unsigned int gr_get_width(gr_surface surface); |
| 55 | unsigned int gr_get_height(gr_surface surface); |
| 56 | |
| 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 | |
Todd Poynor | a5ef19f | 2013-09-17 13:39:10 -0700 | [diff] [blame] | 61 | typedef int (*ev_callback)(int fd, uint32_t epevents, void *data); |
Dima Zavin | 441031d | 2011-10-12 15:53:29 -0700 | [diff] [blame] | 62 | typedef int (*ev_set_key_callback)(int code, int value, void *data); |
Dima Zavin | bc29063 | 2011-08-30 11:59:45 -0700 | [diff] [blame] | 63 | |
| 64 | int ev_init(ev_callback input_cb, void *data); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 65 | void ev_exit(void); |
Dima Zavin | 3658367 | 2011-09-02 11:51:31 -0700 | [diff] [blame] | 66 | int ev_add_fd(int fd, ev_callback cb, void *data); |
Dima Zavin | 441031d | 2011-10-12 15:53:29 -0700 | [diff] [blame] | 67 | int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data); |
Dima Zavin | bc29063 | 2011-08-30 11:59:45 -0700 | [diff] [blame] | 68 | |
| 69 | /* timeout has the same semantics as for poll |
| 70 | * 0 : don't block |
| 71 | * < 0 : block forever |
| 72 | * > 0 : block for 'timeout' milliseconds |
| 73 | */ |
| 74 | int ev_wait(int timeout); |
| 75 | |
Todd Poynor | a5ef19f | 2013-09-17 13:39:10 -0700 | [diff] [blame] | 76 | int ev_get_input(int fd, uint32_t epevents, struct input_event *ev); |
Dima Zavin | bc29063 | 2011-08-30 11:59:45 -0700 | [diff] [blame] | 77 | void ev_dispatch(void); |
Todd Poynor | 4665ede | 2013-09-10 17:03:45 -0700 | [diff] [blame] | 78 | int ev_get_epollfd(void); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 79 | |
| 80 | // Resources |
| 81 | |
| 82 | // Returns 0 if no error, else negative. |
| 83 | int res_create_surface(const char* name, gr_surface* pSurface); |
Doug Zongker | eac881c | 2014-03-07 09:21:25 -0800 | [diff] [blame] | 84 | int res_create_multi_surface(const char* name, int* frames, gr_surface** pSurface); |
Doug Zongker | 02ec6b8 | 2012-08-22 17:26:40 -0700 | [diff] [blame] | 85 | int res_create_localized_surface(const char* name, gr_surface* pSurface); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 86 | void res_free_surface(gr_surface surface); |
| 87 | |
Doug Zongker | 28ce47c | 2011-10-28 10:33:05 -0700 | [diff] [blame] | 88 | #ifdef __cplusplus |
| 89 | } |
| 90 | #endif |
| 91 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 92 | #endif |