Bug 1854467 - Avoid using ExtractSubrect with OffscreenCanvas. r=gfx-reviewers,jrmuizel

With OffscreenCanvas, mCanvasElement may be null, so we need to check
for that case when deciding whether or not we need to use ExtractSubrect
when calling DrawImage.

Differential Revision: https://phabricator.services.mozilla.com/D188877
This commit is contained in:
Andrew Osmond 2023-09-21 21:29:30 +00:00
Родитель 163fd5a55a
Коммит f475176d43
1 изменённых файлов: 2 добавлений и 1 удалений

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

@ -5461,7 +5461,8 @@ void CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
if (srcSurf) {
gfx::Rect sourceRect(aSx, aSy, aSw, aSh);
if (element == mCanvasElement) {
if ((element && element == mCanvasElement) ||
(offscreenCanvas && offscreenCanvas == mOffscreenCanvas)) {
// srcSurf is a snapshot of mTarget. If we draw to mTarget now, we'll
// trigger a COW copy of the whole canvas into srcSurf. That's a huge
// waste if sourceRect doesn't cover the whole canvas.