blob: 5d49204075dd638ade695287e489c28d09e1d47b [file] [log] [blame]
Jamie Gennis6714efc2010-12-20 12:09:37 -08001/*
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#define LOG_TAG "SurfaceTexture"
18
19#include <stdio.h>
20
Mathias Agopiane3eae732013-08-08 19:24:14 -070021#include <GLES2/gl2.h>
22#include <GLES2/gl2ext.h>
23
Andy McFaddend47f7d82012-12-18 09:48:38 -080024#include <gui/GLConsumer.h>
Mathias Agopian52800612013-02-14 17:11:20 -080025#include <gui/Surface.h>
Jamie Gennis6714efc2010-12-20 12:09:37 -080026
27#include <android_runtime/AndroidRuntime.h>
28
29#include <utils/Log.h>
30#include <utils/misc.h>
31
Jamie Gennis6714efc2010-12-20 12:09:37 -080032#include "jni.h"
Jamie Gennis376590d2011-01-13 14:43:36 -080033#include "JNIHelp.h"
Jamie Gennis6714efc2010-12-20 12:09:37 -080034
35// ----------------------------------------------------------------------------
36
37namespace android {
38
39static const char* const OutOfResourcesException =
Igor Murashkina86ab6402013-08-30 12:58:36 -070040 "android/view/Surface$OutOfResourcesException";
Jamie Gennis2b4bfa52012-04-13 14:48:22 -070041static const char* const IllegalStateException = "java/lang/IllegalStateException";
tedbo05031612011-06-06 16:02:47 -070042const char* const kSurfaceTextureClassPathName = "android/graphics/SurfaceTexture";
Jamie Gennis6714efc2010-12-20 12:09:37 -080043
Jamie Gennis376590d2011-01-13 14:43:36 -080044struct fields_t {
45 jfieldID surfaceTexture;
Mathias Agopian52a9a102013-08-02 01:38:38 -070046 jfieldID bufferQueue;
Igor Murashkinc99db2b2012-10-29 13:38:10 -070047 jfieldID frameAvailableListener;
Jamie Gennis376590d2011-01-13 14:43:36 -080048 jmethodID postEvent;
Jamie Gennis6714efc2010-12-20 12:09:37 -080049};
Jamie Gennis376590d2011-01-13 14:43:36 -080050static fields_t fields;
Jamie Gennis6714efc2010-12-20 12:09:37 -080051
52// ----------------------------------------------------------------------------
53
Jamie Gennis376590d2011-01-13 14:43:36 -080054static void SurfaceTexture_setSurfaceTexture(JNIEnv* env, jobject thiz,
Andy McFaddend47f7d82012-12-18 09:48:38 -080055 const sp<GLConsumer>& surfaceTexture)
Jamie Gennis6714efc2010-12-20 12:09:37 -080056{
Andy McFaddend47f7d82012-12-18 09:48:38 -080057 GLConsumer* const p =
Ashok Bhat72aa3132014-01-13 20:41:06 +000058 (GLConsumer*)env->GetLongField(thiz, fields.surfaceTexture);
Jamie Gennis6714efc2010-12-20 12:09:37 -080059 if (surfaceTexture.get()) {
Mathias Agopianb1d90c82013-03-06 17:45:42 -080060 surfaceTexture->incStrong((void*)SurfaceTexture_setSurfaceTexture);
Jamie Gennis6714efc2010-12-20 12:09:37 -080061 }
62 if (p) {
Mathias Agopianb1d90c82013-03-06 17:45:42 -080063 p->decStrong((void*)SurfaceTexture_setSurfaceTexture);
Jamie Gennis6714efc2010-12-20 12:09:37 -080064 }
Ashok Bhat72aa3132014-01-13 20:41:06 +000065 env->SetLongField(thiz, fields.surfaceTexture, (jlong)surfaceTexture.get());
Jamie Gennis6714efc2010-12-20 12:09:37 -080066}
67
Mathias Agopian52a9a102013-08-02 01:38:38 -070068static void SurfaceTexture_setBufferQueue(JNIEnv* env, jobject thiz,
69 const sp<BufferQueue>& bq)
70{
71 BufferQueue* const p =
Ashok Bhat72aa3132014-01-13 20:41:06 +000072 (BufferQueue*)env->GetLongField(thiz, fields.bufferQueue);
Mathias Agopian52a9a102013-08-02 01:38:38 -070073 if (bq.get()) {
74 bq->incStrong((void*)SurfaceTexture_setBufferQueue);
75 }
76 if (p) {
77 p->decStrong((void*)SurfaceTexture_setBufferQueue);
78 }
Ashok Bhat72aa3132014-01-13 20:41:06 +000079 env->SetLongField(thiz, fields.bufferQueue, (jlong)bq.get());
Mathias Agopian52a9a102013-08-02 01:38:38 -070080}
81
Igor Murashkinc99db2b2012-10-29 13:38:10 -070082static void SurfaceTexture_setFrameAvailableListener(JNIEnv* env,
Andy McFaddend47f7d82012-12-18 09:48:38 -080083 jobject thiz, sp<GLConsumer::FrameAvailableListener> listener)
Jamie Gennis6714efc2010-12-20 12:09:37 -080084{
Andy McFaddend47f7d82012-12-18 09:48:38 -080085 GLConsumer::FrameAvailableListener* const p =
86 (GLConsumer::FrameAvailableListener*)
Ashok Bhat72aa3132014-01-13 20:41:06 +000087 env->GetLongField(thiz, fields.frameAvailableListener);
Igor Murashkinc99db2b2012-10-29 13:38:10 -070088 if (listener.get()) {
Mathias Agopianb1d90c82013-03-06 17:45:42 -080089 listener->incStrong((void*)SurfaceTexture_setSurfaceTexture);
Igor Murashkinc99db2b2012-10-29 13:38:10 -070090 }
91 if (p) {
Mathias Agopianb1d90c82013-03-06 17:45:42 -080092 p->decStrong((void*)SurfaceTexture_setSurfaceTexture);
Igor Murashkinc99db2b2012-10-29 13:38:10 -070093 }
Ashok Bhat72aa3132014-01-13 20:41:06 +000094 env->SetLongField(thiz, fields.frameAvailableListener, (jlong)listener.get());
Igor Murashkinc99db2b2012-10-29 13:38:10 -070095}
96
Mathias Agopian52a9a102013-08-02 01:38:38 -070097sp<GLConsumer> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz) {
Ashok Bhat72aa3132014-01-13 20:41:06 +000098 return (GLConsumer*)env->GetLongField(thiz, fields.surfaceTexture);
Jamie Gennis6714efc2010-12-20 12:09:37 -080099}
100
Mathias Agopian52a9a102013-08-02 01:38:38 -0700101sp<IGraphicBufferProducer> SurfaceTexture_getProducer(JNIEnv* env, jobject thiz) {
Ashok Bhat72aa3132014-01-13 20:41:06 +0000102 return (BufferQueue*)env->GetLongField(thiz, fields.bufferQueue);
Mathias Agopian52a9a102013-08-02 01:38:38 -0700103}
104
105sp<ANativeWindow> android_SurfaceTexture_getNativeWindow(JNIEnv* env, jobject thiz) {
Andy McFaddend47f7d82012-12-18 09:48:38 -0800106 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
Mathias Agopian52a9a102013-08-02 01:38:38 -0700107 sp<IGraphicBufferProducer> producer(SurfaceTexture_getProducer(env, thiz));
108 sp<Surface> surfaceTextureClient(surfaceTexture != NULL ? new Surface(producer) : NULL);
Glenn Kasten846db332011-03-04 11:44:32 -0800109 return surfaceTextureClient;
110}
111
Mathias Agopian52a9a102013-08-02 01:38:38 -0700112bool android_SurfaceTexture_isInstanceOf(JNIEnv* env, jobject thiz) {
tedbo05031612011-06-06 16:02:47 -0700113 jclass surfaceTextureClass = env->FindClass(kSurfaceTextureClassPathName);
114 return env->IsInstanceOf(thiz, surfaceTextureClass);
115}
116
Jamie Gennis6714efc2010-12-20 12:09:37 -0800117// ----------------------------------------------------------------------------
118
Andy McFaddend47f7d82012-12-18 09:48:38 -0800119class JNISurfaceTextureContext : public GLConsumer::FrameAvailableListener
Jamie Gennis6714efc2010-12-20 12:09:37 -0800120{
Jamie Gennis376590d2011-01-13 14:43:36 -0800121public:
122 JNISurfaceTextureContext(JNIEnv* env, jobject weakThiz, jclass clazz);
123 virtual ~JNISurfaceTextureContext();
124 virtual void onFrameAvailable();
Jamie Gennis6714efc2010-12-20 12:09:37 -0800125
Jamie Gennis376590d2011-01-13 14:43:36 -0800126private:
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700127 static JNIEnv* getJNIEnv(bool* needsDetach);
128 static void detachJNI();
Jamie Gennis84293fb2011-06-17 16:35:35 -0700129
Jamie Gennis376590d2011-01-13 14:43:36 -0800130 jobject mWeakThiz;
131 jclass mClazz;
132};
133
134JNISurfaceTextureContext::JNISurfaceTextureContext(JNIEnv* env,
135 jobject weakThiz, jclass clazz) :
136 mWeakThiz(env->NewGlobalRef(weakThiz)),
137 mClazz((jclass)env->NewGlobalRef(clazz))
138{}
139
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700140JNIEnv* JNISurfaceTextureContext::getJNIEnv(bool* needsDetach) {
141 *needsDetach = false;
142 JNIEnv* env = AndroidRuntime::getJNIEnv();
143 if (env == NULL) {
Andy McFadden9b311c92014-02-04 15:59:39 -0800144 JavaVMAttachArgs args = {
145 JNI_VERSION_1_4, "JNISurfaceTextureContext", NULL };
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700146 JavaVM* vm = AndroidRuntime::getJavaVM();
147 int result = vm->AttachCurrentThread(&env, (void*) &args);
148 if (result != JNI_OK) {
Steve Block3762c312012-01-06 19:20:56 +0000149 ALOGE("thread attach failed: %#x", result);
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700150 return NULL;
151 }
152 *needsDetach = true;
Jamie Gennis84293fb2011-06-17 16:35:35 -0700153 }
154 return env;
155}
156
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700157void JNISurfaceTextureContext::detachJNI() {
158 JavaVM* vm = AndroidRuntime::getJavaVM();
159 int result = vm->DetachCurrentThread();
160 if (result != JNI_OK) {
Steve Block3762c312012-01-06 19:20:56 +0000161 ALOGE("thread detach failed: %#x", result);
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700162 }
163}
164
Jamie Gennis376590d2011-01-13 14:43:36 -0800165JNISurfaceTextureContext::~JNISurfaceTextureContext()
166{
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700167 bool needsDetach = false;
168 JNIEnv* env = getJNIEnv(&needsDetach);
Jamie Gennis84293fb2011-06-17 16:35:35 -0700169 if (env != NULL) {
170 env->DeleteGlobalRef(mWeakThiz);
171 env->DeleteGlobalRef(mClazz);
172 } else {
Steve Block8564c8d2012-01-05 23:22:43 +0000173 ALOGW("leaking JNI object references");
Jamie Gennis84293fb2011-06-17 16:35:35 -0700174 }
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700175 if (needsDetach) {
176 detachJNI();
177 }
Jamie Gennis6714efc2010-12-20 12:09:37 -0800178}
179
Jamie Gennis376590d2011-01-13 14:43:36 -0800180void JNISurfaceTextureContext::onFrameAvailable()
Jamie Gennis6714efc2010-12-20 12:09:37 -0800181{
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700182 bool needsDetach = false;
183 JNIEnv* env = getJNIEnv(&needsDetach);
Jamie Gennis84293fb2011-06-17 16:35:35 -0700184 if (env != NULL) {
185 env->CallStaticVoidMethod(mClazz, fields.postEvent, mWeakThiz);
186 } else {
Steve Block8564c8d2012-01-05 23:22:43 +0000187 ALOGW("onFrameAvailable event will not posted");
Jamie Gennis84293fb2011-06-17 16:35:35 -0700188 }
Jamie Gennis0a8fd9b2011-06-20 18:39:35 -0700189 if (needsDetach) {
190 detachJNI();
191 }
Jamie Gennis376590d2011-01-13 14:43:36 -0800192}
193
194// ----------------------------------------------------------------------------
195
Mathias Agopian52a9a102013-08-02 01:38:38 -0700196
197#define ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID "mSurfaceTexture"
198#define ANDROID_GRAPHICS_BUFFERQUEUE_JNI_ID "mBufferQueue"
199#define ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID \
200 "mFrameAvailableListener"
201
Jamie Gennis376590d2011-01-13 14:43:36 -0800202static void SurfaceTexture_classInit(JNIEnv* env, jclass clazz)
203{
204 fields.surfaceTexture = env->GetFieldID(clazz,
Ashok Bhat72aa3132014-01-13 20:41:06 +0000205 ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID, "J");
Jamie Gennis376590d2011-01-13 14:43:36 -0800206 if (fields.surfaceTexture == NULL) {
Steve Block3762c312012-01-06 19:20:56 +0000207 ALOGE("can't find android/graphics/SurfaceTexture.%s",
Jamie Gennis376590d2011-01-13 14:43:36 -0800208 ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID);
209 }
Mathias Agopian52a9a102013-08-02 01:38:38 -0700210 fields.bufferQueue = env->GetFieldID(clazz,
Ashok Bhat72aa3132014-01-13 20:41:06 +0000211 ANDROID_GRAPHICS_BUFFERQUEUE_JNI_ID, "J");
Mathias Agopian52a9a102013-08-02 01:38:38 -0700212 if (fields.bufferQueue == NULL) {
213 ALOGE("can't find android/graphics/SurfaceTexture.%s",
214 ANDROID_GRAPHICS_BUFFERQUEUE_JNI_ID);
215 }
Igor Murashkinc99db2b2012-10-29 13:38:10 -0700216 fields.frameAvailableListener = env->GetFieldID(clazz,
Ashok Bhat72aa3132014-01-13 20:41:06 +0000217 ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID, "J");
Igor Murashkinc99db2b2012-10-29 13:38:10 -0700218 if (fields.frameAvailableListener == NULL) {
219 ALOGE("can't find android/graphics/SurfaceTexture.%s",
220 ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID);
221 }
Jamie Gennis376590d2011-01-13 14:43:36 -0800222
223 fields.postEvent = env->GetStaticMethodID(clazz, "postEventFromNative",
224 "(Ljava/lang/Object;)V");
225 if (fields.postEvent == NULL) {
Steve Block3762c312012-01-06 19:20:56 +0000226 ALOGE("can't find android/graphics/SurfaceTexture.postEventFromNative");
Jamie Gennis376590d2011-01-13 14:43:36 -0800227 }
Jamie Gennis376590d2011-01-13 14:43:36 -0800228}
229
Mathias Agopiane591b492013-07-24 19:15:00 -0700230static void SurfaceTexture_init(JNIEnv* env, jobject thiz,
231 jint texName, jboolean singleBufferMode, jobject weakThiz)
Jamie Gennis376590d2011-01-13 14:43:36 -0800232{
Mathias Agopiane3263262013-07-16 22:54:56 -0700233 sp<BufferQueue> bq = new BufferQueue();
Mathias Agopiane591b492013-07-24 19:15:00 -0700234
235 if (singleBufferMode) {
236 bq->disableAsyncBuffer();
237 bq->setDefaultMaxBufferCount(1);
238 }
239
Mathias Agopiane3263262013-07-16 22:54:56 -0700240 sp<GLConsumer> surfaceTexture(new GLConsumer(bq, texName, GL_TEXTURE_EXTERNAL_OES, true, true));
Jamie Gennis376590d2011-01-13 14:43:36 -0800241 if (surfaceTexture == 0) {
242 jniThrowException(env, OutOfResourcesException,
243 "Unable to create native SurfaceTexture");
244 return;
245 }
246 SurfaceTexture_setSurfaceTexture(env, thiz, surfaceTexture);
Mathias Agopian52a9a102013-08-02 01:38:38 -0700247 SurfaceTexture_setBufferQueue(env, thiz, bq);
Jamie Gennis376590d2011-01-13 14:43:36 -0800248
249 jclass clazz = env->GetObjectClass(thiz);
250 if (clazz == NULL) {
251 jniThrowRuntimeException(env,
252 "Can't find android/graphics/SurfaceTexture");
253 return;
254 }
255
256 sp<JNISurfaceTextureContext> ctx(new JNISurfaceTextureContext(env, weakThiz,
257 clazz));
258 surfaceTexture->setFrameAvailableListener(ctx);
Igor Murashkinc99db2b2012-10-29 13:38:10 -0700259 SurfaceTexture_setFrameAvailableListener(env, thiz, ctx);
Jamie Gennis376590d2011-01-13 14:43:36 -0800260}
261
262static void SurfaceTexture_finalize(JNIEnv* env, jobject thiz)
263{
Andy McFaddend47f7d82012-12-18 09:48:38 -0800264 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
Jamie Gennis376590d2011-01-13 14:43:36 -0800265 surfaceTexture->setFrameAvailableListener(0);
Igor Murashkinc99db2b2012-10-29 13:38:10 -0700266 SurfaceTexture_setFrameAvailableListener(env, thiz, 0);
Jamie Gennis376590d2011-01-13 14:43:36 -0800267 SurfaceTexture_setSurfaceTexture(env, thiz, 0);
Mathias Agopian52a9a102013-08-02 01:38:38 -0700268 SurfaceTexture_setBufferQueue(env, thiz, 0);
Jamie Gennis376590d2011-01-13 14:43:36 -0800269}
270
tedbo05031612011-06-06 16:02:47 -0700271static void SurfaceTexture_setDefaultBufferSize(
Mathias Agopian52a9a102013-08-02 01:38:38 -0700272 JNIEnv* env, jobject thiz, jint width, jint height) {
Andy McFaddend47f7d82012-12-18 09:48:38 -0800273 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
tedbo05031612011-06-06 16:02:47 -0700274 surfaceTexture->setDefaultBufferSize(width, height);
275}
276
Jamie Gennis2b4bfa52012-04-13 14:48:22 -0700277static void SurfaceTexture_updateTexImage(JNIEnv* env, jobject thiz)
Jamie Gennis376590d2011-01-13 14:43:36 -0800278{
Andy McFaddend47f7d82012-12-18 09:48:38 -0800279 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
Jamie Gennis2b4bfa52012-04-13 14:48:22 -0700280 status_t err = surfaceTexture->updateTexImage();
281 if (err == INVALID_OPERATION) {
282 jniThrowException(env, IllegalStateException, "Unable to update texture contents (see "
283 "logcat for details)");
Jamie Gennis721bfaa62012-04-13 19:14:37 -0700284 } else if (err < 0) {
Jamie Gennis2b4bfa52012-04-13 14:48:22 -0700285 jniThrowRuntimeException(env, "Error during updateTexImage (see logcat for details)");
286 }
Jamie Gennis6714efc2010-12-20 12:09:37 -0800287}
288
Mathias Agopiane591b492013-07-24 19:15:00 -0700289static void SurfaceTexture_releaseTexImage(JNIEnv* env, jobject thiz)
290{
291 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
292 status_t err = surfaceTexture->releaseTexImage();
293 if (err == INVALID_OPERATION) {
294 jniThrowException(env, IllegalStateException, "Unable to release texture contents (see "
295 "logcat for details)");
296 } else if (err < 0) {
297 jniThrowRuntimeException(env, "Error during updateTexImage (see logcat for details)");
298 }
299}
300
Jamie Gennisc6d99302012-04-05 11:34:02 -0700301static jint SurfaceTexture_detachFromGLContext(JNIEnv* env, jobject thiz)
302{
Andy McFaddend47f7d82012-12-18 09:48:38 -0800303 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
Jamie Gennisc6d99302012-04-05 11:34:02 -0700304 return surfaceTexture->detachFromContext();
305}
306
307static jint SurfaceTexture_attachToGLContext(JNIEnv* env, jobject thiz, jint tex)
308{
Andy McFaddend47f7d82012-12-18 09:48:38 -0800309 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
Jamie Gennisc6d99302012-04-05 11:34:02 -0700310 return surfaceTexture->attachToContext((GLuint)tex);
311}
312
Jamie Gennis376590d2011-01-13 14:43:36 -0800313static void SurfaceTexture_getTransformMatrix(JNIEnv* env, jobject thiz,
Jamie Gennisb0ba48c2011-01-09 18:22:05 -0800314 jfloatArray jmtx)
315{
Andy McFaddend47f7d82012-12-18 09:48:38 -0800316 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
Jamie Gennisb0ba48c2011-01-09 18:22:05 -0800317 float* mtx = env->GetFloatArrayElements(jmtx, NULL);
318 surfaceTexture->getTransformMatrix(mtx);
319 env->ReleaseFloatArrayElements(jmtx, mtx, 0);
320}
321
Eino-Ville Talvalac5f94d82011-02-18 11:02:42 -0800322static jlong SurfaceTexture_getTimestamp(JNIEnv* env, jobject thiz)
323{
Andy McFaddend47f7d82012-12-18 09:48:38 -0800324 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
Eino-Ville Talvalac5f94d82011-02-18 11:02:42 -0800325 return surfaceTexture->getTimestamp();
326}
327
Mathias Agopianec46b4e2011-08-03 15:18:36 -0700328static void SurfaceTexture_release(JNIEnv* env, jobject thiz)
329{
Andy McFaddend47f7d82012-12-18 09:48:38 -0800330 sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
Mathias Agopianec46b4e2011-08-03 15:18:36 -0700331 surfaceTexture->abandon();
332}
333
Jamie Gennis6714efc2010-12-20 12:09:37 -0800334// ----------------------------------------------------------------------------
335
Jamie Gennis6714efc2010-12-20 12:09:37 -0800336static JNINativeMethod gSurfaceTextureMethods[] = {
Jamie Gennisc6d99302012-04-05 11:34:02 -0700337 {"nativeClassInit", "()V", (void*)SurfaceTexture_classInit },
Mathias Agopiane591b492013-07-24 19:15:00 -0700338 {"nativeInit", "(IZLjava/lang/Object;)V", (void*)SurfaceTexture_init },
Jamie Gennisc6d99302012-04-05 11:34:02 -0700339 {"nativeFinalize", "()V", (void*)SurfaceTexture_finalize },
tedbo05031612011-06-06 16:02:47 -0700340 {"nativeSetDefaultBufferSize", "(II)V", (void*)SurfaceTexture_setDefaultBufferSize },
Jamie Gennis2b4bfa52012-04-13 14:48:22 -0700341 {"nativeUpdateTexImage", "()V", (void*)SurfaceTexture_updateTexImage },
Mathias Agopiane591b492013-07-24 19:15:00 -0700342 {"nativeReleaseTexImage", "()V", (void*)SurfaceTexture_releaseTexImage },
Jamie Gennisc6d99302012-04-05 11:34:02 -0700343 {"nativeDetachFromGLContext", "()I", (void*)SurfaceTexture_detachFromGLContext },
344 {"nativeAttachToGLContext", "(I)I", (void*)SurfaceTexture_attachToGLContext },
345 {"nativeGetTransformMatrix", "([F)V", (void*)SurfaceTexture_getTransformMatrix },
346 {"nativeGetTimestamp", "()J", (void*)SurfaceTexture_getTimestamp },
347 {"nativeRelease", "()V", (void*)SurfaceTexture_release },
Jamie Gennis6714efc2010-12-20 12:09:37 -0800348};
349
Jamie Gennis6714efc2010-12-20 12:09:37 -0800350int register_android_graphics_SurfaceTexture(JNIEnv* env)
351{
352 int err = 0;
353 err = AndroidRuntime::registerNativeMethods(env, kSurfaceTextureClassPathName,
354 gSurfaceTextureMethods, NELEM(gSurfaceTextureMethods));
355 return err;
356}
357
358} // namespace android