20829N/Adiff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp
20829N/A--- a/dom/plugins/ipc/PluginInstanceChild.cpp
20829N/A+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
20829N/A@@ -276,17 +276,17 @@ PluginInstanceChild::NPN_GetValue(NPNVar
20829N/A void* aValue)
20829N/A {
20829N/A PLUGIN_LOG_DEBUG(("%s (aVar=%i)", FULLFUNCTION, (int) aVar));
20829N/A AssertPluginThread();
20829N/A
20829N/A switch(aVar) {
20829N/A
20829N/A case NPNVSupportsWindowless:
20829N/A-#if defined(OS_LINUX) || defined(OS_WIN)
20829N/A+#if defined(OS_LINUX) || defined(MOZ_X11) || defined(OS_WIN)
20829N/A *((NPBool*)aValue) = true;
20829N/A #else
20829N/A *((NPBool*)aValue) = false;
20829N/A #endif
20829N/A return NPERR_NO_ERROR;
20829N/A
20829N/A #if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
20829N/A case NPNVSupportsWindowlessLocal: {
20829N/A@@ -295,17 +295,17 @@ PluginInstanceChild::NPN_GetValue(NPNVar
20829N/A // we should set local rendering to false in order to render X-Plugin
20829N/A // there is no possibility to change it later on maemo5 platform
20829N/A mMaemoImageRendering = (!(graphicsSystem && !strcmp(graphicsSystem, "native")));
20829N/A #endif
20829N/A *((NPBool*)aValue) = mMaemoImageRendering;
20829N/A return NPERR_NO_ERROR;
20829N/A }
20829N/A #endif
20829N/A-#if defined(OS_LINUX)
20829N/A+#if defined(MOZ_X11)
20829N/A case NPNVSupportsXEmbedBool:
20829N/A *((NPBool*)aValue) = true;
20829N/A return NPERR_NO_ERROR;
20829N/A
20829N/A case NPNVToolkit:
20829N/A *((NPNToolkitType*)aValue) = NPNVGtk2;
20829N/A return NPERR_NO_ERROR;
20829N/A
20829N/A@@ -2346,17 +2346,26 @@ PluginInstanceChild::CreateOptSurface(vo
20829N/A Display* dpy = mWsInfo.display;
20829N/A Screen* screen = DefaultScreenOfDisplay(dpy);
20829N/A if (format == gfxASurface::ImageFormatRGB24 &&
20829N/A DefaultDepth(dpy, DefaultScreen(dpy)) == 16) {
20829N/A format = gfxASurface::ImageFormatRGB16_565;
20829N/A }
20829N/A
20829N/A if (mSurfaceType == gfxASurface::SurfaceTypeXlib) {
20829N/A- XRenderPictFormat* xfmt = gfxXlibSurface::FindRenderFormat(dpy, format);
20829N/A+ if (!mIsTransparent || mBackground) {
20829N/A+ Visual* defaultVisual = DefaultVisualOfScreen(screen);
20829N/A+ mCurrentSurface =
20829N/A+ gfxXlibSurface::Create(screen, defaultVisual,
20829N/A+ gfxIntSize(mWindow.width,
20829N/A+ mWindow.height));
20829N/A+ return mCurrentSurface != nsnull;
20829N/A+ }
20829N/A+
20829N/A+ XRenderPictFormat* xfmt = XRenderFindStandardFormat(dpy, PictStandardARGB32);
20829N/A if (!xfmt) {
20829N/A NS_ERROR("Need X falback surface, but FindRenderFormat failed");
20829N/A return false;
20829N/A }
20829N/A mCurrentSurface =
20829N/A gfxXlibSurface::Create(screen, xfmt,
20829N/A gfxIntSize(mWindow.width,
20829N/A mWindow.height));
20829N/A@@ -2720,17 +2729,17 @@ PluginInstanceChild::PaintRectToSurface(
20829N/A #ifdef MOZ_X11
20829N/A if (mIsTransparent && (GetQuirks() & PluginModuleChild::QUIRK_FLASH_EXPOSE_COORD_TRANSLATION)) {
20829N/A // Work around a bug in Flash up to 10.1 d51 at least, where expose event
20829N/A // top left coordinates within the plugin-rect and not at the drawable
20829N/A // origin are misinterpreted. (We can move the top left coordinate
20829N/A // provided it is within the clipRect.), see bug 574583
20829N/A plPaintRect.SetRect(0, 0, aRect.XMost(), aRect.YMost());
20829N/A }
20829N/A- if (renderSurface->GetType() != gfxASurface::SurfaceTypeXlib) {
20829N/A+ if (mHelperSurface) {
20829N/A // On X11 we can paint to non Xlib surface only with HelperSurface
20829N/A #if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
20829N/A // Don't use mHelperSurface if surface is image and mMaemoImageRendering is TRUE
20829N/A if (!mMaemoImageRendering ||
20829N/A renderSurface->GetType() != gfxASurface::SurfaceTypeImage)
20829N/A #endif
20829N/A renderSurface = mHelperSurface;
20829N/A }
20829N/A@@ -2929,17 +2938,18 @@ PluginInstanceChild::ShowPluginFrame()
20829N/A this, haveTransparentPixels ? " with alpha" : "",
20829N/A rect.x, rect.y, rect.width, rect.height,
20829N/A mCurrentSurface->GetSize().width, mCurrentSurface->GetSize().height));
20829N/A
20829N/A if (CanPaintOnBackground()) {
20829N/A PLUGIN_LOG_DEBUG((" (on background)"));
20829N/A // Source the background pixels ...
20829N/A {
20829N/A- nsRefPtr<gfxContext> ctx = new gfxContext(mCurrentSurface);
20829N/A+ nsRefPtr<gfxContext> ctx =
20829N/A+ new gfxContext(mHelperSurface ? mHelperSurface : mCurrentSurface);
20829N/A ctx->SetSource(mBackground);
20829N/A ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
20829N/A ctx->Rectangle(gfxRect(rect.x, rect.y, rect.width, rect.height));
20829N/A ctx->Fill();
20829N/A }
20829N/A // ... and hand off to the plugin
20829N/A // BEWARE: mBackground may die during this call
20829N/A PaintRectToSurface(rect, mCurrentSurface, gfxRGBA(0.0, 0.0, 0.0, 0.0));
20829N/A@@ -3326,23 +3336,17 @@ PluginInstanceChild::SwapSurfaces()
20829N/A mBackSurfaceActor = tmpactor;
20829N/A #endif
20829N/A
20829N/A // Outdated back surface... not usable anymore due to changed plugin size.
20829N/A // Dropping obsolete surface
20829N/A if (mCurrentSurface && mBackSurface &&
20829N/A (mCurrentSurface->GetSize() != mBackSurface->GetSize() ||
20829N/A mCurrentSurface->GetContentType() != mBackSurface->GetContentType())) {
20829N/A- mCurrentSurface = nsnull;
20829N/A-#ifdef XP_WIN
20829N/A- if (mCurrentSurfaceActor) {
20829N/A- PPluginSurfaceChild::Send__delete__(mCurrentSurfaceActor);
20829N/A- mCurrentSurfaceActor = NULL;
20829N/A- }
20829N/A-#endif
20829N/A+ ClearCurrentSurface();
20829N/A }
20829N/A }
20829N/A
20829N/A void
20829N/A PluginInstanceChild::ClearCurrentSurface()
20829N/A {
20829N/A mCurrentSurface = nsnull;
20829N/A #ifdef XP_WIN