Bug 781731 - Fix Azure Cairo GTK perf by removing xlib to buffered image conversion. r=Bas
☠☠ backed out by d9a7f7115ec6 ☠ ☠
authorAnthony Jones <ajones@mozilla.com>
Wed, 29 Aug 2012 17:00:09 -0400
changeset 103809 503884273a3a5d703a00dacc7a5b3b4b52ec835d
parent 103808 c71057cd9300944ca573e49ff252f84ebf05d51a
child 103810 dc33092d9cd8a09562a7fa5d47b22d6892c7cf95
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersBas
bugs781731
milestone18.0a1
Bug 781731 - Fix Azure Cairo GTK perf by removing xlib to buffered image conversion. r=Bas
gfx/thebes/gfxPlatform.cpp
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -530,18 +530,31 @@ gfxPlatform::GetSourceSurfaceForSurface(
     surf.mFormat = format;
     surf.mType = NATIVE_SURFACE_D3D10_TEXTURE;
     surf.mSurface = static_cast<gfxD2DSurface*>(aSurface)->GetTexture();
     mozilla::gfx::DrawTarget *dt = static_cast<mozilla::gfx::DrawTarget*>(aSurface->GetData(&kDrawTarget));
     if (dt) {
       dt->Flush();
     }
     srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
+  } else
+#endif
+  if (aSurface->CairoSurface()) {
+    // If this is an xlib cairo surface we don't want to fetch it into memory
+    // because this is a major slow down.
+    NativeSurface surf;
+    surf.mFormat = format;
+    surf.mType = NATIVE_SURFACE_CAIRO_SURFACE;
+    surf.mSurface = aSurface->CairoSurface();
+    srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf);
+
+    // It's cheap enough to make a new one so we won't keep it around and
+    // keeping it creates a cycle.
+    return srcBuffer;
   }
-#endif
 
   if (!srcBuffer) {
     nsRefPtr<gfxImageSurface> imgSurface = aSurface->GetAsImageSurface();
 
     bool isWin32ImageSurf = imgSurface &&
                             aSurface->GetType() == gfxASurface::SurfaceTypeWin32;
 
     if (!imgSurface) {