Bug 1799495 - Ensure WaitForShmem has a valid DrawTargetWebgl to access. r=aosmond

Differential Revision: https://phabricator.services.mozilla.com/D161554
This commit is contained in:
Lee Salzman 2022-11-08 16:23:56 +00:00
Родитель 56d4fa3ec9
Коммит b00c9670cf
4 изменённых файлов: 28 добавлений и 5 удалений

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

@ -224,7 +224,7 @@ DrawTargetWebgl::~DrawTargetWebgl() {
// Force any Skia snapshots to copy the shmem before it deallocs.
mSkia->DetachAllSnapshots();
// Ensure we're done using the shmem before dealloc.
mSharedContext->WaitForShmem();
mSharedContext->WaitForShmem(this);
auto* child = mSharedContext->mWebgl->GetChild();
if (child && child->CanSend()) {
child->DeallocShmem(mShmem);
@ -3226,7 +3226,7 @@ void DrawTargetWebgl::FillGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer,
mSkia->FillGlyphs(aFont, aBuffer, aPattern, aOptions);
}
void DrawTargetWebgl::SharedContext::WaitForShmem() {
void DrawTargetWebgl::SharedContext::WaitForShmem(DrawTargetWebgl* aTarget) {
if (mWaitForShmem) {
// GetError is a sync IPDL call that forces all dispatched commands to be
// flushed. Once it returns, we are certain that any commands processing
@ -3235,7 +3235,9 @@ void DrawTargetWebgl::SharedContext::WaitForShmem() {
mWaitForShmem = false;
// The sync IPDL call can cause expensive round-trips to add up over time,
// so account for that here.
mCurrentTarget->mProfile.OnReadback();
if (aTarget) {
aTarget->mProfile.OnReadback();
}
}
}

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

@ -309,7 +309,7 @@ class DrawTargetWebgl : public DrawTarget, public SupportsWeakPtr {
void ClearEmptyTextureMemory();
void ClearCachesIfNecessary();
void WaitForShmem();
void WaitForShmem(DrawTargetWebgl* aTarget);
};
RefPtr<SharedContext> mSharedContext;
@ -486,7 +486,7 @@ class DrawTargetWebgl : public DrawTarget, public SupportsWeakPtr {
void WaitForShmem() {
if (mSharedContext->mWaitForShmem) {
mSharedContext->WaitForShmem();
mSharedContext->WaitForShmem(this);
}
}

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

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<script>
window.addEventListener('load', async () => {
const canvas1 = document.createElement('canvas')
document.documentElement.appendChild(canvas1)
const context1 = canvas1.getContext('2d')
context1.globalCompositeOperation = 'destination-atop'
const path = new Path2D()
context1.fill(path, 'nonzero')
const canvas2 = document.createElement('canvas')
const context2 = canvas2.getContext('2d', {})
await window.createImageBitmap(canvas1, 124, 233, 2147483647, 1, {})
context2.filter = 'invert( 90% )'
context2.fillRect(-1, -128, 4096, 1024)
})
</script>
</head>
</html>

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

@ -222,3 +222,4 @@ pref(layout.css.backdrop-filter.enabled,true) load 1771561.html
load 1780567.html
load 1681955.html
load 1797099-1.html
load 1799495-1.html