diff -r 000000000000 -r 6474c204b198 dom/plugins/base/android/ANPOpenGL.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dom/plugins/base/android/ANPOpenGL.cpp Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,77 @@ +/* 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/. */ + +#include +#include +#include "AndroidBridge.h" +#include "ANPBase.h" +#include "GLContextProvider.h" +#include "nsNPAPIPluginInstance.h" +#include "nsPluginInstanceOwner.h" +#include "GLContextProvider.h" +#include "GLContextEGL.h" + +#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; + +typedef nsNPAPIPluginInstance::TextureInfo TextureInfo; + +static ANPEGLContext anp_opengl_acquireContext(NPP instance) { + nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); + + GLContext* context = pinst->GLContext(); + if (!context) + return nullptr; + + context->MakeCurrent(); + return GLContextEGL::Cast(context)->GetEGLContext(); +} + +static ANPTextureInfo anp_opengl_lockTexture(NPP instance) { + nsNPAPIPluginInstance* pinst = static_cast(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; + + return info; +} + +static void anp_opengl_releaseTexture(NPP instance, const ANPTextureInfo* info) { + nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); + + TextureInfo pluginInfo(info->textureId, info->width, info->height, info->internalFormat); + pinst->ReleaseContentTexture(pluginInfo); + pinst->RedrawPlugin(); +} + +static void anp_opengl_invertPluginContent(NPP instance, bool isContentInverted) { + nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); + + // Our definition of inverted is the opposite of the plugin's + pinst->SetInverted(!isContentInverted); + pinst->RedrawPlugin(); +} + +/////////////////////////////////////////////////////////////////////////////// + +void InitOpenGLInterface(ANPOpenGLInterfaceV0* i) { + ASSIGN(i, acquireContext); + ASSIGN(i, lockTexture); + ASSIGN(i, releaseTexture); + ASSIGN(i, invertPluginContent); +}