Rolled up Android plugin fixes including bugs 692988, 694366, 702330, 702334, 702338, 702341, 702614, 702627, 702964
Bug 692988 - anp_system_getApplicationDataDirectory() is just plain wrong Bug 694366 - Allow Flash to use transparent wmode Bug 702330 - Revert to drawing Flash plugin with a SurfaceView Bug 702334 - Fix deadlocks caused by Flash Bug 702338 - Enable plugins Bug 702341 - Flash plugins don't respond to panning/zooming changes Bug 702614 - Flash should use Skia to implement ANPCanvas and similar interfaces Bug 702627 - Flash: queue invalidation after async surface request Bug 702964 - Support subregion lock on plugin surfaces
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
#include "ANPBase.h"
|
||||
#include <android/log.h>
|
||||
#include "android_npapi.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/CondVar.h"
|
||||
#include "AndroidBridge.h"
|
||||
#endif
|
||||
@@ -72,11 +73,6 @@
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::plugins::parent;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include <map>
|
||||
static std::map<void*, nsNPAPIPluginInstance*> sSurfaceMap;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
|
||||
|
||||
@@ -93,7 +89,6 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin)
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mSurface(nsnull),
|
||||
mTargetSurface(nsnull),
|
||||
mDrawingModel(0),
|
||||
#endif
|
||||
mRunning(NOT_STARTED),
|
||||
@@ -128,10 +123,6 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin)
|
||||
mUsePluginLayersPref = useLayersPref;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mTargetSurfaceLock = new Mutex("nsNPAPIPluginInstance::SurfaceLock");
|
||||
#endif
|
||||
|
||||
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
|
||||
}
|
||||
|
||||
@@ -143,22 +134,6 @@ nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
|
||||
PR_Free((void *)mMIMEType);
|
||||
mMIMEType = nsnull;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (mSurface) {
|
||||
sSurfaceMap.erase(mSurface);
|
||||
}
|
||||
|
||||
if (mTargetSurface) {
|
||||
delete mTargetSurface;
|
||||
mTargetSurface = nsnull;
|
||||
}
|
||||
|
||||
if (mTargetSurfaceLock) {
|
||||
delete mTargetSurfaceLock;
|
||||
mTargetSurfaceLock = nsnull;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -760,40 +735,25 @@ void nsNPAPIPluginInstance::SetDrawingModel(PRUint32 aModel)
|
||||
{
|
||||
mDrawingModel = aModel;
|
||||
}
|
||||
|
||||
class SurfaceGetter : public nsRunnable {
|
||||
public:
|
||||
SurfaceGetter(NPPluginFuncs* aPluginFunctions, NPP_t aNPP) :
|
||||
mHaveSurface(false), mPluginFunctions(aPluginFunctions), mNPP(aNPP) {
|
||||
mLock = new Mutex("SurfaceGetter::Lock");
|
||||
mCondVar = new CondVar(*mLock, "SurfaceGetter::CondVar");
|
||||
|
||||
SurfaceGetter(nsNPAPIPluginInstance* aInstance, NPPluginFuncs* aPluginFunctions, NPP_t aNPP) :
|
||||
mInstance(aInstance), mPluginFunctions(aPluginFunctions), mNPP(aNPP) {
|
||||
}
|
||||
~SurfaceGetter() {
|
||||
delete mLock;
|
||||
delete mCondVar;
|
||||
}
|
||||
nsresult Run() {
|
||||
MutexAutoLock lock(*mLock);
|
||||
(*mPluginFunctions->getvalue)(&mNPP, kJavaSurface_ANPGetValue, &mSurface);
|
||||
mHaveSurface = true;
|
||||
mCondVar->Notify();
|
||||
void* surface;
|
||||
(*mPluginFunctions->getvalue)(&mNPP, kJavaSurface_ANPGetValue, &surface);
|
||||
mInstance->SetJavaSurface(surface);
|
||||
return NS_OK;
|
||||
}
|
||||
void* GetSurface() {
|
||||
MutexAutoLock lock(*mLock);
|
||||
mHaveSurface = false;
|
||||
AndroidBridge::Bridge()->PostToJavaThread(this);
|
||||
while (!mHaveSurface)
|
||||
mCondVar->Wait();
|
||||
return mSurface;
|
||||
void RequestSurface() {
|
||||
mozilla::AndroidBridge::Bridge()->PostToJavaThread(this);
|
||||
}
|
||||
private:
|
||||
nsNPAPIPluginInstance* mInstance;
|
||||
NPP_t mNPP;
|
||||
void* mSurface;
|
||||
Mutex* mLock;
|
||||
CondVar* mCondVar;
|
||||
bool mHaveSurface;
|
||||
NPPluginFuncs* mPluginFunctions;
|
||||
};
|
||||
|
||||
@@ -803,64 +763,22 @@ void* nsNPAPIPluginInstance::GetJavaSurface()
|
||||
if (mDrawingModel != kSurface_ANPDrawingModel)
|
||||
return nsnull;
|
||||
|
||||
if (mSurface)
|
||||
return mSurface;
|
||||
|
||||
nsCOMPtr<SurfaceGetter> sg = new SurfaceGetter(mPlugin->PluginFuncs(), mNPP);
|
||||
mSurface = sg->GetSurface();
|
||||
sSurfaceMap[mSurface] = this;
|
||||
return mSurface;
|
||||
}
|
||||
|
||||
gfxImageSurface*
|
||||
nsNPAPIPluginInstance::LockTargetSurface()
|
||||
void nsNPAPIPluginInstance::SetJavaSurface(void* aSurface)
|
||||
{
|
||||
mTargetSurfaceLock->Lock();
|
||||
return mTargetSurface;
|
||||
mSurface = aSurface;
|
||||
}
|
||||
|
||||
gfxImageSurface*
|
||||
nsNPAPIPluginInstance::LockTargetSurface(PRUint32 aWidth, PRUint32 aHeight, gfxImageFormat aFormat,
|
||||
NPRect* aRect)
|
||||
void nsNPAPIPluginInstance::RequestJavaSurface()
|
||||
{
|
||||
mTargetSurfaceLock->Lock();
|
||||
if (!mTargetSurface ||
|
||||
mTargetSurface->Width() != aWidth ||
|
||||
mTargetSurface->Height() != aHeight ||
|
||||
mTargetSurface->Format() != aFormat) {
|
||||
if (mSurfaceGetter.get())
|
||||
return;
|
||||
|
||||
if (mTargetSurface) {
|
||||
delete mTargetSurface;
|
||||
}
|
||||
mSurfaceGetter = new SurfaceGetter(this, mPlugin->PluginFuncs(), mNPP);
|
||||
|
||||
mTargetSurface = new gfxImageSurface(gfxIntSize(aWidth, aHeight), aFormat);
|
||||
}
|
||||
|
||||
mTargetLockRect = *aRect;
|
||||
|
||||
return mTargetSurface;
|
||||
}
|
||||
|
||||
void
|
||||
nsNPAPIPluginInstance::InvalidateTargetRect()
|
||||
{
|
||||
InvalidateRect(&mTargetLockRect);
|
||||
}
|
||||
|
||||
void
|
||||
nsNPAPIPluginInstance::UnlockTargetSurface(bool aInvalidate)
|
||||
{
|
||||
mTargetSurfaceLock->Unlock();
|
||||
|
||||
if (aInvalidate) {
|
||||
NS_DispatchToMainThread(NS_NewRunnableMethod(this, &nsNPAPIPluginInstance::InvalidateTargetRect));
|
||||
}
|
||||
}
|
||||
|
||||
nsNPAPIPluginInstance*
|
||||
nsNPAPIPluginInstance::FindByJavaSurface(void* aJavaSurface)
|
||||
{
|
||||
return sSurfaceMap[aJavaSurface];
|
||||
((SurfaceGetter*)mSurfaceGetter.get())->RequestSurface();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user