Bug 1851861: Null-check more calls that attempt to create a DrawTarget. r=gfx-reviewers,lsalzman

Most of our calls that create a DrawTarget are null-checked. This patch
fixes up the few that were not already checked.

Differential Revision: https://phabricator.services.mozilla.com/D187586
This commit is contained in:
Brad Werth 2023-09-06 20:13:22 +00:00
Родитель 8b640ae506
Коммит fa097e4d1e
3 изменённых файлов: 22 добавлений и 11 удалений

Просмотреть файл

@ -1803,9 +1803,13 @@ RefPtr<DrawTarget> DrawTargetCairo::CreateClippedDrawTarget(
if (!clipBounds.IsEmpty()) {
RefPtr<DrawTarget> dt = CreateSimilarDrawTarget(
IntSize(clipBounds.width, clipBounds.height), aFormat);
result = gfx::Factory::CreateOffsetDrawTarget(
dt, IntPoint(clipBounds.x, clipBounds.y));
result->SetTransform(mTransform);
if (dt) {
result = gfx::Factory::CreateOffsetDrawTarget(
dt, IntPoint(clipBounds.x, clipBounds.y));
if (result) {
result->SetTransform(mTransform);
}
}
} else {
// Everything is clipped but we still want some kind of surface
result = CreateSimilarDrawTarget(IntSize(1, 1), aFormat);

Просмотреть файл

@ -1230,8 +1230,12 @@ RefPtr<DrawTarget> DrawTargetD2D1::CreateClippedDrawTarget(
IntRect rect = RoundedOut(ToRect(clipRect));
RefPtr<DrawTarget> dt = CreateSimilarDrawTarget(rect.Size(), aFormat);
result = gfx::Factory::CreateOffsetDrawTarget(dt, rect.TopLeft());
result->SetTransform(mTransform);
if (dt) {
result = gfx::Factory::CreateOffsetDrawTarget(dt, rect.TopLeft());
if (result) {
result->SetTransform(mTransform);
}
}
if (!aBounds.IsEmpty()) {
PopClip();
}

Просмотреть файл

@ -370,22 +370,25 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
return false;
}
// aRenderRect is the part of the blob that we are currently rendering
// (for example a tile) in the same coordinate space as aVisibleRect.
IntPoint origin = gfx::IntPoint(aRenderRect->min.x, aRenderRect->min.y);
dt = gfx::Factory::CreateOffsetDrawTarget(dt, origin);
if (!dt) {
return false;
}
// We try hard to not have empty blobs but we can end up with
// them because of CompositorHitTestInfo and merging.
size_t footerSize = sizeof(size_t);
MOZ_RELEASE_ASSERT(aBlob.length() >= footerSize);
size_t indexOffset = ConvertFromBytes<size_t>(aBlob.end().get() - footerSize);
// aRenderRect is the part of the blob that we are currently rendering
// (for example a tile) in the same coordinate space as aVisibleRect.
IntPoint origin = gfx::IntPoint(aRenderRect->min.x, aRenderRect->min.y);
MOZ_RELEASE_ASSERT(indexOffset <= aBlob.length() - footerSize);
Reader reader(aBlob.begin().get() + indexOffset,
aBlob.length() - footerSize - indexOffset);
dt = gfx::Factory::CreateOffsetDrawTarget(dt, origin);
auto bounds = gfx::IntRect(origin, size);
if (aDirtyRect) {