Ethan Yonker | c798c9c | 2015-10-09 11:15:26 -0500 | [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 | #include <stdbool.h> |
| 21 | |
| 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
| 26 | typedef void* gr_surface; |
| 27 | typedef unsigned short gr_pixel; |
| 28 | |
| 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); |
| 36 | void gr_fb_blank(bool blank); |
| 37 | |
| 38 | void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); |
| 39 | void gr_fill(int x1, int y1, int x2, int y2); |
| 40 | |
| 41 | // system/core/charger uses different gr_print signatures in diferent |
| 42 | // Android versions, either with or without int bold. |
| 43 | int gr_text(int x, int y, const char *s, ...); |
| 44 | int gr_text_impl(int x, int y, const char *s, int bold); |
| 45 | |
| 46 | void gr_texticon(int x, int y, gr_surface icon); |
| 47 | int gr_measure(const char *s); |
| 48 | void gr_font_size(int *x, int *y); |
| 49 | void gr_get_memory_surface(gr_surface); |
| 50 | |
| 51 | void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); |
| 52 | unsigned int gr_get_width(gr_surface surface); |
| 53 | unsigned int gr_get_height(gr_surface surface); |
| 54 | |
| 55 | // input event structure, include <linux/input.h> for the definition. |
| 56 | // see http://www.mjmwired.net/kernel/Documentation/input/ for info. |
| 57 | struct input_event; |
| 58 | |
| 59 | typedef int (*ev_callback)(int fd, uint32_t epevents, void *data); |
| 60 | typedef int (*ev_set_key_callback)(int code, int value, void *data); |
| 61 | |
| 62 | int ev_init(ev_callback input_cb, void *data); |
| 63 | void ev_exit(void); |
| 64 | int ev_add_fd(int fd, ev_callback cb, void *data); |
| 65 | int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data); |
| 66 | |
| 67 | /* timeout has the same semantics as for poll |
| 68 | * 0 : don't block |
| 69 | * < 0 : block forever |
| 70 | * > 0 : block for 'timeout' milliseconds |
| 71 | */ |
| 72 | int ev_wait(int timeout); |
| 73 | |
| 74 | int ev_get_input(int fd, uint32_t epevents, struct input_event *ev); |
| 75 | void ev_dispatch(void); |
| 76 | int ev_get_epollfd(void); |
| 77 | |
| 78 | // Resources |
| 79 | |
| 80 | // Returns 0 if no error, else negative. |
| 81 | int res_create_surface(const char* name, gr_surface* pSurface); |
| 82 | |
| 83 | // Load an array of display surfaces from a single PNG image. The PNG |
| 84 | // should have a 'Frames' text chunk whose value is the number of |
| 85 | // frames this image represents. The pixel data itself is interlaced |
| 86 | // by row. |
| 87 | int res_create_multi_display_surface(const char* name, |
| 88 | int* frames, gr_surface** pSurface); |
| 89 | |
| 90 | int res_create_localized_surface(const char* name, gr_surface* pSurface); |
| 91 | void res_free_surface(gr_surface surface); |
| 92 | static inline int res_create_display_surface(const char* name, gr_surface* pSurface) { |
| 93 | return res_create_surface(name, pSurface); |
| 94 | } |
| 95 | |
| 96 | // These are new graphics functions from 5.0 that were not available in |
| 97 | // 4.4 that are required by charger and healthd |
| 98 | void gr_clear(); |
| 99 | |
| 100 | |
| 101 | #ifdef __cplusplus |
| 102 | } |
| 103 | #endif |
| 104 | |
| 105 | #endif |