Bug 1759527 - Ensure ImageBitmapRenderingContext checks for null surfaces. r=gfx-reviewers,jnicol

This could happen when the content process cannot access the underlying
surface directly for example.

Differential Revision: https://phabricator.services.mozilla.com/D141098
This commit is contained in:
Andrew Osmond 2022-03-15 12:41:02 +00:00
parent 8e7cc7be44
commit 02150a3b67

View File

@ -102,6 +102,9 @@ ImageBitmapRenderingContext::InitializeWithDrawTarget(
already_AddRefed<gfx::DataSourceSurface>
ImageBitmapRenderingContext::MatchWithIntrinsicSize() {
RefPtr<gfx::SourceSurface> surface = mImage->GetAsSourceSurface();
if (!surface) {
return nullptr;
}
RefPtr<gfx::DataSourceSurface> temp = gfx::Factory::CreateDataSourceSurface(
gfx::IntSize(mWidth, mHeight), surface->GetFormat());
if (!temp) {
@ -195,6 +198,10 @@ ImageBitmapRenderingContext::GetSurfaceSnapshot(
}
RefPtr<gfx::SourceSurface> surface = mImage->GetAsSourceSurface();
if (!surface) {
return nullptr;
}
if (surface->GetSize() != gfx::IntSize(mWidth, mHeight)) {
return MatchWithIntrinsicSize();
}