Bug 692198 - Make Flash on Android draw to bitmap intead of SurfaceView directly
From 718909dd4d8c1b1ffb2e8ea72cc7d75c281e0773 Mon Sep 17 00:00:00 2001
This commit is contained in:
@@ -65,7 +65,6 @@
|
||||
#include "ANPBase.h"
|
||||
#include <android/log.h>
|
||||
#include "android_npapi.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/CondVar.h"
|
||||
#include "AndroidBridge.h"
|
||||
#endif
|
||||
@@ -73,6 +72,11 @@
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::plugins::parent;
|
||||
|
||||
#ifdef 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);
|
||||
|
||||
@@ -89,6 +93,7 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin)
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
mSurface(nsnull),
|
||||
mTargetSurface(nsnull),
|
||||
mDrawingModel(0),
|
||||
#endif
|
||||
mRunning(NOT_STARTED),
|
||||
@@ -122,6 +127,10 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin)
|
||||
mUsePluginLayersPref = useLayersPref;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
mTargetSurfaceLock = new Mutex("nsNPAPIPluginInstance::SurfaceLock");
|
||||
#endif
|
||||
|
||||
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
|
||||
}
|
||||
|
||||
@@ -133,6 +142,22 @@ nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
|
||||
PR_Free((void *)mMIMEType);
|
||||
mMIMEType = nsnull;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
if (mSurface) {
|
||||
sSurfaceMap.erase(mSurface);
|
||||
}
|
||||
|
||||
if (mTargetSurface) {
|
||||
delete mTargetSurface;
|
||||
mTargetSurface = nsnull;
|
||||
}
|
||||
|
||||
if (mTargetSurfaceLock) {
|
||||
delete mTargetSurfaceLock;
|
||||
mTargetSurfaceLock = nsnull;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -775,9 +800,61 @@ void* nsNPAPIPluginInstance::GetJavaSurface()
|
||||
|
||||
nsCOMPtr<SurfaceGetter> sg = new SurfaceGetter(mPlugin->PluginFuncs(), mNPP);
|
||||
mSurface = sg->GetSurface();
|
||||
sSurfaceMap[mSurface] = this;
|
||||
return mSurface;
|
||||
}
|
||||
|
||||
gfxImageSurface*
|
||||
nsNPAPIPluginInstance::LockTargetSurface()
|
||||
{
|
||||
mTargetSurfaceLock->Lock();
|
||||
return mTargetSurface;
|
||||
}
|
||||
|
||||
gfxImageSurface*
|
||||
nsNPAPIPluginInstance::LockTargetSurface(PRUint32 aWidth, PRUint32 aHeight, gfxImageFormat aFormat,
|
||||
NPRect* aRect)
|
||||
{
|
||||
mTargetSurfaceLock->Lock();
|
||||
if (!mTargetSurface ||
|
||||
mTargetSurface->Width() != aWidth ||
|
||||
mTargetSurface->Height() != aHeight ||
|
||||
mTargetSurface->Format() != aFormat) {
|
||||
|
||||
if (mTargetSurface) {
|
||||
delete mTargetSurface;
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsresult nsNPAPIPluginInstance::GetDrawingModel(PRInt32* aModel)
|
||||
|
||||
Reference in New Issue
Block a user