b=521376 remove XSynchronize from plugin process r=cjones

This commit is contained in:
Karl Tomlinson 2009-10-12 12:54:49 +13:00
parent be2f5f8cbe
commit 3fa2368891
4 changed files with 45 additions and 31 deletions

View File

@ -57,6 +57,25 @@ using namespace mozilla::plugins;
#endif
PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface) :
mPluginIface(aPluginIface)
#if defined(OS_WIN)
, mPluginWindowHWND(0)
, mPluginWndProc(0)
, mPluginParentHWND(0)
#endif
{
memset(&mWindow, 0, sizeof(mWindow));
mData.ndata = (void*) this;
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
mWindow.ws_info = &mWsInfo;
memset(&mWsInfo, 0, sizeof(mWsInfo));
# ifdef MOZ_WIDGET_GTK2
mWsInfo.display = GDK_DISPLAY();
# endif
#endif
}
PluginInstanceChild::~PluginInstanceChild()
{
#if defined(OS_WIN)
@ -303,6 +322,20 @@ PluginInstanceChild::AnswerNPP_HandleEvent(const NPEvent& event,
// plugins might be fooling with these, make a copy
NPEvent evcopy = event;
*handled = mPluginIface->event(&mData, reinterpret_cast<void*>(&evcopy));
#ifdef MOZ_X11
if (GraphicsExpose == event.type) {
// Make sure the X server completes the drawing before the parent
// draws on top and destroys the Drawable.
//
// XSync() waits for the X server to complete. Really this child
// process does not need to wait; the parent is the process that needs
// to wait. A possibly-slightly-better alternative would be to send
// an X event to the parent that the parent would wait for.
XSync(mWsInfo.display, False);
}
#endif
return true;
}
@ -358,9 +391,6 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow,
mWindow.clipRect = aWindow.clipRect;
mWindow.type = aWindow.type;
#ifdef MOZ_WIDGET_GTK2
mWsInfo.display = GDK_DISPLAY();
#endif
mWsInfo.colormap = aWindow.colormap;
if (!XVisualIDToInfo(mWsInfo.display, aWindow.visualID,
&mWsInfo.visual, &mWsInfo.depth))

View File

@ -140,23 +140,7 @@ protected:
const NPReason& reason);
public:
PluginInstanceChild(const NPPluginFuncs* aPluginIface) :
mPluginIface(aPluginIface)
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
, mPlug(0)
#elif defined(OS_WIN)
, mPluginWindowHWND(0)
, mPluginWndProc(0)
, mPluginParentHWND(0)
#endif
{
memset(&mWindow, 0, sizeof(mWindow));
mData.ndata = (void*) this;
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
mWindow.ws_info = &mWsInfo;
memset(&mWsInfo, 0, sizeof(mWsInfo));
#endif
}
PluginInstanceChild(const NPPluginFuncs* aPluginIface);
virtual ~PluginInstanceChild();
@ -201,11 +185,8 @@ private:
const NPPluginFuncs* mPluginIface;
NPP_t mData;
#ifdef OS_LINUX
GtkWidget* mPlug;
#endif
NPWindow mWindow;
#ifdef OS_LINUX
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
NPSetWindowCallbackStruct mWsInfo;
#elif defined(OS_WIN)
HWND mPluginWindowHWND;

View File

@ -433,15 +433,20 @@ PluginInstanceParent::NPP_HandleEvent(void* event)
NPEvent* npevent = reinterpret_cast<NPEvent*>(event);
#if defined(OS_LINUX)
#if defined(MOZ_X11)
if (GraphicsExpose == npevent->type) {
printf(" schlepping drawable 0x%lx across the pipe\n",
npevent->xgraphicsexpose.drawable);
// FIXME: this is probably rather expensive, should only do it
// when necessary. which raises the question: when is it
// necessary?
// Make sure the X server has created the Drawable and completes any
// drawing before the plugin draws on top.
//
// XSync() waits for the X server to complete. Really this parent
// process does not need to wait; the child is the process that needs
// to wait. A possibly-slightly-better alternative would be to send
// an X event to the child that the child would wait for.
# ifdef MOZ_WIDGET_GTK2
XSync(GDK_DISPLAY(), False);
# endif
}
#endif

View File

@ -176,8 +176,6 @@ PluginModuleChild::InitGraphics()
// FIXME/cjones: is this the place for this?
#if defined(OS_LINUX)
gtk_init(0, 0);
XSynchronize(GDK_DISPLAY(), True);
#else
// may not be necessary on all platforms
#endif