Bug 556487 - Plugin Child/Parent async API. r=roc,jones.chris.g a=blocking2.0

This commit is contained in:
Oleg Romashin 2010-09-14 12:01:05 -07:00
parent dcd9fb6f7a
commit 728d67a018
6 changed files with 130 additions and 0 deletions

View File

@ -52,10 +52,30 @@ using NPRect;
using NPNURLVariable;
using NPCoordinateSpace;
using mozilla::plugins::NativeWindowHandle;
using mozilla::gfxSurfaceType;
using gfxIntSize;
using mozilla::null_t;
namespace mozilla {
namespace plugins {
struct SurfaceDescriptorX11 {
int XID;
int xrenderPictID;
gfxIntSize size;
};
union SurfaceDescriptor {
Shmem;
SurfaceDescriptorX11;
// Descriptor can be null here in case
// 1) of first Show call (prevSurface is null)
// 2) when child is going to destroy
// and it just want to grab prevSurface
// back without giving new surface
null_t;
};
rpc protocol PPluginInstance
{
manager PPluginModule;
@ -92,6 +112,20 @@ child:
// this is only used on windows to forward WM_WINDOWPOSCHANGE
async WindowPosChanged(NPRemoteEvent event);
// ********************** Async plugins rendering
// see https://wiki.mozilla.org/Gecko:AsyncPluginPainting
// **********************
// Plugin parent notify child that plugin frame
// has been painted to the screen
async PaintFinished();
// Async version of SetWindow call
// @param surfaceType - gfxASurface::gfxSurfaceType
// plugin child must create offscreen buffer
// with type equals to surfaceType
async AsyncSetWindow(gfxSurfaceType surfaceType, NPRemoteWindow window);
rpc NPP_Destroy()
returns (NPError rv);
@ -134,6 +168,16 @@ parent:
async NPN_InvalidateRect(NPRect rect);
// Give |newSurface|, containing this instance's updated pixels, to
// the browser for compositing. Get back |prevSurface|, containing
// old pixels, to be recycled
// @param rect - actually updated rectangle, comparing to prevSurface content
// could be used for partial render of layer to topLevel context
// @param newSurface - remotable surface
// @param prevSurface - return surface for recycling
sync Show(NPRect updatedRect, SurfaceDescriptor newSurface)
returns (SurfaceDescriptor prevSurface);
rpc NPN_PushPopupsEnabledState(bool aState);
rpc NPN_PopPopupsEnabledState();

View File

@ -1938,6 +1938,19 @@ PluginInstanceChild::NPN_NewStream(NPMIMEType aMIMEType, const char* aWindow,
return NPERR_NO_ERROR;
}
bool
PluginInstanceChild::RecvPaintFinished(void)
{
return false;
}
bool
PluginInstanceChild::RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
const NPRemoteWindow& aWindow)
{
return true;
}
void
PluginInstanceChild::InvalidateRect(NPRect* aInvalidRect)
{

View File

@ -97,6 +97,12 @@ protected:
virtual bool
AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event, const uint32_t& surface, int16_t* handled);
// Async rendering
virtual bool
RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
const NPRemoteWindow& aWindow);
virtual bool RecvPaintFinished(void);
NS_OVERRIDE
virtual bool
AnswerPaint(const NPRemoteEvent& event, int16_t* handled)

View File

@ -460,6 +460,15 @@ PluginInstanceParent::RecvNPN_InvalidateRect(const NPRect& rect)
return true;
}
bool
PluginInstanceParent::RecvShow(const NPRect& updatedRect,
const SurfaceDescriptor& newSurface,
SurfaceDescriptor* prevSurface)
{
*prevSurface = null_t();
return false;
}
nsresult
PluginInstanceParent::AsyncSetWindow(NPWindow* aWindow)
{

View File

@ -165,6 +165,12 @@ public:
virtual bool
RecvNPN_InvalidateRect(const NPRect& rect);
// Async rendering
virtual bool
RecvShow(const NPRect& updatedRect,
const SurfaceDescriptor& newSurface,
SurfaceDescriptor* prevSurface);
virtual bool
AnswerNPN_PushPopupsEnabledState(const bool& aState);

View File

@ -50,6 +50,7 @@
#include "gfxPattern.h"
#include "nsRect.h"
#include "nsRegion.h"
#include "gfxASurface.h"
#ifdef _MSC_VER
#pragma warning( disable : 4800 )
@ -59,6 +60,7 @@
namespace mozilla {
typedef gfxPattern::GraphicsFilter GraphicsFilterType;
typedef gfxASurface::gfxSurfaceType gfxSurfaceType;
// XXX there are out of place and might be generally useful. Could
// move to nscore.h or something.
@ -419,6 +421,38 @@ struct ParamTraits<mozilla::GraphicsFilterType>
}
}
};
template<>
struct ParamTraits<mozilla::gfxSurfaceType>
{
typedef mozilla::gfxSurfaceType paramType;
static void Write(Message* msg, const paramType& param)
{
if (gfxASurface::SurfaceTypeImage <= param &&
param < gfxASurface::SurfaceTypeMax) {
WriteParam(msg, int32(param));
return;
}
NS_RUNTIMEABORT("surface type not reached");
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
int32 filter;
if (!ReadParam(msg, iter, &filter))
return false;
if (gfxASurface::SurfaceTypeImage <= filter &&
filter < gfxASurface::SurfaceTypeMax) {
*result = paramType(filter);
return true;
}
return false;
}
};
template<>
struct ParamTraits<gfxRGBA>
{
@ -552,6 +586,24 @@ struct ParamTraits<nsIntSize>
}
};
template<>
struct ParamTraits<gfxIntSize>
{
typedef gfxIntSize paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.width);
WriteParam(msg, param.height);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->width) &&
ReadParam(msg, iter, &result->height));
}
};
} /* namespace IPC */
#endif /* __IPC_GLUE_IPCMESSAGEUTILS_H__ */