From 5a0d03626e5676efd122bb758431f612765cb8d1 Mon Sep 17 00:00:00 2001 From: Anthony Jones Date: Sun, 2 Sep 2012 19:07:05 -0400 Subject: [PATCH] Bug 781731 - Fix Azure Cairo GTK perf by removing xlib to buffered image conversion. r=mattwoodrow --- gfx/thebes/gfxPlatform.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 582dd3ca4887..e8d1d79a1974 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -535,8 +535,23 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa dt->Flush(); } srcBuffer = aTarget->CreateSourceSurfaceFromNativeSurface(surf); - } + } else #endif + if (aSurface->CairoSurface() && aTarget->GetType() == BACKEND_CAIRO) { + // 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); + + if (srcBuffer) { + // It's cheap enough to make a new one so we won't keep it around and + // keeping it creates a cycle. + return srcBuffer; + } + } if (!srcBuffer) { nsRefPtr imgSurface = aSurface->GetAsImageSurface();