summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Andrews <athenian200@outlook.com>2023-10-23 22:36:00 -0500
committerJeremy Andrews <athenian200@outlook.com>2023-10-24 00:59:00 -0500
commit855109b02862ed5680500de105147bf6e79adc45 (patch)
treee72ae9409804fa5252c16231f2851cdb05de759b
parentc48055d6ea9a63ee8a19a38c3e8759e3630b00fe (diff)
downloaduxp-855109b02862ed5680500de105147bf6e79adc45.tar.gz
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
-rw-r--r--gfx/layers/ipc/SharedRGBImage.cpp27
-rw-r--r--gfx/layers/ipc/SharedRGBImage.h1
2 files changed, 27 insertions, 1 deletions
diff --git a/gfx/layers/ipc/SharedRGBImage.cpp b/gfx/layers/ipc/SharedRGBImage.cpp
index bb3bb968cd..2db2ef105a 100644
--- a/gfx/layers/ipc/SharedRGBImage.cpp
+++ b/gfx/layers/ipc/SharedRGBImage.cpp
@@ -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
diff --git a/gfx/layers/ipc/SharedRGBImage.h b/gfx/layers/ipc/SharedRGBImage.h
index 2c6009c19c..7122b27bc4 100644
--- a/gfx/layers/ipc/SharedRGBImage.h
+++ b/gfx/layers/ipc/SharedRGBImage.h
@@ -51,6 +51,7 @@ private:
gfx::IntSize mSize;
RefPtr<ImageClient> mCompositable;
RefPtr<TextureClient> mTextureClient;
+ nsCountedRef<nsMainThreadSourceSurfaceRef> mSourceSurface;
};
} // namespace layers