blob: 4c629c1b5df2b17cb3343008e8f6414ff6c557ec [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
Dima Zavin4daf48a2011-08-30 11:59:20 -070020#include <stdbool.h>
21
Doug Zongker28ce47c2011-10-28 10:33:05 -070022#ifdef __cplusplus
23extern "C" {
24#endif
25
Ethan Yonkera33161b2014-11-06 15:11:20 -060026typedef void* gr_surface;
27typedef unsigned short gr_pixel;
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080028
29int gr_init(void);
30void gr_exit(void);
31
32int gr_fb_width(void);
33int gr_fb_height(void);
Ethan Yonkera33161b2014-11-06 15:11:20 -060034gr_pixel *gr_fb_data(void);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080035void gr_flip(void);
Dima Zavin4daf48a2011-08-30 11:59:20 -070036void gr_fb_blank(bool blank);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080037
38void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
Doug Zongkerc560a672012-12-18 16:31:27 -080039void gr_fill(int x1, int y1, int x2, int y2);
Vojtech Bocek65fdcdd2013-09-06 21:32:22 +020040
41// system/core/charger uses different gr_print signatures in diferent
42// Android versions, either with or without int bold.
43int gr_text(int x, int y, const char *s, ...);
44int gr_text_impl(int x, int y, const char *s, int bold);
45
Ethan Yonkera33161b2014-11-06 15:11:20 -060046 void gr_texticon(int x, int y, gr_surface icon);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080047int gr_measure(const char *s);
Dima Zavin3c7f00e2011-08-30 11:58:24 -070048void gr_font_size(int *x, int *y);
Dees Troy62b75ab2014-05-02 13:20:33 +000049void gr_get_memory_surface(gr_surface);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080050
51void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
52unsigned int gr_get_width(gr_surface surface);
53unsigned 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.
57struct input_event;
58
Ethan Yonker304f32f2014-11-07 10:14:05 -060059typedef int (*ev_callback)(int fd, uint32_t epevents, void *data);
Dima Zavin441031d2011-10-12 15:53:29 -070060typedef int (*ev_set_key_callback)(int code, int value, void *data);
Dima Zavinbc290632011-08-30 11:59:45 -070061
62int ev_init(ev_callback input_cb, void *data);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080063void ev_exit(void);
Dima Zavin36583672011-09-02 11:51:31 -070064int ev_add_fd(int fd, ev_callback cb, void *data);
Dima Zavin441031d2011-10-12 15:53:29 -070065int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data);
Dima Zavinbc290632011-08-30 11:59:45 -070066
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 */
72int ev_wait(int timeout);
73
Ethan Yonker304f32f2014-11-07 10:14:05 -060074int ev_get_input(int fd, uint32_t epevents, struct input_event *ev);
Dima Zavinbc290632011-08-30 11:59:45 -070075void ev_dispatch(void);
Ethan Yonker304f32f2014-11-07 10:14:05 -060076int ev_get_epollfd(void);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080077
78// Resources
79
Ethan Yonkera33161b2014-11-06 15:11:20 -060080// Returns 0 if no error, else negative.
81int res_create_surface(const char* name, gr_surface* pSurface);
Ethan Yonker304f32f2014-11-07 10:14:05 -060082
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.
87int res_create_multi_display_surface(const char* name,
88 int* frames, gr_surface** pSurface);
89
Ethan Yonkera33161b2014-11-06 15:11:20 -060090int res_create_localized_surface(const char* name, gr_surface* pSurface);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080091void res_free_surface(gr_surface surface);
Steve Kondik626009f2014-04-30 13:25:41 -070092static inline int res_create_display_surface(const char* name, gr_surface* pSurface) {
93 return res_create_surface(name, pSurface);
94}
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080095
Ethan Yonker304f32f2014-11-07 10:14:05 -060096// These are new graphics functions from 5.0 that were not available in
97// 4.4 that are required by charger and healthd
98void gr_clear();
99
100
Doug Zongker28ce47c2011-10-28 10:33:05 -0700101#ifdef __cplusplus
102}
103#endif
104
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800105#endif