summaryrefslogtreecommitdiff
path: root/dom/plugins/base/nsNPAPIPluginInstance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/plugins/base/nsNPAPIPluginInstance.cpp')
-rw-r--r--dom/plugins/base/nsNPAPIPluginInstance.cpp357
1 files changed, 2 insertions, 355 deletions
diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp
index 4b211ed7ef..ce24b62967 100644
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -5,11 +5,6 @@
#include "mozilla/DebugOnly.h"
-#ifdef MOZ_WIDGET_ANDROID
-// For ScreenOrientation.h and Hal.h
-#include "base/basictypes.h"
-#endif
-
#include "mozilla/Logging.h"
#include "prmem.h"
#include "nscore.h"
@@ -45,64 +40,6 @@
using namespace mozilla;
using namespace mozilla::dom;
-#ifdef MOZ_WIDGET_ANDROID
-#include "ANPBase.h"
-#include <android/log.h>
-#include "android_npapi.h"
-#include "mozilla/Mutex.h"
-#include "mozilla/CondVar.h"
-#include "mozilla/dom/ScreenOrientation.h"
-#include "mozilla/Hal.h"
-#include "GLContextProvider.h"
-#include "GLContext.h"
-#include "TexturePoolOGL.h"
-#include "SurfaceTypes.h"
-#include "EGLUtils.h"
-
-using namespace mozilla;
-using namespace mozilla::gl;
-
-typedef nsNPAPIPluginInstance::VideoInfo VideoInfo;
-
-class PluginEventRunnable : public Runnable
-{
-public:
- PluginEventRunnable(nsNPAPIPluginInstance* instance, ANPEvent* event)
- : mInstance(instance), mEvent(*event), mCanceled(false) {}
-
- virtual nsresult Run() {
- if (mCanceled)
- return NS_OK;
-
- mInstance->HandleEvent(&mEvent, nullptr);
- mInstance->PopPostedEvent(this);
- return NS_OK;
- }
-
- void Cancel() { mCanceled = true; }
-private:
- nsNPAPIPluginInstance* mInstance;
- ANPEvent mEvent;
- bool mCanceled;
-};
-
-static RefPtr<GLContext> sPluginContext = nullptr;
-
-static bool EnsureGLContext()
-{
- if (!sPluginContext) {
- const auto flags = CreateContextFlags::REQUIRE_COMPAT_PROFILE;
- nsCString discardedFailureId;
- sPluginContext = GLContextProvider::CreateHeadless(flags, &discardedFailureId);
- }
-
- return sPluginContext != nullptr;
-}
-
-static std::map<NPP, nsNPAPIPluginInstance*> sPluginNPPMap;
-
-#endif
-
using namespace mozilla;
using namespace mozilla::plugins::parent;
using namespace mozilla::layers;
@@ -113,13 +50,6 @@ NS_IMPL_ISUPPORTS(nsNPAPIPluginInstance, nsIAudioChannelAgentCallback)
nsNPAPIPluginInstance::nsNPAPIPluginInstance()
: mDrawingModel(kDefaultDrawingModel)
-#ifdef MOZ_WIDGET_ANDROID
- , mANPDrawingModel(0)
- , mFullScreenOrientation(dom::eScreenOrientation_LandscapePrimary)
- , mWakeLocked(false)
- , mFullScreen(false)
- , mOriginPos(gl::OriginPos::TopLeft)
-#endif
, mRunning(NOT_STARTED)
, mWindowless(false)
, mTransparent(false)
@@ -132,9 +62,6 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
#ifdef XP_MACOSX
, mCurrentPluginEvent(nullptr)
#endif
-#ifdef MOZ_WIDGET_ANDROID
- , mOnScreen(true)
-#endif
, mHaveJavaC2PJSObjectQuirk(false)
, mCachedParamLength(0)
, mCachedParamNames(nullptr)
@@ -145,20 +72,12 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
mNPP.ndata = this;
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
-
-#ifdef MOZ_WIDGET_ANDROID
- sPluginNPPMap[&mNPP] = this;
-#endif
}
nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
{
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance dtor: this=%p\n",this));
-#ifdef MOZ_WIDGET_ANDROID
- sPluginNPPMap.erase(&mNPP);
-#endif
-
if (mMIMEType) {
PR_Free((void *)mMIMEType);
mMIMEType = nullptr;
@@ -195,21 +114,6 @@ nsNPAPIPluginInstance::Destroy()
Stop();
mPlugin = nullptr;
mAudioChannelAgent = nullptr;
-
-#if MOZ_WIDGET_ANDROID
- if (mContentSurface)
- mContentSurface->SetFrameAvailableCallback(nullptr);
-
- mContentSurface = nullptr;
-
- std::map<void*, VideoInfo*>::iterator it;
- for (it = mVideos.begin(); it != mVideos.end(); it++) {
- it->second->mSurfaceTexture->SetFrameAvailableCallback(nullptr);
- delete it->second;
- }
- mVideos.clear();
- SetWakeLock(false);
-#endif
}
TimeStamp
@@ -297,14 +201,6 @@ nsresult nsNPAPIPluginInstance::Stop()
}
mRunning = DESTROYED;
-#if MOZ_WIDGET_ANDROID
- for (uint32_t i = 0; i < mPostedEvents.Length(); i++) {
- mPostedEvents[i]->Cancel();
- }
-
- mPostedEvents.Clear();
-#endif
-
nsJSNPRuntime::OnPluginDestroy(&mNPP);
if (error != NPERR_NO_ERROR)
@@ -404,13 +300,8 @@ nsNPAPIPluginInstance::Start()
mCachedParamValues[i] = ToNewUTF8String(attributes[i].mValue);
}
- // Android expects and empty string instead of null.
mCachedParamNames[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
- #ifdef MOZ_WIDGET_ANDROID
- mCachedParamValues[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING(""));
- #else
- mCachedParamValues[attributes.Length()] = nullptr;
- #endif
+ mCachedParamValues[attributes.Length()] = nullptr;
for (uint32_t i = 0, pos = attributes.Length() + 1; i < params.Length(); i ++) {
mCachedParamNames[pos] = ToNewUTF8String(params[i].mName);
@@ -738,249 +629,6 @@ void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel)
}
#endif
-#if defined(MOZ_WIDGET_ANDROID)
-
-static void SendLifecycleEvent(nsNPAPIPluginInstance* aInstance, uint32_t aAction)
-{
- ANPEvent event;
- event.inSize = sizeof(ANPEvent);
- event.eventType = kLifecycle_ANPEventType;
- event.data.lifecycle.action = aAction;
- aInstance->HandleEvent(&event, nullptr);
-}
-
-void nsNPAPIPluginInstance::NotifyForeground(bool aForeground)
-{
- PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetForeground this=%p\n foreground=%d",this, aForeground));
- if (RUNNING != mRunning)
- return;
-
- SendLifecycleEvent(this, aForeground ? kResume_ANPLifecycleAction : kPause_ANPLifecycleAction);
-}
-
-void nsNPAPIPluginInstance::NotifyOnScreen(bool aOnScreen)
-{
- PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetOnScreen this=%p\n onScreen=%d",this, aOnScreen));
- if (RUNNING != mRunning || mOnScreen == aOnScreen)
- return;
-
- mOnScreen = aOnScreen;
- SendLifecycleEvent(this, aOnScreen ? kOnScreen_ANPLifecycleAction : kOffScreen_ANPLifecycleAction);
-}
-
-void nsNPAPIPluginInstance::MemoryPressure()
-{
- PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::MemoryPressure this=%p\n",this));
- if (RUNNING != mRunning)
- return;
-
- SendLifecycleEvent(this, kFreeMemory_ANPLifecycleAction);
-}
-
-void nsNPAPIPluginInstance::NotifyFullScreen(bool aFullScreen)
-{
- PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::NotifyFullScreen this=%p\n",this));
-
- if (RUNNING != mRunning || mFullScreen == aFullScreen)
- return;
-
- mFullScreen = aFullScreen;
- SendLifecycleEvent(this, mFullScreen ? kEnterFullScreen_ANPLifecycleAction : kExitFullScreen_ANPLifecycleAction);
-
- if (mFullScreen && mFullScreenOrientation != dom::eScreenOrientation_None) {
- java::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
- }
-}
-
-void nsNPAPIPluginInstance::NotifySize(nsIntSize size)
-{
- if (kOpenGL_ANPDrawingModel != GetANPDrawingModel() ||
- size == mCurrentSize)
- return;
-
- mCurrentSize = size;
-
- ANPEvent event;
- event.inSize = sizeof(ANPEvent);
- event.eventType = kDraw_ANPEventType;
- event.data.draw.model = kOpenGL_ANPDrawingModel;
- event.data.draw.data.surfaceSize.width = size.width;
- event.data.draw.data.surfaceSize.height = size.height;
-
- HandleEvent(&event, nullptr);
-}
-
-void nsNPAPIPluginInstance::SetANPDrawingModel(uint32_t aModel)
-{
- mANPDrawingModel = aModel;
-}
-
-void* nsNPAPIPluginInstance::GetJavaSurface()
-{
- void* surface = nullptr;
- nsresult rv = GetValueFromPlugin(kJavaSurface_ANPGetValue, &surface);
- if (NS_FAILED(rv))
- return nullptr;
-
- return surface;
-}
-
-void nsNPAPIPluginInstance::PostEvent(void* event)
-{
- PluginEventRunnable *r = new PluginEventRunnable(this, (ANPEvent*)event);
- mPostedEvents.AppendElement(RefPtr<PluginEventRunnable>(r));
-
- NS_DispatchToMainThread(r);
-}
-
-void nsNPAPIPluginInstance::SetFullScreenOrientation(uint32_t orientation)
-{
- if (mFullScreenOrientation == orientation)
- return;
-
- uint32_t oldOrientation = mFullScreenOrientation;
- mFullScreenOrientation = orientation;
-
- if (mFullScreen) {
- // We're already fullscreen so immediately apply the orientation change
-
- if (mFullScreenOrientation != dom::eScreenOrientation_None) {
- java::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
- } else if (oldOrientation != dom::eScreenOrientation_None) {
- // We applied an orientation when we entered fullscreen, but
- // we don't want it anymore
- java::GeckoAppShell::UnlockScreenOrientation();
- }
- }
-}
-
-void nsNPAPIPluginInstance::PopPostedEvent(PluginEventRunnable* r)
-{
- mPostedEvents.RemoveElement(r);
-}
-
-void nsNPAPIPluginInstance::SetWakeLock(bool aLocked)
-{
- if (aLocked == mWakeLocked)
- return;
-
- mWakeLocked = aLocked;
- hal::ModifyWakeLock(NS_LITERAL_STRING("screen"),
- mWakeLocked ? hal::WAKE_LOCK_ADD_ONE : hal::WAKE_LOCK_REMOVE_ONE,
- hal::WAKE_LOCK_NO_CHANGE);
-}
-
-GLContext* nsNPAPIPluginInstance::GLContext()
-{
- if (!EnsureGLContext())
- return nullptr;
-
- return sPluginContext;
-}
-
-already_AddRefed<AndroidSurfaceTexture> nsNPAPIPluginInstance::CreateSurfaceTexture()
-{
- if (!EnsureGLContext())
- return nullptr;
-
- GLuint texture = TexturePoolOGL::AcquireTexture();
- if (!texture)
- return nullptr;
-
- RefPtr<AndroidSurfaceTexture> surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(),
- texture);
- if (!surface) {
- return nullptr;
- }
-
- nsCOMPtr<nsIRunnable> frameCallback = NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable);
- surface->SetFrameAvailableCallback(frameCallback);
- return surface.forget();
-}
-
-void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
-{
- if (mRunning == RUNNING && mOwner)
- mOwner->Recomposite();
-}
-
-void* nsNPAPIPluginInstance::AcquireContentWindow()
-{
- if (!mContentSurface) {
- mContentSurface = CreateSurfaceTexture();
-
- if (!mContentSurface)
- return nullptr;
- }
-
- return mContentSurface->NativeWindow();
-}
-
-AndroidSurfaceTexture*
-nsNPAPIPluginInstance::AsSurfaceTexture()
-{
- if (!mContentSurface)
- return nullptr;
-
- return mContentSurface;
-}
-
-void* nsNPAPIPluginInstance::AcquireVideoWindow()
-{
- RefPtr<AndroidSurfaceTexture> surface = CreateSurfaceTexture();
- if (!surface) {
- return nullptr;
- }
-
- VideoInfo* info = new VideoInfo(surface);
-
- void* window = info->mSurfaceTexture->NativeWindow();
- mVideos.insert(std::pair<void*, VideoInfo*>(window, info));
-
- return window;
-}
-
-void nsNPAPIPluginInstance::ReleaseVideoWindow(void* window)
-{
- std::map<void*, VideoInfo*>::iterator it = mVideos.find(window);
- if (it == mVideos.end())
- return;
-
- delete it->second;
- mVideos.erase(window);
-}
-
-void nsNPAPIPluginInstance::SetVideoDimensions(void* window, gfxRect aDimensions)
-{
- std::map<void*, VideoInfo*>::iterator it;
-
- it = mVideos.find(window);
- if (it == mVideos.end())
- return;
-
- it->second->mDimensions = aDimensions;
-}
-
-void nsNPAPIPluginInstance::GetVideos(nsTArray<VideoInfo*>& aVideos)
-{
- std::map<void*, VideoInfo*>::iterator it;
- for (it = mVideos.begin(); it != mVideos.end(); it++)
- aVideos.AppendElement(it->second);
-}
-
-nsNPAPIPluginInstance* nsNPAPIPluginInstance::GetFromNPP(NPP npp)
-{
- std::map<NPP, nsNPAPIPluginInstance*>::iterator it;
-
- it = sPluginNPPMap.find(npp);
- if (it == sPluginNPPMap.end())
- return nullptr;
-
- return it->second;
-}
-
-#endif
-
nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel)
{
*aModel = (int32_t)mDrawingModel;
@@ -1083,9 +731,8 @@ nsNPAPIPluginInstance::ShouldCache()
nsresult
nsNPAPIPluginInstance::IsWindowless(bool* isWindowless)
{
-#if defined(MOZ_WIDGET_ANDROID) || defined(XP_MACOSX)
+#ifdef XP_MACOSX
// All OS X plugins are windowless.
- // On android, pre-honeycomb, all plugins are treated as windowless.
*isWindowless = true;
#else
*isWindowless = mWindowless;