webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
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 
175  struct android_poll_source cmdPollSource;
176  struct android_poll_source inputPollSource;
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 */
std::integral_constant< std::int32_t, V > int32_t
Definition: Brigand.h:439
Definition: android_native_app_glue.h:265
Definition: android_native_app_glue.h:270
ARect contentRect
Definition: android_native_app_glue.h:154
struct android_app * app
Definition: android_native_app_glue.h:96
GLsizei GLsizei GLchar * source
Definition: gl2.h:451
AInputQueue * inputQueue
Definition: android_native_app_glue.h:147
void android_app_pre_exec_cmd(struct android_app *android_app, int8_t cmd)
Definition: android_native_app_glue.c:89
cmd
Definition: vs_env.py:27
Definition: android_native_app_glue.h:259
signed int int32_t
Definition: ptypes.h:101
ANativeWindow * pendingWindow
Definition: android_native_app_glue.h:183
Definition: android_native_app_glue.h:204
Definition: android_native_app_glue.h:218
Definition: android_native_app_glue.h:253
size_t savedStateSize
Definition: android_native_app_glue.h:140
ANativeWindow * window
Definition: android_native_app_glue.h:150
int destroyRequested
Definition: android_native_app_glue.h:162
int8_t android_app_read_cmd(struct android_app *android_app)
Definition: android_native_app_glue.c:49
void android_main(struct android_app *app)
Definition: AndroidWindow.cpp:131
Definition: android_native_app_glue.h:195
Definition: android_native_app_glue.h:246
pthread_cond_t cond
Definition: android_native_app_glue.h:168
Definition: android_native_app_glue.h:225
int msgread
Definition: android_native_app_glue.h:170
void * savedState
Definition: android_native_app_glue.h:139
void * userData
Definition: android_native_app_glue.h:114
Definition: android_native_app_glue.h:111
void
Definition: AVFoundationCFSoftLinking.h:81
void app_dummy()
Definition: android_native_app_glue.c:170
int activityState
Definition: android_native_app_glue.h:158
int running
Definition: android_native_app_glue.h:178
Definition: android_native_app_glue.h:209
Definition: android_native_app_glue.h:233
Definition: android_native_app_glue.h:286
int stateSaved
Definition: android_native_app_glue.h:179
int destroyed
Definition: android_native_app_glue.h:180
Definition: android_native_app_glue.h:295
AInputQueue * pendingInputQueue
Definition: android_native_app_glue.h:182
Definition: android_native_app_glue.h:276
Definition: android_native_app_glue.h:305
int redrawNeeded
Definition: android_native_app_glue.h:181
-ogles2-tests
pthread_mutex_t mutex
Definition: android_native_app_glue.h:167
Definition: android_native_app_glue.h:90
AConfiguration * config
Definition: android_native_app_glue.h:129
pthread_t thread
Definition: android_native_app_glue.h:173
int32_t id
Definition: android_native_app_glue.h:93
ANativeActivity * activity
Definition: android_native_app_glue.h:126
int msgwrite
Definition: android_native_app_glue.h:171
signed char int8_t
Definition: ptypes.h:85
int32_t(* onInputEvent)(struct android_app *app, AInputEvent *event)
Definition: android_native_app_glue.h:123
Definition: android_native_app_glue.h:300
Definition: android_native_app_glue.h:281
void android_app_post_exec_cmd(struct android_app *android_app, int8_t cmd)
Definition: android_native_app_glue.c:146
Definition: android_native_app_glue.h:311
ARect pendingContentRect
Definition: android_native_app_glue.h:184
Definition: android_native_app_glue.h:239
ALooper * looper
Definition: android_native_app_glue.h:143