2012-05-29 19:52:43 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-01-31 18:40:58 +04:00
|
|
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
#include "AndroidBridge.h"
|
|
|
|
#include "ANPBase.h"
|
|
|
|
#include "GLContextProvider.h"
|
|
|
|
#include "nsNPAPIPluginInstance.h"
|
2012-07-20 23:20:51 +04:00
|
|
|
#include "nsPluginInstanceOwner.h"
|
|
|
|
#include "GLContextProvider.h"
|
2014-01-08 00:02:18 +04:00
|
|
|
#include "GLContextEGL.h"
|
2012-01-31 18:40:58 +04:00
|
|
|
|
|
|
|
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
|
|
|
#define ASSIGN(obj, name) (obj)->name = anp_opengl_##name
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
2012-07-20 23:20:51 +04:00
|
|
|
typedef nsNPAPIPluginInstance::TextureInfo TextureInfo;
|
|
|
|
|
|
|
|
static ANPEGLContext anp_opengl_acquireContext(NPP instance) {
|
|
|
|
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
|
|
|
|
|
|
|
GLContext* context = pinst->GLContext();
|
|
|
|
if (!context)
|
2013-10-24 00:34:30 +04:00
|
|
|
return nullptr;
|
2012-07-20 23:20:51 +04:00
|
|
|
|
|
|
|
context->MakeCurrent();
|
2014-01-08 00:02:18 +04:00
|
|
|
return GLContextEGL::Cast(context)->GetEGLContext();
|
2012-01-31 18:40:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static ANPTextureInfo anp_opengl_lockTexture(NPP instance) {
|
2012-07-20 23:20:51 +04:00
|
|
|
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
|
|
|
|
|
|
|
TextureInfo pluginInfo = pinst->LockContentTexture();
|
|
|
|
|
|
|
|
ANPTextureInfo info;
|
|
|
|
info.textureId = pluginInfo.mTexture;
|
|
|
|
info.width = pluginInfo.mWidth;
|
|
|
|
info.height = pluginInfo.mHeight;
|
|
|
|
|
|
|
|
// It looks like we should be passing whatever
|
|
|
|
// internal format Flash told us it used previously
|
|
|
|
// (e.g., the value of pluginInfo.mInternalFormat),
|
|
|
|
// but if we do that it doesn't upload to the texture
|
|
|
|
// for some reason.
|
|
|
|
info.internalFormat = 0;
|
|
|
|
|
2012-01-31 18:40:58 +04:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void anp_opengl_releaseTexture(NPP instance, const ANPTextureInfo* info) {
|
2012-07-20 23:20:51 +04:00
|
|
|
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
|
|
|
|
|
|
|
TextureInfo pluginInfo(info->textureId, info->width, info->height, info->internalFormat);
|
|
|
|
pinst->ReleaseContentTexture(pluginInfo);
|
|
|
|
pinst->RedrawPlugin();
|
2012-01-31 18:40:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void anp_opengl_invertPluginContent(NPP instance, bool isContentInverted) {
|
2012-07-20 23:20:51 +04:00
|
|
|
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
|
|
|
|
|
|
|
// Our definition of inverted is the opposite of the plugin's
|
|
|
|
pinst->SetInverted(!isContentInverted);
|
|
|
|
pinst->RedrawPlugin();
|
2012-01-31 18:40:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void InitOpenGLInterface(ANPOpenGLInterfaceV0* i) {
|
|
|
|
ASSIGN(i, acquireContext);
|
|
|
|
ASSIGN(i, lockTexture);
|
|
|
|
ASSIGN(i, releaseTexture);
|
|
|
|
ASSIGN(i, invertPluginContent);
|
|
|
|
}
|