Bug 1837070 - Ensure we flush OffscreenCanvas when the display list is recreated. r=lsalzman

When we recreate the display list, e.g. after tabbing away, we need to
ensure we flush the OffscreenCanvas because our resource handles will be
invalidated. This requires the OffscreenCanvasDisplayHelper to know
which OffscreenCanvas it belongs to, and a worker reference if necessary
to do the dispatching for the flush. Otherwise we would require the
canvas to be updated manually by the web application to repaint.

Differential Revision: https://phabricator.services.mozilla.com/D184324
This commit is contained in:
Andrew Osmond
2023-07-23 20:42:41 +00:00
parent 0e0ae0a785
commit 2d890a764c
6 changed files with 115 additions and 5 deletions

View File

@@ -485,7 +485,7 @@ HTMLCanvasElement::~HTMLCanvasElement() { Destroy(); }
void HTMLCanvasElement::Destroy() {
if (mOffscreenDisplay) {
mOffscreenDisplay->Destroy();
mOffscreenDisplay->DestroyElement();
mOffscreenDisplay = nullptr;
mImageContainer = nullptr;
}
@@ -1095,6 +1095,12 @@ void HTMLCanvasElement::SetHeight(uint32_t aHeight, ErrorResult& aRv) {
SetUnsignedIntAttr(nsGkAtoms::height, aHeight, DEFAULT_CANVAS_HEIGHT, aRv);
}
void HTMLCanvasElement::FlushOffscreenCanvas() {
if (mOffscreenDisplay) {
mOffscreenDisplay->FlushForDisplay();
}
}
void HTMLCanvasElement::InvalidateCanvasPlaceholder(uint32_t aWidth,
uint32_t aHeight) {
ErrorResult rv;