From 4c08a5eb55ec9d63b47e99f264c964d10c5d1d1f Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 15 Apr 2014 14:36:27 +1200 Subject: [PATCH] Bug 996393 - Part 2: Use new gfxPlatform::GetWrappedDataSourceSurface API in nsLayoutUtils::SurfaceFromElement to avoid copying. r=roc --- layout/base/nsLayoutUtils.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 4b1868d2a1a..f474595c9b1 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -5408,20 +5408,9 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement, return result; if (wantImageSurface) { - IntSize size(imgWidth, imgHeight); - RefPtr output = Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8); - RefPtr dt = Factory::CreateDrawTargetForData(BackendType::CAIRO, - output->GetData(), - size, - output->Stride(), - SurfaceFormat::B8G8R8A8); - RefPtr source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, gfxsurf); - - dt->CopySurface(source, IntRect(0, 0, imgWidth, imgHeight), IntPoint()); - dt->Flush(); - - result.mSourceSurface = output; - } else { + result.mSourceSurface = gfxPlatform::GetPlatform()->GetWrappedDataSourceSurface(gfxsurf); + } + if (!result.mSourceSurface) { result.mSourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(aTarget, gfxsurf); } } else {