mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1557105 - Handle non-webrender widget case during enabling WebRender at ImageBridge r=nical
ImageBridgeChild has only one global TextureFactoryIdentifier. When WebRender is enabled, it is used for both WebRender widget and non-WebRender(BasicCompositor) widget. WebRenderImageHost and ImageHost are incompatible and WebRenderTextureHost does not permit to be consumed on compositor thread. Then it does not work well for non-WebRender widget. To address the problem at ImageContainer, ImageContainer needs to know a connected widget type. It is not easy in some cases like WebRTC. Then host side could address the problem easier. CompositableParentManager::FindCompositable() is changed to permit transform from WebRenderImageHost to ImageHost if it is necessary when WebRenderImageHost belongs to ImageBridge. WebRenderTextureHost is changed to permit to consume wrapped TextureHost on compositor thread. If the wrapped TextureHost is BufferTextureHost, it is possible to comsume the TextureHost on compositor and on RenderThread, since they are memory buffer or shared memory buffer. WebRTC code always create BufferTextureHost for video frame. Then it works. Differential Revision: https://phabricator.services.mozilla.com/D34132 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
9bf5c64368
commit
ec2350cffb
@ -470,7 +470,6 @@ class Compositor : public TextureSourceProvider {
|
||||
virtual LayersBackend GetBackendType() const = 0;
|
||||
|
||||
virtual CompositorD3D11* AsCompositorD3D11() { return nullptr; }
|
||||
virtual BasicCompositor* AsBasicCompositor() { return nullptr; }
|
||||
|
||||
Compositor* AsCompositor() override { return this; }
|
||||
|
||||
|
@ -25,6 +25,7 @@ namespace layers {
|
||||
|
||||
class TextureHost;
|
||||
class DataTextureSource;
|
||||
class BasicCompositor;
|
||||
class Compositor;
|
||||
class CompositorOGL;
|
||||
|
||||
@ -86,6 +87,10 @@ class TextureSourceProvider {
|
||||
// return null.
|
||||
virtual Compositor* AsCompositor() { return nullptr; }
|
||||
|
||||
// If this provider is also a BasicCompositor, return the compositor.
|
||||
// Otherwise return nullptr.
|
||||
virtual BasicCompositor* AsBasicCompositor() { return nullptr; }
|
||||
|
||||
// If this provider is also a CompositorOGL, return the compositor. Otherwise
|
||||
// return nullptr.
|
||||
virtual CompositorOGL* AsCompositorOGL() { return nullptr; }
|
||||
|
@ -130,6 +130,8 @@ class CompositableHost {
|
||||
return gfx::IntSize();
|
||||
}
|
||||
|
||||
const TextureInfo& GetTextureInfo() const { return mTextureInfo; }
|
||||
|
||||
/**
|
||||
* Adds a mask effect using this texture as the mask, if possible.
|
||||
* @return true if the effect was added, false otherwise.
|
||||
|
@ -278,12 +278,33 @@ RefPtr<CompositableHost> CompositableParentManager::AddCompositable(
|
||||
}
|
||||
|
||||
RefPtr<CompositableHost> CompositableParentManager::FindCompositable(
|
||||
const CompositableHandle& aHandle) {
|
||||
const CompositableHandle& aHandle, bool aAllowDisablingWebRender) {
|
||||
auto iter = mCompositables.find(aHandle.Value());
|
||||
if (iter == mCompositables.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return iter->second;
|
||||
|
||||
RefPtr<CompositableHost> host = iter->second;
|
||||
if (!aAllowDisablingWebRender) {
|
||||
return host;
|
||||
}
|
||||
|
||||
if (!host->AsWebRenderImageHost() || !host->GetAsyncRef()) {
|
||||
return host;
|
||||
}
|
||||
|
||||
// Try to replace WebRenderImageHost of ImageBridge to ImageHost.
|
||||
RefPtr<CompositableHost> newHost = CompositableHost::Create(
|
||||
host->GetTextureInfo(), /* aUseWebRender */ false);
|
||||
if (!newHost || !newHost->AsImageHost()) {
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
||||
return host;
|
||||
}
|
||||
|
||||
newHost->SetAsyncRef(host->GetAsyncRef());
|
||||
mCompositables[aHandle.Value()] = newHost;
|
||||
|
||||
return newHost;
|
||||
}
|
||||
|
||||
void CompositableParentManager::ReleaseCompositable(
|
||||
|
@ -38,7 +38,8 @@ class CompositableParentManager : public HostIPCAllocator {
|
||||
RefPtr<CompositableHost> AddCompositable(const CompositableHandle& aHandle,
|
||||
const TextureInfo& aInfo,
|
||||
bool aUseWebRender);
|
||||
RefPtr<CompositableHost> FindCompositable(const CompositableHandle& aHandle);
|
||||
RefPtr<CompositableHost> FindCompositable(
|
||||
const CompositableHandle& aHandle, bool aAllowDisablingWebRender = false);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -393,8 +393,8 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvUpdate(
|
||||
if (!imageBridge) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
RefPtr<CompositableHost> host =
|
||||
imageBridge->FindCompositable(op.compositable());
|
||||
RefPtr<CompositableHost> host = imageBridge->FindCompositable(
|
||||
op.compositable(), /* aAllowDisablingWebRender */ true);
|
||||
if (!host) {
|
||||
// This normally should not happen, but can after a GPU process crash.
|
||||
// Media may not have had time to update the ImageContainer associated
|
||||
|
@ -69,20 +69,63 @@ void WebRenderTextureHost::CreateRenderTextureHost(
|
||||
}
|
||||
|
||||
bool WebRenderTextureHost::Lock() {
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
||||
MOZ_ASSERT(!mWrappedTextureHost.get() ||
|
||||
mWrappedTextureHost->AsBufferTextureHost());
|
||||
|
||||
if (mWrappedTextureHost && mWrappedTextureHost->AsBufferTextureHost()) {
|
||||
return mWrappedTextureHost->Lock();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WebRenderTextureHost::Unlock() {
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
||||
MOZ_ASSERT(!mWrappedTextureHost.get() ||
|
||||
mWrappedTextureHost->AsBufferTextureHost());
|
||||
|
||||
if (mWrappedTextureHost && mWrappedTextureHost->AsBufferTextureHost()) {
|
||||
mWrappedTextureHost->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void WebRenderTextureHost::PrepareTextureSource(
|
||||
CompositableTextureSourceRef& aTexture) {
|
||||
MOZ_ASSERT(!mWrappedTextureHost.get() ||
|
||||
mWrappedTextureHost->AsBufferTextureHost());
|
||||
|
||||
if (mWrappedTextureHost && mWrappedTextureHost->AsBufferTextureHost()) {
|
||||
mWrappedTextureHost->PrepareTextureSource(aTexture);
|
||||
}
|
||||
}
|
||||
|
||||
bool WebRenderTextureHost::BindTextureSource(
|
||||
CompositableTextureSourceRef& aTexture) {
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
||||
MOZ_ASSERT(!mWrappedTextureHost.get() ||
|
||||
mWrappedTextureHost->AsBufferTextureHost());
|
||||
|
||||
if (mWrappedTextureHost && mWrappedTextureHost->AsBufferTextureHost()) {
|
||||
return mWrappedTextureHost->BindTextureSource(aTexture);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WebRenderTextureHost::UnbindTextureSource() {
|
||||
if (mWrappedTextureHost && mWrappedTextureHost->AsBufferTextureHost()) {
|
||||
mWrappedTextureHost->UnbindTextureSource();
|
||||
}
|
||||
}
|
||||
|
||||
void WebRenderTextureHost::SetTextureSourceProvider(
|
||||
TextureSourceProvider* aProvider) {
|
||||
// During using WebRender, only BasicCompositor could exist
|
||||
MOZ_ASSERT(!aProvider || aProvider->AsBasicCompositor());
|
||||
MOZ_ASSERT(!mWrappedTextureHost.get() ||
|
||||
mWrappedTextureHost->AsBufferTextureHost());
|
||||
|
||||
if (mWrappedTextureHost && mWrappedTextureHost->AsBufferTextureHost()) {
|
||||
mWrappedTextureHost->SetTextureSourceProvider(aProvider);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<gfx::DataSourceSurface> WebRenderTextureHost::GetAsSurface() {
|
||||
if (!mWrappedTextureHost) {
|
||||
return nullptr;
|
||||
@ -90,9 +133,6 @@ already_AddRefed<gfx::DataSourceSurface> WebRenderTextureHost::GetAsSurface() {
|
||||
return mWrappedTextureHost->GetAsSurface();
|
||||
}
|
||||
|
||||
void WebRenderTextureHost::SetTextureSourceProvider(
|
||||
TextureSourceProvider* aProvider) {}
|
||||
|
||||
gfx::YUVColorSpace WebRenderTextureHost::GetYUVColorSpace() const {
|
||||
if (mWrappedTextureHost) {
|
||||
return mWrappedTextureHost->GetYUVColorSpace();
|
||||
|
@ -30,12 +30,15 @@ class WebRenderTextureHost : public TextureHost {
|
||||
|
||||
void DeallocateDeviceData() override {}
|
||||
|
||||
void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
|
||||
bool Lock() override;
|
||||
|
||||
void Unlock() override;
|
||||
|
||||
void PrepareTextureSource(CompositableTextureSourceRef& aTexture) override;
|
||||
bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
|
||||
void UnbindTextureSource() override;
|
||||
void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
|
||||
|
||||
gfx::SurfaceFormat GetFormat() const override;
|
||||
|
||||
virtual void NotifyNotUsed() override;
|
||||
@ -46,8 +49,6 @@ class WebRenderTextureHost : public TextureHost {
|
||||
// Please check TextureHost::GetReadFormat().
|
||||
gfx::SurfaceFormat GetReadFormat() const override;
|
||||
|
||||
bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
|
||||
|
||||
already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
|
||||
|
||||
gfx::YUVColorSpace GetYUVColorSpace() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user