gecko-dev/gfx/gl/AndroidSurfaceTexture.cpp
James Willcox 5de9b3dc5f Bug 1322650 - Add GeckoSurfaceTexture, GeckoSurface and associated Android Service r=jchen
This allows us to allocate an Android SurfaceTexture in the compositor process as well
as an accompanying Surface. We can then transfer the Surface back to the content process
via binder, where it can be used for things like WebGL and video decoding.

Each SurfaceTexture/Surface pair has a unique handle. We use this handle in
layer transactions to locate the SurfaceTexture for a given Surface and composite it
appropriately.

MozReview-Commit-ID: 68VSbXdfsMH
2017-05-15 09:37:43 -05:00

47 lines
1.0 KiB
C++

#ifdef MOZ_WIDGET_ANDROID
#include "AndroidSurfaceTexture.h"
using namespace mozilla;
namespace mozilla {
namespace gl {
void
AndroidSurfaceTexture::GetTransformMatrix(java::sdk::SurfaceTexture::LocalRef aSurfaceTexture,
gfx::Matrix4x4& aMatrix)
{
JNIEnv* const env = jni::GetEnvForThread();
auto jarray = jni::FloatArray::LocalRef::Adopt(env, env->NewFloatArray(16));
aSurfaceTexture->GetTransformMatrix(jarray);
jfloat* array = env->GetFloatArrayElements(jarray.Get(), nullptr);
aMatrix._11 = array[0];
aMatrix._12 = array[1];
aMatrix._13 = array[2];
aMatrix._14 = array[3];
aMatrix._21 = array[4];
aMatrix._22 = array[5];
aMatrix._23 = array[6];
aMatrix._24 = array[7];
aMatrix._31 = array[8];
aMatrix._32 = array[9];
aMatrix._33 = array[10];
aMatrix._34 = array[11];
aMatrix._41 = array[12];
aMatrix._42 = array[13];
aMatrix._43 = array[14];
aMatrix._44 = array[15];
env->ReleaseFloatArrayElements(jarray.Get(), array, 0);
}
} // gl
} // mozilla
#endif // MOZ_WIDGET_ANDROID