Bug 1322650 - Allow access to TexturePoolOGL from Java r=jchen
--- a/gfx/layers/opengl/TexturePoolOGL.cpp
+++ b/gfx/layers/opengl/TexturePoolOGL.cpp
@@ -5,26 +5,43 @@
#include "TexturePoolOGL.h"
#include <stdlib.h> // for malloc
#include "GLContext.h" // for GLContext
#include "mozilla/Monitor.h" // for Monitor, MonitorAutoLock
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsDebug.h" // for NS_ASSERTION, NS_ERROR, etc
#include "nsDeque.h" // for nsDeque
+#ifdef MOZ_WIDGET_ANDROID
+#include "GeneratedJNINatives.h"
+#endif
+
#define TEXTURE_POOL_SIZE 10
namespace mozilla {
namespace gl {
static GLContext* sActiveContext = nullptr;
static Monitor* sMonitor = nullptr;
static nsDeque* sTextures = nullptr;
+#ifdef MOZ_WIDGET_ANDROID
+
+class GeckoSurfaceTextureSupport final
+ : public java::GeckoSurfaceTexture::Natives<GeckoSurfaceTextureSupport>
+{
+public:
+ static int32_t NativeAcquireTexture() {
+ return TexturePoolOGL::AcquireTexture();
+ }
+};
+
+#endif // MOZ_WIDGET_ANDROID
+
GLuint TexturePoolOGL::AcquireTexture()
{
NS_ASSERTION(sMonitor, "not initialized");
MonitorAutoLock lock(*sMonitor);
if (!sActiveContext) {
// Wait for a context
@@ -106,16 +123,22 @@ GLContext* TexturePoolOGL::GetGLContext(
{
return sActiveContext;
}
void TexturePoolOGL::Init()
{
sMonitor = new Monitor("TexturePoolOGL.sMonitor");
sTextures = new nsDeque();
+
+#ifdef MOZ_WIDGET_ANDROID
+ if (jni::IsAvailable()) {
+ GeckoSurfaceTextureSupport::Init();
+ }
+#endif
}
void TexturePoolOGL::Shutdown()
{
delete sMonitor;
delete sTextures;
}