Bug 996393 - Part 2: Use new gfxPlatform::GetWrappedDataSourceSurface API in nsLayoutUtils::SurfaceFromElement to avoid copying. r=roc

This commit is contained in:
Matt Woodrow 2014-04-15 14:36:27 +12:00
parent 71adf4fec9
commit 4c08a5eb55

View File

@ -5408,20 +5408,9 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
return result; return result;
if (wantImageSurface) { if (wantImageSurface) {
IntSize size(imgWidth, imgHeight); result.mSourceSurface = gfxPlatform::GetPlatform()->GetWrappedDataSourceSurface(gfxsurf);
RefPtr<DataSourceSurface> output = Factory::CreateDataSourceSurface(size, SurfaceFormat::B8G8R8A8); }
RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(BackendType::CAIRO, if (!result.mSourceSurface) {
output->GetData(),
size,
output->Stride(),
SurfaceFormat::B8G8R8A8);
RefPtr<SourceSurface> 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()->GetSourceSurfaceForSurface(aTarget, gfxsurf); result.mSourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(aTarget, gfxsurf);
} }
} else { } else {