1 /* xscreensaver, Copyright (c) 2016 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
12 #ifndef __JWXYZ_ANDROID_H__
13 #define __JWXYZ_ANDROID_H__
16 #include "../hacks/fps.h"
18 #include <android/log.h>
19 /* Native EGL is Android 2.3/API 9. EGL in Java is available from API 1. */
21 #include <GLES/glext.h>
24 /* From utils/visual.c. */
25 #define DEFAULT_VISUAL -1
28 struct jwxyz_Drawable {
29 enum { WINDOW, PIXMAP } type;
33 EGLSurface egl_surface;
34 GLuint texture; /* If this is 0, it's the default framebuffer. */
41 struct running_hack *rh;
42 int last_mouse_x, last_mouse_y;
51 struct xscreensaver_function_table *xsft;
59 Bool jwxyz_gl_p, egl_p;
63 EGLSurface egl_surface;
64 EGLDisplay egl_display;
69 struct jwxyz_Drawable frontbuffer;
71 Bool gl_fbo_p, frontbuffer_p;
74 Drawable current_drawable;
77 ANativeWindow *native_window;
79 Bool ignore_rotation_p;
81 jwzgles_state *gles_state;
83 unsigned long frame_count;
85 struct event_queue *event_queue;
89 // Methods of the Java class org.jwz.jwxyz that are implemented in C.
91 JNIEXPORT void JNICALL
92 Java_org_jwz_xscreensaver_jwxyz_nativeInit (JNIEnv *, jobject thiz,
98 JNIEXPORT void JNICALL
99 Java_org_jwz_xscreensaver_jwxyz_nativeResize (JNIEnv *, jobject thiz,
100 jint w, jint h, jdouble rot);
102 JNIEXPORT jlong JNICALL
103 Java_org_jwz_xscreensaver_jwxyz_nativeRender (JNIEnv *, jobject thiz);
105 JNIEXPORT void JNICALL
106 Java_org_jwz_xscreensaver_jwxyz_nativeDone (JNIEnv *, jobject thiz);
108 JNIEXPORT void JNICALL
109 Java_org_jwz_xscreensaver_jwxyz_sendButtonEvent (JNIEnv *, jobject thiz,
110 int x, int y, jboolean down);
112 JNIEXPORT void JNICALL
113 Java_org_jwz_xscreensaver_jwxyz_sendMotionEvent (JNIEnv *, jobject thiz,
116 JNIEXPORT void JNICALL
117 Java_org_jwz_xscreensaver_jwxyz_sendKeyEvent (JNIEnv *, jobject thiz,
121 #endif // __JWXYZ_ANDROID_H__