Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2023-10-26 10:55:31 +08:00
commit bac9ec9a84
39 changed files with 541 additions and 108 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