zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
android_native_app_glue.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 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 
18 #ifndef _ANDROID_NATIVE_APP_GLUE_H
19 #define _ANDROID_NATIVE_APP_GLUE_H
20 
21 #include <poll.h>
22 #include <pthread.h>
23 #include <sched.h>
24 
25 #include <android/configuration.h>
26 #include <android/looper.h>
27 #include <android/native_activity.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
84 struct android_app;
85 
91  // The identifier of this source. May be LOOPER_ID_MAIN or
92  // LOOPER_ID_INPUT.
94 
95  // The android_app this ident is associated with.
96  struct android_app* app;
97 
98  // Function to call to perform the standard processing of data from
99  // this source.
101 };
102 
111 struct android_app {
112  // The application can place a pointer to its own state object
113  // here if it likes.
114  void* userData;
115 
116  // Fill this in with the function to process main app commands (APP_CMD_*)
117  void (*onAppCmd)(struct android_app* app, int32_t cmd);
118 
119  // Fill this in with the function to process input events. At this point
120  // the event has already been pre-dispatched, and it will be finished upon
121  // return. Return 1 if you have handled the event, 0 for any default
122  // dispatching.
123  int32_t (*onInputEvent)(struct android_app* app, AInputEvent* event);
124 
125  // The ANativeActivity object instance that this app is running in.
126  ANativeActivity* activity;
127 
128  // The current configuration the app is running in.
129  AConfiguration* config;
130 
131  // This is the last instance's saved state, as provided at creation time.
132  // It is NULL if there was no state. You can use this as you need; the
133  // memory will remain around until you call android_app_exec_cmd() for
134  // APP_CMD_RESUME, at which point it will be freed and savedState set to NULL.
135  // These variables should only be changed when processing a APP_CMD_SAVE_STATE,
136  // at which point they will be initialized to NULL and you can malloc your
137  // state and place the information here. In that case the memory will be
138  // freed for you later.
139  void* savedState;
141 
142  // The ALooper associated with the app's thread.
143  ALooper* looper;
144 
145  // When non-NULL, this is the input queue from which the app will
146  // receive user input events.
147  AInputQueue* inputQueue;
148 
149  // When non-NULL, this is the window surface that the app can draw in.
150  ANativeWindow* window;
151 
152  // Current content rectangle of the window; this is the area where the
153  // window's content should be placed to be seen by the user.
154  ARect contentRect;
155 
156  // Current state of the app's activity. May be either APP_CMD_START,
157  // APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below.
159 
160  // This is non-zero when the application's NativeActivity is being
161  // destroyed and waiting for the app thread to complete.
163 
164  // -------------------------------------------------
165  // Below are "private" implementation of the glue code.
166 
167  pthread_mutex_t mutex;
168  pthread_cond_t cond;
169 
170  int msgread;
171  int msgwrite;
172 
173  pthread_t thread;
174 
177 
178  int running;
182  AInputQueue* pendingInputQueue;
183  ANativeWindow* pendingWindow;
185 };
186 
187 enum {
196 
205 
210 };
211 
212 enum {
219 
226 
234 
240 
247 
254 
260 
266 
271 
277 
282 
287 
296 
301 
306 
312 };
313 
319 
326 
333 
337 void app_dummy();
338 
343 extern void android_main(struct android_app* app);
344 
345 #ifdef __cplusplus
346 }
347 #endif
348 
349 #endif /* _ANDROID_NATIVE_APP_GLUE_H */
struct android_app * app
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1824
AInputQueue * inputQueue
void android_app_pre_exec_cmd(struct android_app *android_app, int8_t cmd)
ANativeWindow * pendingWindow
ANativeWindow * window
long int32_t
Definition: types.h:9
int8_t android_app_read_cmd(struct android_app *android_app)
void(* onAppCmd)(struct android_app *app, int32_t cmd)
pthread_cond_t cond
void app_dummy()
void android_main(struct android_app *state)
Definition: main.cpp:352
struct android_poll_source inputPollSource
AInputQueue * pendingInputQueue
void(* process)(struct android_app *app, struct android_poll_source *source)
signed char int8_t
pthread_mutex_t mutex
struct android_poll_source cmdPollSource
AConfiguration * config
int32_t(* onInputEvent)(struct android_app *app, AInputEvent *event)
ANativeActivity * activity
GLsizei GLsizei GLchar * source
Definition: gl2ext.h:994
void android_app_post_exec_cmd(struct android_app *android_app, int8_t cmd)
cl_event event
Definition: glew.h:3556