Issue #2357 - Paused WebM videos w/alpha are 100% transparent if HA is disabled.

Mozilla found a bug in their initial implementation, causing paused WebM videos with alpha to become totally transparent if hardware acceleration is disabled. Straight port of the Firefox 54 fix.

Ref: BZ 1332952
This commit is contained in:
Jeremy Andrews 2023-10-23 22:36:00 -05:00 committed by roytam1
commit 9982ceb94f
2 changed files with 27 additions and 1 deletions

View file

@ -106,7 +106,32 @@ SharedRGBImage::GetTextureClient(KnowsCompositor* aForwarder)
already_AddRefed<gfx::SourceSurface>
SharedRGBImage::GetAsSourceSurface()
{
return nullptr;
NS_ASSERTION(NS_IsMainThread(), "Must be main thread");
if (mSourceSurface) {
RefPtr<gfx::SourceSurface> surface(mSourceSurface);
return surface.forget();
}
RefPtr<gfx::SourceSurface> surface;
{
// We are 'borrowing' the DrawTarget and retaining a permanent reference to
// the underlying data (via the surface). It is in this instance since we
// know that the TextureClient is always wrapping a BufferTextureData and
// therefore it won't go away underneath us.
BufferTextureData* decoded_buffer =
mTextureClient->GetInternalData()->AsBufferTextureData();
RefPtr<gfx::DrawTarget> drawTarget = decoded_buffer->BorrowDrawTarget();
if (!drawTarget) {
return nullptr;
}
surface = drawTarget->Snapshot();
}
mSourceSurface = surface;
return surface.forget();
}
} // namespace layers

View file

@ -51,6 +51,7 @@ private:
gfx::IntSize mSize;
RefPtr<ImageClient> mCompositable;
RefPtr<TextureClient> mTextureClient;
nsCountedRef<nsMainThreadSourceSurfaceRef> mSourceSurface;
};
} // namespace layers