diff options
author | Cory Fields <theuni-nospam-@xbmc.org> | 2013-08-08 20:40:58 -0400 |
---|---|---|
committer | Cory Fields <theuni-nospam-@xbmc.org> | 2013-08-08 20:40:58 -0400 |
commit | a35b40f9b7caeecb015a1d46f98fc3f01fd8b7be (patch) | |
tree | 6f02763ed1be324fb477dd28cc4b37d44b1f1edb | |
parent | 2d6913cf27d620b9b52990ef0889a61155479b0d (diff) |
jni: clean and fixup SurfaceTexture
-rw-r--r-- | xbmc/android/jni/SurfaceTexture.cpp | 60 | ||||
-rw-r--r-- | xbmc/android/jni/SurfaceTexture.h | 18 |
2 files changed, 53 insertions, 25 deletions
diff --git a/xbmc/android/jni/SurfaceTexture.cpp b/xbmc/android/jni/SurfaceTexture.cpp index f8a0c60a46..0baf4a8a4e 100644 --- a/xbmc/android/jni/SurfaceTexture.cpp +++ b/xbmc/android/jni/SurfaceTexture.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2013 Team XBMC - * http://xbmc.org + * http://www.xbmc.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,45 +18,67 @@ * */ +#include "JNIBase.h" #include "SurfaceTexture.h" + #include "jutils/jutils-details.hpp" using namespace jni; -CJNISurfaceTexture::CJNISurfaceTexture(int texid) : CJNIBase("android/graphics/SurfaceTexture") +CJNISurfaceTexture::CJNISurfaceTexture(int texName) : CJNIBase("android/graphics/SurfaceTexture") { - m_object = new_object(GetClassName(), - "<init>", "(I)V", - texid); + m_object = new_object(GetClassName(), "<init>", "(I)V", texName); m_object.setGlobal(); } -CJNISurfaceTexture::~CJNISurfaceTexture() +/* +void setOnFrameAvailableListener(const CJNISurfaceTextureOnFrameAvailableListener &listener) { - release(); +} +*/ + +void CJNISurfaceTexture::setDefaultBufferSize(int width, int height) +{ + call_method<void>(m_object, + "setDefaultBufferSize", "(II)V", width, height); } void CJNISurfaceTexture::updateTexImage() { - call_method<jhobject>(m_object, + call_method<void>(m_object, "updateTexImage", "()V"); } -void CJNISurfaceTexture::release() +void CJNISurfaceTexture::detachFromGLContext() +{ + call_method<void>(m_object, + "detachFromGLContext", "()V"); +} + +void CJNISurfaceTexture::attachToGLContext(int texName) { - call_method<jhobject>(m_object, - "release", "()V"); + call_method<void>(m_object, + "attachToGLContext", "(I)V", texName); } -void CJNISurfaceTexture::getTransformMatrix(float* transformMatrix) +void CJNISurfaceTexture::getTransformMatrix(float* mtx) { - JNIEnv* env = xbmc_jnienv(); - jfloatArray arr = (jfloatArray)env->NewFloatArray(16); - env->SetFloatArrayRegion(arr, 0, 16, transformMatrix); + jsize size = 16; // hard-coded 4x4 matrix. + JNIEnv *env = xbmc_jnienv(); + jfloatArray floatarray = env->NewFloatArray(size); + call_method<void>(m_object, + "getTransformMatrix", "([F)V", floatarray); + env->GetFloatArrayRegion(floatarray, 0, size, mtx); +} - call_method<jhobject>(m_object, - "getTransformMatrix", "([F)V", arr); +int64_t CJNISurfaceTexture::getTimestamp() +{ + return call_method<jlong>(m_object, + "getTimestamp", "()J"); +} - env->GetFloatArrayRegion(arr, 0, 16, transformMatrix); - env->DeleteLocalRef(arr); +void CJNISurfaceTexture::release() +{ + call_method<void>(m_object, + "attachToGLContext", "()V"); } diff --git a/xbmc/android/jni/SurfaceTexture.h b/xbmc/android/jni/SurfaceTexture.h index fa81ece8dc..d1965f99cd 100644 --- a/xbmc/android/jni/SurfaceTexture.h +++ b/xbmc/android/jni/SurfaceTexture.h @@ -1,7 +1,7 @@ #pragma once /* * Copyright (C) 2013 Team XBMC - * http://xbmc.org + * http://www.xbmc.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,10 +24,16 @@ class CJNISurfaceTexture : public CJNIBase { public: - CJNISurfaceTexture(int texid); - ~CJNISurfaceTexture(); + CJNISurfaceTexture(const jni::jhobject &object) : CJNIBase(object) {}; + CJNISurfaceTexture(int texName); + ~CJNISurfaceTexture() {}; - void updateTexImage(); - void release(); - void getTransformMatrix(float* transformMatrix); + //void setOnFrameAvailableListener(const CJNISurfaceTextureOnFrameAvailableListener &listener) + void setDefaultBufferSize(int width, int height); + void updateTexImage(); + void detachFromGLContext(); + void attachToGLContext(int texName); + void getTransformMatrix(float* mtx); // mtx MUST BE a preallocated 4x4 float array + int64_t getTimestamp(); + void release(); }; |