Bug 781731 - Fixed Azure Cairo GTK perf by removing xlib to buffered image conversion; r=Bas
authorAnthony Jones <ajones@mozilla.com>
Mon, 27 Aug 2012 11:31:33 +0200
changeset 105580 f3fa6d8742ffe6f91aacb77f73945d441dc1dfdf
parent 105579 b3fde74539de8ea3e44ad707416de4caacfbad4f
child 105581 7402befeff1c5462046704415800b16b690f5cc9
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersBas
bugs781731
milestone17.0a1
Bug 781731 - Fixed 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) {