Bug 1950610 [Wayland] Always use WR compositor to paint D&D popups r=lsalzman

We can't use native compositor to paint D&D popups as Wayland doesn't implement subsurfaces for it.

Differential Revision: https://phabricator.services.mozilla.com/D239733
This commit is contained in:
stransky
2025-02-27 07:59:45 +00:00
parent a3bcb912a5
commit 8d58db2e9e
6 changed files with 20 additions and 4 deletions

View File

@@ -42,6 +42,7 @@ class CompositorOptions {
bool AllowSoftwareWebRenderOGL() const { return mAllowSoftwareWebRenderOGL; } bool AllowSoftwareWebRenderOGL() const { return mAllowSoftwareWebRenderOGL; }
bool InitiallyPaused() const { return mInitiallyPaused; } bool InitiallyPaused() const { return mInitiallyPaused; }
bool NeedFastSnaphot() const { return mNeedFastSnaphot; } bool NeedFastSnaphot() const { return mNeedFastSnaphot; }
bool AllowNativeCompositor() const { return mAllowNativeCompositor; }
void SetUseAPZ(bool aUseAPZ) { mUseAPZ = aUseAPZ; } void SetUseAPZ(bool aUseAPZ) { mUseAPZ = aUseAPZ; }
@@ -61,13 +62,18 @@ class CompositorOptions {
mNeedFastSnaphot = aNeedFastSnaphot; mNeedFastSnaphot = aNeedFastSnaphot;
} }
void SetAllowNativeCompositor(bool aAllowNativeCompositor) {
mAllowNativeCompositor = aAllowNativeCompositor;
}
bool EqualsIgnoringApzEnablement(const CompositorOptions& aOther) const { bool EqualsIgnoringApzEnablement(const CompositorOptions& aOther) const {
return mUseSoftwareWebRender == aOther.mUseSoftwareWebRender && return mUseSoftwareWebRender == aOther.mUseSoftwareWebRender &&
mAllowSoftwareWebRenderD3D11 == mAllowSoftwareWebRenderD3D11 ==
aOther.mAllowSoftwareWebRenderD3D11 && aOther.mAllowSoftwareWebRenderD3D11 &&
mAllowSoftwareWebRenderOGL == aOther.mAllowSoftwareWebRenderOGL && mAllowSoftwareWebRenderOGL == aOther.mAllowSoftwareWebRenderOGL &&
mInitiallyPaused == aOther.mInitiallyPaused && mInitiallyPaused == aOther.mInitiallyPaused &&
mNeedFastSnaphot == aOther.mNeedFastSnaphot; mNeedFastSnaphot == aOther.mNeedFastSnaphot &&
mAllowNativeCompositor == aOther.mAllowNativeCompositor;
} }
bool operator==(const CompositorOptions& aOther) const { bool operator==(const CompositorOptions& aOther) const {
@@ -83,6 +89,7 @@ class CompositorOptions {
bool mAllowSoftwareWebRenderOGL = false; bool mAllowSoftwareWebRenderOGL = false;
bool mInitiallyPaused = false; bool mInitiallyPaused = false;
bool mNeedFastSnaphot = false; bool mNeedFastSnaphot = false;
bool mAllowNativeCompositor = true;
// Make sure to add new fields to the ParamTraits implementation // Make sure to add new fields to the ParamTraits implementation
// in LayersMessageUtils.h // in LayersMessageUtils.h

View File

@@ -1011,6 +1011,7 @@ struct ParamTraits<mozilla::layers::CompositorOptions> {
WriteParam(aWriter, aParam.mAllowSoftwareWebRenderOGL); WriteParam(aWriter, aParam.mAllowSoftwareWebRenderOGL);
WriteParam(aWriter, aParam.mInitiallyPaused); WriteParam(aWriter, aParam.mInitiallyPaused);
WriteParam(aWriter, aParam.mNeedFastSnaphot); WriteParam(aWriter, aParam.mNeedFastSnaphot);
WriteParam(aWriter, aParam.mAllowNativeCompositor);
} }
static bool Read(MessageReader* aReader, paramType* aResult) { static bool Read(MessageReader* aReader, paramType* aResult) {
@@ -1019,7 +1020,8 @@ struct ParamTraits<mozilla::layers::CompositorOptions> {
ReadParam(aReader, &aResult->mAllowSoftwareWebRenderD3D11) && ReadParam(aReader, &aResult->mAllowSoftwareWebRenderD3D11) &&
ReadParam(aReader, &aResult->mAllowSoftwareWebRenderOGL) && ReadParam(aReader, &aResult->mAllowSoftwareWebRenderOGL) &&
ReadParam(aReader, &aResult->mInitiallyPaused) && ReadParam(aReader, &aResult->mInitiallyPaused) &&
ReadParam(aReader, &aResult->mNeedFastSnaphot); ReadParam(aReader, &aResult->mNeedFastSnaphot) &&
ReadParam(aReader, &aResult->mAllowNativeCompositor);
} }
}; };

View File

@@ -205,7 +205,10 @@ UniquePtr<RenderCompositor> RenderCompositor::Create(
return RenderCompositorNativeSWGL::Create(aWidget, aError); return RenderCompositorNativeSWGL::Create(aWidget, aError);
} }
#elif defined(MOZ_WAYLAND) #elif defined(MOZ_WAYLAND)
if (gfx::gfxVars::UseWebRenderCompositor()) { // Some widgets on Wayland (D&D popups for instance) can't use native
// compositor due to system limitations.
if (gfx::gfxVars::UseWebRenderCompositor() &&
aWidget->GetCompositorOptions().AllowNativeCompositor()) {
return RenderCompositorNativeSWGL::Create(aWidget, aError); return RenderCompositorNativeSWGL::Create(aWidget, aError);
} }
#endif #endif
@@ -231,7 +234,8 @@ UniquePtr<RenderCompositor> RenderCompositor::Create(
#endif #endif
#if defined(MOZ_WAYLAND) #if defined(MOZ_WAYLAND)
if (gfx::gfxVars::UseWebRenderCompositor()) { if (gfx::gfxVars::UseWebRenderCompositor() &&
aWidget->GetCompositorOptions().AllowNativeCompositor()) {
return RenderCompositorNativeOGL::Create(aWidget, aError); return RenderCompositorNativeOGL::Create(aWidget, aError);
} }
#endif #endif

View File

@@ -432,6 +432,7 @@ class nsWindow final : public nsBaseWidget {
LayoutDeviceIntMargin GtkBorderToDevicePixels(const GtkBorder&); LayoutDeviceIntMargin GtkBorderToDevicePixels(const GtkBorder&);
bool WidgetTypeSupportsAcceleration() override; bool WidgetTypeSupportsAcceleration() override;
bool WidgetTypeSupportsNativeCompositing() override { return !mIsDragPopup; }
nsresult SetSystemFont(const nsCString& aFontName) override; nsresult SetSystemFont(const nsCString& aFontName) override;
nsresult GetSystemFont(nsCString& aFontName) override; nsresult GetSystemFont(nsCString& aFontName) override;

View File

@@ -1452,6 +1452,7 @@ already_AddRefed<WebRenderLayerManager> nsBaseWidget::CreateCompositorSession(
options.SetAllowSoftwareWebRenderOGL( options.SetAllowSoftwareWebRenderOGL(
gfx::gfxVars::AllowSoftwareWebRenderOGL()); gfx::gfxVars::AllowSoftwareWebRenderOGL());
} }
options.SetAllowNativeCompositor(WidgetTypeSupportsNativeCompositing());
#endif #endif
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID

View File

@@ -280,6 +280,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
} }
bool ComputeShouldAccelerate(); bool ComputeShouldAccelerate();
virtual bool WidgetTypeSupportsAcceleration() { return true; } virtual bool WidgetTypeSupportsAcceleration() { return true; }
virtual bool WidgetTypeSupportsNativeCompositing() { return true; }
[[nodiscard]] nsresult OnDefaultButtonLoaded( [[nodiscard]] nsresult OnDefaultButtonLoaded(
const LayoutDeviceIntRect& aButtonRect) override { const LayoutDeviceIntRect& aButtonRect) override {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;