Bug 1656818 - Remove unnecessary copy from CanvasRenderingContext2D::DrawWindow. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D86894
This commit is contained in:
Matt Woodrow 2020-08-14 01:25:12 +00:00
parent a250b4d7a3
commit 31280579ce

View file

@ -4877,27 +4877,6 @@ void CanvasRenderingContext2D::DrawWindow(nsGlobalWindowInner& aWindow,
aError.Throw(NS_ERROR_FAILURE);
return;
}
RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
if (!data || !Factory::AllowedSurfaceSize(data->GetSize())) {
gfxCriticalError() << "Unexpected invalid data source surface "
<< (data ? data->GetSize() : IntSize(0, 0));
aError.Throw(NS_ERROR_FAILURE);
return;
}
DataSourceSurface::MappedSurface rawData;
if (NS_WARN_IF(!data->Map(DataSourceSurface::READ, &rawData))) {
aError.Throw(NS_ERROR_FAILURE);
return;
}
RefPtr<SourceSurface> source = mTarget->CreateSourceSurfaceFromData(
rawData.mData, data->GetSize(), rawData.mStride, data->GetFormat());
data->Unmap();
if (!source) {
aError.Throw(NS_ERROR_FAILURE);
return;
}
op = UsedOperation();
if (!IsTargetValid()) {
@ -4906,7 +4885,7 @@ void CanvasRenderingContext2D::DrawWindow(nsGlobalWindowInner& aWindow,
}
gfx::Rect destRect(0, 0, aW, aH);
gfx::Rect sourceRect(0, 0, sw, sh);
mTarget->DrawSurface(source, destRect, sourceRect,
mTarget->DrawSurface(snapshot, destRect, sourceRect,
DrawSurfaceOptions(gfx::SamplingFilter::POINT),
DrawOptions(GlobalAlpha(), op, AntialiasMode::NONE));
} else {