xref: /OK3568_Linux_fs/external/rk_pcba_test/pcba_minui/minui/minui.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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 #include <inttypes.h>
20 #include <sys/types.h>
21 
22 #include <stdbool.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 typedef struct {
29     int width;
30     int height;
31     int row_bytes;
32     int pixel_bytes;
33     unsigned char* data;
34 } GRSurface;
35 
36 typedef GRSurface* gr_surface;
37 
38 int gr_init(void);
39 void gr_exit(void);
40 
41 int gr_fb_width(void);
42 int gr_fb_height(void);
43 
44 void gr_flip(void);
45 void gr_fb_blank(bool blank);
46 
47 void gr_clear();  // clear entire surface to current color
48 void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
49 void gr_fill(int x1, int y1, int x2, int y2);
50 
51 
52 
53 void gr_texticon(int x, int y, gr_surface icon);
54 int gr_measure(const char *s);
55 void gr_font_size(int *x, int *y);
56 
57 void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
58 unsigned int gr_get_width(gr_surface surface);
59 unsigned int gr_get_height(gr_surface surface);
60 
61 // input event structure, include <linux/input.h> for the definition.
62 // see http://www.mjmwired.net/kernel/Documentation/input/ for info.
63 struct input_event;
64 
65 typedef int (*ev_callback)(int fd, uint32_t epevents, void *data);
66 typedef int (*ev_set_key_callback)(int code, int value, void *data);
67 
68 void gr_text(int x, int y, const char *s, int bold);
69 
70 int ev_init(void);
71 void ev_exit(void);
72 int ev_get(struct input_event *ev, unsigned dont_wait);
73 
74 
75 // Resources
76 
77 // res_create_*_surface() functions return 0 if no error, else
78 // negative.
79 //
80 // A "display" surface is one that is intended to be drawn to the
81 // screen with gr_blit().  An "alpha" surface is a grayscale image
82 // interpreted as an alpha mask used to render text in the current
83 // color (with gr_text() or gr_texticon()).
84 //
85 // All these functions load PNG images from "/res/images/${name}.png".
86 
87 // Load a single display surface from a PNG image.
88 int res_create_display_surface(const char* name, gr_surface* pSurface);
89 
90 // Load an array of display surfaces from a single PNG image.  The PNG
91 // should have a 'Frames' text chunk whose value is the number of
92 // frames this image represents.  The pixel data itself is interlaced
93 // by row.
94 int res_create_multi_display_surface(const char* name,
95                                      int* frames, gr_surface** pSurface);
96 
97 // Load a single alpha surface from a grayscale PNG image.
98 int res_create_alpha_surface(const char* name, gr_surface* pSurface);
99 
100 // Load part of a grayscale PNG image that is the first match for the
101 // given locale.  The image is expected to be a composite of multiple
102 // translations of the same text, with special added rows that encode
103 // the subimages' size and intended locale in the pixel data.  See
104 // development/tools/recovery_l10n for an app that will generate these
105 // specialized images from Android resources.
106 int res_create_localized_alpha_surface(const char* name, const char* locale,
107                                        gr_surface* pSurface);
108 
109 // Free a surface allocated by any of the res_create_*_surface()
110 // functions.
111 void res_free_surface(gr_surface surface);
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif
118