am 98b2c359: Copy over updated NDK APIs and follow other API changes.
Merge commit '98b2c359c2b3361f43e14b0c5d07a02c055dd10e' into gingerbread-plus-aosp * commit '98b2c359c2b3361f43e14b0c5d07a02c055dd10e': Copy over updated NDK APIs and follow other API changes.
This commit is contained in:
@@ -146,6 +146,21 @@ typedef struct ANativeActivityCallbacks {
|
|||||||
*/
|
*/
|
||||||
void (*onNativeWindowCreated)(ANativeActivity* activity, ANativeWindow* window);
|
void (*onNativeWindowCreated)(ANativeActivity* activity, ANativeWindow* window);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The drawing window for this native activity has been resized. You should
|
||||||
|
* retrieve the new size from the window and ensure that your rendering in
|
||||||
|
* it now matches.
|
||||||
|
*/
|
||||||
|
void (*onNativeWindowResized)(ANativeActivity* activity, ANativeWindow* window);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The drawing window for this native activity needs to be redrawn. To avoid
|
||||||
|
* transient artifacts during screen changes (such resizing after rotation),
|
||||||
|
* applications should not return from this function until they have finished
|
||||||
|
* drawing their window in its current state.
|
||||||
|
*/
|
||||||
|
void (*onNativeWindowRedrawNeeded)(ANativeActivity* activity, ANativeWindow* window);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The drawing window for this native activity is going to be destroyed.
|
* The drawing window for this native activity is going to be destroyed.
|
||||||
* You MUST ensure that you do not touch the window object after returning
|
* You MUST ensure that you do not touch the window object after returning
|
||||||
@@ -169,6 +184,11 @@ typedef struct ANativeActivityCallbacks {
|
|||||||
*/
|
*/
|
||||||
void (*onInputQueueDestroyed)(ANativeActivity* activity, AInputQueue* queue);
|
void (*onInputQueueDestroyed)(ANativeActivity* activity, AInputQueue* queue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The rectangle in the window in which content should be placed has changed.
|
||||||
|
*/
|
||||||
|
void (*onContentRectChanged)(ANativeActivity* activity, const ARect* rect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The system is running low on memory. Use this callback to release
|
* The system is running low on memory. Use this callback to release
|
||||||
* resources you do not need, to help the system avoid killing more
|
* resources you do not need, to help the system avoid killing more
|
||||||
@@ -197,6 +217,28 @@ void ANativeActivity_setWindowFormat(ANativeActivity* activity, int32_t format);
|
|||||||
void ANativeActivity_setWindowFlags(ANativeActivity* activity,
|
void ANativeActivity_setWindowFlags(ANativeActivity* activity,
|
||||||
uint32_t addFlags, uint32_t removeFlags);
|
uint32_t addFlags, uint32_t removeFlags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flags for ANativeActivity_showSoftInput; see the Java InputMethodManager
|
||||||
|
* API for documentation.
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT = 0x0001,
|
||||||
|
ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002,
|
||||||
|
};
|
||||||
|
|
||||||
|
void ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flags for ANativeActivity_hideSoftInput; see the Java InputMethodManager
|
||||||
|
* API for documentation.
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001,
|
||||||
|
ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002,
|
||||||
|
};
|
||||||
|
|
||||||
|
void ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ struct android_app {
|
|||||||
// When non-NULL, this is the window surface that the app can draw in.
|
// When non-NULL, this is the window surface that the app can draw in.
|
||||||
ANativeWindow* window;
|
ANativeWindow* window;
|
||||||
|
|
||||||
|
// Current content rectangle of the window; this is the area where the
|
||||||
|
// window's content should be placed to be seen by the user.
|
||||||
|
ARect contentRect;
|
||||||
|
|
||||||
// Current state of the app's activity. May be either APP_CMD_START,
|
// Current state of the app's activity. May be either APP_CMD_START,
|
||||||
// APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below.
|
// APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below.
|
||||||
int activityState;
|
int activityState;
|
||||||
@@ -69,8 +73,10 @@ struct android_app {
|
|||||||
|
|
||||||
int running;
|
int running;
|
||||||
int destroyed;
|
int destroyed;
|
||||||
|
int redrawNeeded;
|
||||||
AInputQueue* pendingInputQueue;
|
AInputQueue* pendingInputQueue;
|
||||||
ANativeWindow* pendingWindow;
|
ANativeWindow* pendingWindow;
|
||||||
|
ARect pendingContentRect;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -104,6 +110,26 @@ enum {
|
|||||||
*/
|
*/
|
||||||
APP_CMD_WINDOW_CHANGED,
|
APP_CMD_WINDOW_CHANGED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command from main thread: the current ANativeWindow has been resized.
|
||||||
|
* Please redraw with its new size.
|
||||||
|
*/
|
||||||
|
APP_CMD_WINDOW_RESIZED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command from main thread: the system needs that the current ANativeWindow
|
||||||
|
* be redrawn. You should redraw the window before handing this to
|
||||||
|
* android_app_exec_cmd() in order to avoid transient drawing glitches.
|
||||||
|
*/
|
||||||
|
APP_CMD_WINDOW_REDRAW_NEEDED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command from main thread: the content area of the window has changed,
|
||||||
|
* such as from the soft input window being shown or hidden. You can
|
||||||
|
* find the new content rect in android_app::contentRect.
|
||||||
|
*/
|
||||||
|
APP_CMD_CONTENT_RECT_CHANGED,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command from main thread: the app's activity window has gained
|
* Command from main thread: the app's activity window has gained
|
||||||
* input focus.
|
* input focus.
|
||||||
@@ -116,6 +142,12 @@ enum {
|
|||||||
*/
|
*/
|
||||||
APP_CMD_LOST_FOCUS,
|
APP_CMD_LOST_FOCUS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command from main thread: the system is running low on memory.
|
||||||
|
* Try to reduce your memory use.
|
||||||
|
*/
|
||||||
|
APP_CMD_LOW_MEMORY,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command from main thread: the app's activity has been started.
|
* Command from main thread: the app's activity has been started.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -8,4 +8,4 @@
|
|||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-7
|
target=android-9
|
||||||
|
|||||||
@@ -202,8 +202,8 @@ static void fill_plasma(ANativeWindow_Buffer* buffer, double t)
|
|||||||
#define YT2_INCR FIXED_FROM_FLOAT(1/163.)
|
#define YT2_INCR FIXED_FROM_FLOAT(1/163.)
|
||||||
|
|
||||||
void* pixels = buffer->bits;
|
void* pixels = buffer->bits;
|
||||||
LOGI("width=%d height=%d stride=%d format=%d", buffer->width, buffer->height,
|
//LOGI("width=%d height=%d stride=%d format=%d", buffer->width, buffer->height,
|
||||||
buffer->stride, buffer->format);
|
// buffer->stride, buffer->format);
|
||||||
|
|
||||||
int yy;
|
int yy;
|
||||||
for (yy = 0; yy < buffer->height; yy++) {
|
for (yy = 0; yy < buffer->height; yy++) {
|
||||||
@@ -417,6 +417,12 @@ static int engine_do_ui_event(struct engine* engine) {
|
|||||||
if (AInputEvent_getType(event) == INPUT_EVENT_TYPE_MOTION) {
|
if (AInputEvent_getType(event) == INPUT_EVENT_TYPE_MOTION) {
|
||||||
engine->animating = 1;
|
engine->animating = 1;
|
||||||
AInputQueue_finishEvent(engine->app->inputQueue, event, 1);
|
AInputQueue_finishEvent(engine->app->inputQueue, event, 1);
|
||||||
|
} else if (AInputEvent_getType(event) == INPUT_EVENT_TYPE_KEY) {
|
||||||
|
LOGI("Key event: action=%d keyCode=%d metaState=0x%x",
|
||||||
|
AKeyEvent_getAction(event),
|
||||||
|
AKeyEvent_getKeyCode(event),
|
||||||
|
AKeyEvent_getMetaState(event));
|
||||||
|
AInputQueue_finishEvent(engine->app->inputQueue, event, 0);
|
||||||
} else {
|
} else {
|
||||||
AInputQueue_finishEvent(engine->app->inputQueue, event, 0);
|
AInputQueue_finishEvent(engine->app->inputQueue, event, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import android.view.SurfaceHolder;
|
|||||||
* Demonstrates how to take over the Surface from a window to do direct
|
* Demonstrates how to take over the Surface from a window to do direct
|
||||||
* drawing to it (without going through the view hierarchy).
|
* drawing to it (without going through the view hierarchy).
|
||||||
*/
|
*/
|
||||||
public class WindowSurface extends Activity implements SurfaceHolder.Callback {
|
public class WindowSurface extends Activity implements SurfaceHolder.Callback2 {
|
||||||
DrawingThread mDrawingThread;
|
DrawingThread mDrawingThread;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,6 +76,9 @@ public class WindowSurface extends Activity implements SurfaceHolder.Callback {
|
|||||||
// new sizes from the canvas.
|
// new sizes from the canvas.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void surfaceRedrawNeeded(SurfaceHolder holder) {
|
||||||
|
}
|
||||||
|
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
// We need to tell the drawing thread to stop, and block until
|
// We need to tell the drawing thread to stop, and block until
|
||||||
// it has done so.
|
// it has done so.
|
||||||
|
|||||||
Reference in New Issue
Block a user