Bug 657874 Fix Flash movie playback with w_mode on a screen with xBGR visual r=karlt
authorGinn Chen <ginn.chen@oracle.com>
Thu, 02 Jun 2011 10:27:51 +0800
changeset 70449 9a6c139a4e586eeba4a2ed7b60706acbc146d3b8
parent 70448 b3760bf020265db8b97f12ff0f723642570780e6
child 70457 1e3b54a0191393b5d845f78072e8ceab948edab1
push id20323
push userginn.chen@oracle.com
push dateThu, 02 Jun 2011 02:29:40 +0000
treeherdermozilla-central@9a6c139a4e58 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs657874
milestone7.0a1
first release with
nightly linux32
9a6c139a4e58 / 7.0a1 / 20110602030726 / files
nightly linux64
9a6c139a4e58 / 7.0a1 / 20110602030726 / files
nightly mac
9a6c139a4e58 / 7.0a1 / 20110602030726 / files
nightly win32
9a6c139a4e58 / 7.0a1 / 20110602030726 / files
nightly win64
9a6c139a4e58 / 7.0a1 / 20110602030223 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 657874 Fix Flash movie playback with w_mode on a screen with xBGR visual r=karlt
dom/plugins/ipc/PluginInstanceChild.cpp
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -276,17 +276,17 @@ PluginInstanceChild::NPN_GetValue(NPNVar
                                   void* aValue)
 {
     PLUGIN_LOG_DEBUG(("%s (aVar=%i)", FULLFUNCTION, (int) aVar));
     AssertPluginThread();
 
     switch(aVar) {
 
     case NPNVSupportsWindowless:
-#if defined(OS_LINUX) || defined(OS_WIN)
+#if defined(OS_LINUX) || defined(MOZ_X11) || defined(OS_WIN)
         *((NPBool*)aValue) = true;
 #else
         *((NPBool*)aValue) = false;
 #endif
         return NPERR_NO_ERROR;
 
 #if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
     case NPNVSupportsWindowlessLocal: {
@@ -295,17 +295,17 @@ PluginInstanceChild::NPN_GetValue(NPNVar
         // we should set local rendering to false in order to render X-Plugin
         // there is no possibility to change it later on maemo5 platform
         mMaemoImageRendering = (!(graphicsSystem && !strcmp(graphicsSystem, "native")));
 #endif
         *((NPBool*)aValue) = mMaemoImageRendering;
         return NPERR_NO_ERROR;
     }
 #endif
-#if defined(OS_LINUX)
+#if defined(MOZ_X11)
     case NPNVSupportsXEmbedBool:
         *((NPBool*)aValue) = true;
         return NPERR_NO_ERROR;
 
     case NPNVToolkit:
         *((NPNToolkitType*)aValue) = NPNVGtk2;
         return NPERR_NO_ERROR;
 
@@ -2346,17 +2346,26 @@ PluginInstanceChild::CreateOptSurface(vo
     Display* dpy = mWsInfo.display;
     Screen* screen = DefaultScreenOfDisplay(dpy);
     if (format == gfxASurface::ImageFormatRGB24 &&
         DefaultDepth(dpy, DefaultScreen(dpy)) == 16) {
         format = gfxASurface::ImageFormatRGB16_565;
     }
 
     if (mSurfaceType == gfxASurface::SurfaceTypeXlib) {
-        XRenderPictFormat* xfmt = gfxXlibSurface::FindRenderFormat(dpy, format);
+        if (!mIsTransparent  || mBackground) {
+            Visual* defaultVisual = DefaultVisualOfScreen(screen);
+            mCurrentSurface =
+                gfxXlibSurface::Create(screen, defaultVisual,
+                                       gfxIntSize(mWindow.width,
+                                                  mWindow.height));
+            return mCurrentSurface != nsnull;
+        }
+
+        XRenderPictFormat* xfmt = XRenderFindStandardFormat(dpy, PictStandardARGB32);
         if (!xfmt) {
             NS_ERROR("Need X falback surface, but FindRenderFormat failed");
             return false;
         }
         mCurrentSurface =
             gfxXlibSurface::Create(screen, xfmt,
                                    gfxIntSize(mWindow.width,
                                               mWindow.height));
@@ -2720,17 +2729,17 @@ PluginInstanceChild::PaintRectToSurface(
 #ifdef MOZ_X11
     if (mIsTransparent && (GetQuirks() & PluginModuleChild::QUIRK_FLASH_EXPOSE_COORD_TRANSLATION)) {
         // Work around a bug in Flash up to 10.1 d51 at least, where expose event
         // top left coordinates within the plugin-rect and not at the drawable
         // origin are misinterpreted.  (We can move the top left coordinate
         // provided it is within the clipRect.), see bug 574583
         plPaintRect.SetRect(0, 0, aRect.XMost(), aRect.YMost());
     }
-    if (renderSurface->GetType() != gfxASurface::SurfaceTypeXlib) {
+    if (mHelperSurface) {
         // On X11 we can paint to non Xlib surface only with HelperSurface
 #if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
         // Don't use mHelperSurface if surface is image and mMaemoImageRendering is TRUE
         if (!mMaemoImageRendering ||
             renderSurface->GetType() != gfxASurface::SurfaceTypeImage)
 #endif
         renderSurface = mHelperSurface;
     }
@@ -2929,17 +2938,18 @@ PluginInstanceChild::ShowPluginFrame()
          this, haveTransparentPixels ? " with alpha" : "",
          rect.x, rect.y, rect.width, rect.height,
          mCurrentSurface->GetSize().width, mCurrentSurface->GetSize().height));
 
     if (CanPaintOnBackground()) {
         PLUGIN_LOG_DEBUG(("  (on background)"));
         // Source the background pixels ...
         {
-            nsRefPtr<gfxContext> ctx = new gfxContext(mCurrentSurface);
+            nsRefPtr<gfxContext> ctx =
+                new gfxContext(mHelperSurface ? mHelperSurface : mCurrentSurface);
             ctx->SetSource(mBackground);
             ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
             ctx->Rectangle(gfxRect(rect.x, rect.y, rect.width, rect.height));
             ctx->Fill();
         }
         // ... and hand off to the plugin
         // BEWARE: mBackground may die during this call
         PaintRectToSurface(rect, mCurrentSurface, gfxRGBA(0.0, 0.0, 0.0, 0.0));
@@ -3326,23 +3336,17 @@ PluginInstanceChild::SwapSurfaces()
     mBackSurfaceActor = tmpactor;
 #endif
 
     // Outdated back surface... not usable anymore due to changed plugin size.
     // Dropping obsolete surface
     if (mCurrentSurface && mBackSurface &&
         (mCurrentSurface->GetSize() != mBackSurface->GetSize() ||
          mCurrentSurface->GetContentType() != mBackSurface->GetContentType())) {
-        mCurrentSurface = nsnull;
-#ifdef XP_WIN
-        if (mCurrentSurfaceActor) {
-            PPluginSurfaceChild::Send__delete__(mCurrentSurfaceActor);
-            mCurrentSurfaceActor = NULL;
-        }
-#endif
+        ClearCurrentSurface();
     }
 }
 
 void
 PluginInstanceChild::ClearCurrentSurface()
 {
     mCurrentSurface = nsnull;
 #ifdef XP_WIN