blob: b4b57e1db57c7b0496ae1df289c5d3b5a46df8d6 [file] [log] [blame]
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08001/*
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
Doug Zongker830b3e32014-03-11 13:22:04 -070020#include <sys/types.h>
21
Dima Zavin4daf48a2011-08-30 11:59:20 -070022#include <stdbool.h>
23
Doug Zongker28ce47c2011-10-28 10:33:05 -070024#ifdef __cplusplus
25extern "C" {
26#endif
27
Doug Zongker39cf4172014-03-06 16:16:05 -080028typedef struct {
29 int width;
30 int height;
31 int row_bytes;
32 int pixel_bytes;
33 unsigned char* data;
34} GRSurface;
35
36typedef GRSurface* gr_surface;
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080037
38int gr_init(void);
39void gr_exit(void);
40
41int gr_fb_width(void);
42int gr_fb_height(void);
Doug Zongker39cf4172014-03-06 16:16:05 -080043
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080044void gr_flip(void);
Dima Zavin4daf48a2011-08-30 11:59:20 -070045void gr_fb_blank(bool blank);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080046
Doug Zongker39cf4172014-03-06 16:16:05 -080047void gr_clear(); // clear entire surface to current color
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080048void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
Doug Zongkerc560a672012-12-18 16:31:27 -080049void gr_fill(int x1, int y1, int x2, int y2);
Doug Zongker39cf4172014-03-06 16:16:05 -080050void gr_text(int x, int y, const char *s, int bold);
51void gr_texticon(int x, int y, gr_surface icon);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080052int gr_measure(const char *s);
Dima Zavin3c7f00e2011-08-30 11:58:24 -070053void gr_font_size(int *x, int *y);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080054
55void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
56unsigned int gr_get_width(gr_surface surface);
57unsigned int gr_get_height(gr_surface surface);
58
59// input event structure, include <linux/input.h> for the definition.
60// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
61struct input_event;
62
Todd Poynora5ef19f2013-09-17 13:39:10 -070063typedef int (*ev_callback)(int fd, uint32_t epevents, void *data);
Dima Zavin441031d2011-10-12 15:53:29 -070064typedef int (*ev_set_key_callback)(int code, int value, void *data);
Dima Zavinbc290632011-08-30 11:59:45 -070065
66int ev_init(ev_callback input_cb, void *data);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080067void ev_exit(void);
Dima Zavin36583672011-09-02 11:51:31 -070068int ev_add_fd(int fd, ev_callback cb, void *data);
Dima Zavin441031d2011-10-12 15:53:29 -070069int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data);
Dima Zavinbc290632011-08-30 11:59:45 -070070
71/* timeout has the same semantics as for poll
72 * 0 : don't block
73 * < 0 : block forever
74 * > 0 : block for 'timeout' milliseconds
75 */
76int ev_wait(int timeout);
77
Todd Poynora5ef19f2013-09-17 13:39:10 -070078int ev_get_input(int fd, uint32_t epevents, struct input_event *ev);
Dima Zavinbc290632011-08-30 11:59:45 -070079void ev_dispatch(void);
Todd Poynor4665ede2013-09-10 17:03:45 -070080int ev_get_epollfd(void);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080081
82// Resources
83
84// Returns 0 if no error, else negative.
85int res_create_surface(const char* name, gr_surface* pSurface);
Doug Zongkereac881c2014-03-07 09:21:25 -080086int res_create_multi_surface(const char* name, int* frames, gr_surface** pSurface);
Doug Zongker02ec6b82012-08-22 17:26:40 -070087int res_create_localized_surface(const char* name, gr_surface* pSurface);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080088void res_free_surface(gr_surface surface);
89
Doug Zongker28ce47c2011-10-28 10:33:05 -070090#ifdef __cplusplus
91}
92#endif
93
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080094#endif