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 /* Keep synchronized with check-configs.pl and jwxyz.java. */
28 struct jwxyz_Drawable {
29 enum { WINDOW, PIXMAP } type;
32 EGLSurface egl_surface;
33 GLuint texture; /* If this is 0, it's the default framebuffer. */
37 struct running_hack *rh;
38 int last_mouse_x, last_mouse_y;
47 struct xscreensaver_function_table *xsft;
56 /* These are set up in Java by the GLSurfaceView. */
58 EGLSurface egl_surface;
59 EGLDisplay egl_display;
64 PFNGLBINDFRAMEBUFFEROESPROC glBindFramebufferOES;
65 PFNGLFRAMEBUFFERTEXTURE2DOESPROC glFramebufferTexture2DOES;
67 struct jwxyz_Drawable frontbuffer;
69 Bool gl_fbo_p, frontbuffer_p;
72 Drawable current_drawable;
73 Bool ignore_rotation_p;
75 jwzgles_state *gles_state;
77 unsigned long frame_count;
79 struct event_queue *event_queue;
83 extern void prepare_context (struct running_hack *rh);
86 // Methods of the Java class org.jwz.jwxyz that are implemented in C.
88 JNIEXPORT void JNICALL
89 Java_org_jwz_xscreensaver_jwxyz_nativeInit (JNIEnv *, jobject thiz,
94 JNIEXPORT void JNICALL
95 Java_org_jwz_xscreensaver_jwxyz_nativeResize (JNIEnv *, jobject thiz,
96 jint w, jint h, jdouble rot);
98 JNIEXPORT jlong JNICALL
99 Java_org_jwz_xscreensaver_jwxyz_nativeRender (JNIEnv *, jobject thiz);
101 JNIEXPORT void JNICALL
102 Java_org_jwz_xscreensaver_jwxyz_nativeDone (JNIEnv *, jobject thiz);
104 JNIEXPORT void JNICALL
105 Java_org_jwz_xscreensaver_jwxyz_allnativeSettings (JNIEnv *, jobject thiz,
108 jint draw, jstring key);
110 JNIEXPORT jboolean JNICALL
111 Java_org_jwz_xscreensaver_jwxyz_ignoreRotation (JNIEnv *, jobject thiz);
113 JNIEXPORT jboolean JNICALL
114 Java_org_jwz_xscreensaver_jwxyz_suppressRotationAnimation (JNIEnv *,
117 JNIEXPORT void JNICALL
118 Java_org_jwz_xscreensaver_jwxyz_sendButtonEvent (JNIEnv *, jobject thiz,
119 int x, int y, jboolean down);
121 JNIEXPORT void JNICALL
122 Java_org_jwz_xscreensaver_jwxyz_sendMotionEvent (JNIEnv *, jobject thiz,
125 JNIEXPORT void JNICALL
126 Java_org_jwz_xscreensaver_jwxyz_sendKeyEvent (JNIEnv *, jobject thiz,
130 #endif // __JWXYZ_ANDROID_H__