Bug 651192 - Part 7: Implement the NPP_DidComposite API. r=roc

This commit is contained in:
Bas Schouten
2012-02-16 04:30:25 +01:00
parent 48591ea721
commit 68a787a584
6 changed files with 52 additions and 1 deletions

View File

@@ -173,6 +173,8 @@ child:
rpc HandleKeyEvent(nsKeyEvent event)
returns (bool handled);
async NPP_DidComposite();
rpc NPP_Destroy()
returns (NPError rv);

View File

@@ -2095,6 +2095,15 @@ PluginInstanceChild::AnswerUpdateWindow()
#endif
}
bool
PluginInstanceChild::RecvNPP_DidComposite()
{
if (mPluginIface->didComposite) {
mPluginIface->didComposite(GetNPP());
}
return true;
}
PPluginScriptableObjectChild*
PluginInstanceChild::AllocPPluginScriptableObject()
{

View File

@@ -218,6 +218,9 @@ protected:
virtual bool
AnswerUpdateWindow();
virtual bool
RecvNPP_DidComposite();
public:
PluginInstanceChild(const NPPluginFuncs* aPluginIface);

View File

@@ -128,6 +128,7 @@ PluginInstanceParent::~PluginInstanceParent()
if (container) {
container->SetRemoteImageData(nsnull, nsnull);
container->SetCompositionNotifySink(nsnull);
DeallocShmem(mRemoteImageDataShmem);
}
}
@@ -365,6 +366,17 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginUsesDOMForCursor(
return true;
}
class NotificationSink : public CompositionNotifySink
{
public:
NotificationSink(PluginInstanceParent *aInstance) : mInstance(aInstance)
{ }
virtual void DidComposite() { mInstance->DidComposite(); }
private:
PluginInstanceParent *mInstance;
};
bool
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel(
const int& drawingModel, OptionalShmem *shmem, CrossProcessMutexHandle *mutex, NPError* result)
@@ -404,6 +416,10 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel(
*mutex = mRemoteImageDataMutex->ShareToProcess(OtherProcess());
container->SetRemoteImageData(mRemoteImageDataShmem.get<RemoteImageData>(), mRemoteImageDataMutex);
mNotifySink = new NotificationSink(this);
container->SetCompositionNotifySink(mNotifySink);
} else if (drawingModel == NPDrawingModelSyncWin ||
#ifdef XP_MACOSX
#ifndef NP_NO_QUICKDRAW
@@ -427,6 +443,7 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel(
if (mRemoteImageDataShmem.IsWritable()) {
container->SetRemoteImageData(nsnull, nsnull);
container->SetCompositionNotifySink(nsnull);
DeallocShmem(mRemoteImageDataShmem);
mRemoteImageDataMutex = NULL;
}

View File

@@ -305,6 +305,8 @@ public:
nsresult HandleGUIEvent(const nsGUIEvent& anEvent, bool* handled);
#endif
void DidComposite() { SendNPP_DidComposite(); }
private:
// Create an appropriate platform surface for a background of size
// |aSize|. Return true if successful.
@@ -337,6 +339,7 @@ private:
Shmem mRemoteImageDataShmem;
nsAutoPtr<CrossProcessMutex> mRemoteImageDataMutex;
int16_t mDrawingModel;
nsAutoPtr<mozilla::layers::CompositionNotifySink> mNotifySink;
nsDataHashtable<nsVoidPtrHashKey, PluginScriptableObjectParent*> mScriptableObjects;

View File

@@ -205,6 +205,12 @@ FormatInList(const Image::Format* aFormats, PRUint32 aNumFormats,
return false;
}
class CompositionNotifySink
{
public:
virtual void DidComposite() = 0;
};
/**
* A class that manages Image creation for a LayerManager. The only reason
* we need a separate class here is that LayerMananers aren't threadsafe
@@ -295,7 +301,8 @@ public:
mImageFactory(new ImageFactory()),
mRecycleBin(new BufferRecycleBin()),
mRemoteData(nsnull),
mRemoteDataMutex(nsnull)
mRemoteDataMutex(nsnull),
mCompositionNotifySink(nsnull)
{}
~ImageContainer();
@@ -448,6 +455,14 @@ public:
mPaintCount++;
mPreviousImagePainted = true;
}
if (mCompositionNotifySink) {
mCompositionNotifySink->DidComposite();
}
}
void SetCompositionNotifySink(CompositionNotifySink *aSink) {
mCompositionNotifySink = aSink;
}
/**
@@ -519,6 +534,8 @@ protected:
// When this mutex is held, we will always be inside the mReentrantMonitor
// however the same is not true vice versa.
CrossProcessMutex *mRemoteDataMutex;
CompositionNotifySink *mCompositionNotifySink;
};
class AutoLockImage