commit d3734204ad485cf7e8f33843c6787038b8e768de
parent 95e81323519c31c407a0eb4adfdfe948f30f787c
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Tue, 14 Oct 2025 21:30:11 +0000
Bug 1994273 - Make nsIWidget::GetNativeLayerRoot return a raw pointer. r=mac-reviewers,mstange
Otherwise GCC requires NativeLayerRoot to be fully defined. All callers
keep alive the NativeLayerRoot, and callees immediately store it in a
RefPtr of their own, so there is no behavior change.
Differential Revision: https://phabricator.services.mozilla.com/D268601
Diffstat:
16 files changed, 32 insertions(+), 38 deletions(-)
diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp
@@ -198,11 +198,9 @@ CompositorOGL::CompositorOGL(widget::CompositorWidget* aWidget,
mFrameInProgress(false),
mDestroyed(false),
mViewportSize(0, 0) {
- if (aWidget->GetNativeLayerRoot()) {
- // We can only render into native layers, our GLContext won't have a usable
- // default framebuffer.
- mCanRenderToDefaultFramebuffer = false;
- }
+ // If we render into native layers, our GLContext won't have a usable default
+ // framebuffer.
+ mCanRenderToDefaultFramebuffer = !aWidget->GetNativeLayerRoot();
MOZ_COUNT_CTOR(CompositorOGL);
}
diff --git a/gfx/webrender_bindings/RenderCompositorNative.cpp b/gfx/webrender_bindings/RenderCompositorNative.cpp
@@ -135,6 +135,12 @@ void RenderCompositorNative::GetCompositorCapabilities(
#endif
}
+RenderCompositorNative::Surface::~Surface() = default;
+
+RenderCompositorNative::Surface::Surface(wr::DeviceIntSize aTileSize,
+ bool aIsOpaque)
+ : mTileSize(aTileSize), mIsOpaque(aIsOpaque) {}
+
bool RenderCompositorNative::MaybeReadback(
const gfx::IntSize& aReadbackSize, const wr::ImageFormat& aReadbackFormat,
const Range<uint8_t>& aReadbackBuffer, bool* aNeedsYFlip) {
diff --git a/gfx/webrender_bindings/RenderCompositorNative.h b/gfx/webrender_bindings/RenderCompositorNative.h
@@ -114,9 +114,10 @@ class RenderCompositorNative : public RenderCompositor {
};
struct Surface {
- explicit Surface(wr::DeviceIntSize aTileSize, bool aIsOpaque)
- : mTileSize(aTileSize), mIsOpaque(aIsOpaque) {}
- gfx::IntSize TileSize() {
+ Surface(wr::DeviceIntSize aTileSize, bool aIsOpaque);
+ ~Surface();
+
+ gfx::IntSize TileSize() const {
return gfx::IntSize(mTileSize.width, mTileSize.height);
}
diff --git a/widget/CompositorWidget.cpp b/widget/CompositorWidget.cpp
@@ -6,6 +6,7 @@
#include "GLConsts.h"
#include "nsIWidget.h"
#include "VsyncDispatcher.h"
+#include "mozilla/gfx/2D.h"
namespace mozilla {
namespace widget {
diff --git a/widget/CompositorWidget.h b/widget/CompositorWidget.h
@@ -12,11 +12,6 @@
#include "mozilla/layers/CompositorOptions.h"
#include "mozilla/layers/LayersTypes.h"
-#ifdef MOZ_IS_GCC
-# include "mozilla/layers/NativeLayer.h"
-#endif
-
-class nsIWidget;
class nsIWidget;
namespace mozilla {
@@ -122,9 +117,7 @@ class CompositorWidget {
* When native layers are used, StartRemoteDrawing(InRegion) and
* EndRemoteDrawing(InRegion) will not be called.
*/
- virtual RefPtr<layers::NativeLayerRoot> GetNativeLayerRoot() {
- return nullptr;
- }
+ virtual layers::NativeLayerRoot* GetNativeLayerRoot() { return nullptr; }
/**
* Return a DrawTarget for the window which can be composited into.
diff --git a/widget/InProcessCompositorWidget.cpp b/widget/InProcessCompositorWidget.cpp
@@ -5,6 +5,7 @@
#include "InProcessCompositorWidget.h"
#include "mozilla/VsyncDispatcher.h"
+#include "mozilla/layers/NativeLayer.h"
#include "nsIWidget.h"
namespace mozilla {
@@ -55,8 +56,7 @@ void InProcessCompositorWidget::PostRender(WidgetRenderingContext* aContext) {
mWidget->PostRender(aContext);
}
-RefPtr<layers::NativeLayerRoot>
-InProcessCompositorWidget::GetNativeLayerRoot() {
+layers::NativeLayerRoot* InProcessCompositorWidget::GetNativeLayerRoot() {
CheckWidgetSanity();
return mWidget->GetNativeLayerRoot();
}
diff --git a/widget/InProcessCompositorWidget.h b/widget/InProcessCompositorWidget.h
@@ -19,7 +19,7 @@ class InProcessCompositorWidget : public CompositorWidget {
bool PreRender(WidgetRenderingContext* aManager) override;
void PostRender(WidgetRenderingContext* aManager) override;
- RefPtr<layers::NativeLayerRoot> GetNativeLayerRoot() override;
+ layers::NativeLayerRoot* GetNativeLayerRoot() override;
already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
already_AddRefed<gfx::DrawTarget> StartRemoteDrawingInRegion(
const LayoutDeviceIntRegion& aInvalidRegion) override;
diff --git a/widget/cocoa/CocoaCompositorWidget.cpp b/widget/cocoa/CocoaCompositorWidget.cpp
@@ -7,6 +7,7 @@
#include "CocoaCompositorWidget.h"
#include "mozilla/gfx/Logging.h"
+#include "mozilla/layers/NativeLayer.h"
#include "mozilla/layers/NativeLayerRootRemoteMacChild.h"
#include "mozilla/widget/PlatformWidgetTypes.h"
#include "nsIWidget.h"
@@ -32,8 +33,7 @@ void CocoaCompositorWidget::Init(CompositorWidgetInitData&& aInitData) {
mChildEndpoint = std::move(cocoaInitData.childEndpoint());
}
-RefPtr<mozilla::layers::NativeLayerRoot>
-CocoaCompositorWidget::GetNativeLayerRoot() {
+mozilla::layers::NativeLayerRoot* CocoaCompositorWidget::GetNativeLayerRoot() {
if (!mNativeLayerRoot) {
CreateNativeLayerRoot();
MOZ_ASSERT(mNativeLayerRoot);
diff --git a/widget/cocoa/CocoaCompositorWidget.h b/widget/cocoa/CocoaCompositorWidget.h
@@ -8,9 +8,12 @@
#include "CompositorWidget.h"
#include "mozilla/ipc/Endpoint.h"
-#include "mozilla/layers/NativeLayerRemoteChild.h"
+#include "mozilla/layers/NativeLayer.h"
namespace mozilla {
+namespace layers {
+class PNativeLayerRemoteChild;
+}
namespace widget {
class PlatformCompositorWidgetDelegate : public CompositorWidgetDelegate {
@@ -34,7 +37,7 @@ class CocoaCompositorWidget : public CompositorWidget {
virtual void Init(CompositorWidgetInitData&& aInitData);
// CompositorWidget overrides
- RefPtr<layers::NativeLayerRoot> GetNativeLayerRoot() override;
+ layers::NativeLayerRoot* GetNativeLayerRoot() override;
LayoutDeviceIntSize GetClientSize() override;
diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h
@@ -403,7 +403,7 @@ class nsCocoaWindow final : public nsIWidget {
bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override;
void PostRender(mozilla::widget::WidgetRenderingContext* aContext) override;
- RefPtr<mozilla::layers::NativeLayerRoot> GetNativeLayerRoot() override;
+ mozilla::layers::NativeLayerRoot* GetNativeLayerRoot() override;
void UpdateWindowDraggingRegion(
const LayoutDeviceIntRegion& aRegion) override;
diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
@@ -1192,7 +1192,7 @@ void nsCocoaWindow::PostRender(WidgetRenderingContext* aContext)
mCompositingLock.Unlock();
}
-RefPtr<layers::NativeLayerRoot> nsCocoaWindow::GetNativeLayerRoot() {
+layers::NativeLayerRoot* nsCocoaWindow::GetNativeLayerRoot() {
return mNativeLayerRoot;
}
diff --git a/widget/gtk/GtkCompositorWidget.cpp b/widget/gtk/GtkCompositorWidget.cpp
@@ -143,8 +143,7 @@ LayoutDeviceIntRegion GtkCompositorWidget::GetTransparentRegion() {
}
#ifdef MOZ_WAYLAND
-RefPtr<mozilla::layers::NativeLayerRoot>
-GtkCompositorWidget::GetNativeLayerRoot() {
+mozilla::layers::NativeLayerRoot* GtkCompositorWidget::GetNativeLayerRoot() {
if (gfx::gfxVars::UseWebRenderCompositor()) {
if (!mNativeLayerRoot) {
LOG("GtkCompositorWidget::GetNativeLayerRoot [%p] create",
diff --git a/widget/gtk/GtkCompositorWidget.h b/widget/gtk/GtkCompositorWidget.h
@@ -87,7 +87,7 @@ class GtkCompositorWidget : public CompositorWidget,
Window XWindow() const { return mProvider.GetXWindow(); }
#endif
#if defined(MOZ_WAYLAND)
- RefPtr<mozilla::layers::NativeLayerRoot> GetNativeLayerRoot() override;
+ mozilla::layers::NativeLayerRoot* GetNativeLayerRoot() override;
#endif
// PlatformCompositorWidgetDelegate Overrides
diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h
@@ -15,7 +15,6 @@
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
-#include "mozilla/Compiler.h"
#include "mozilla/EventForwards.h"
#include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h"
@@ -46,12 +45,6 @@
#include "mozilla/widget/InitData.h"
#include "nsXULAppAPI.h"
-// GCC needs this to compile RefPtr<NativeLayerRoot> GetNativeLayerRoot(),
-// surprisingly.
-#if MOZ_IS_GCC
-# include "mozilla/layers/NativeLayer.h"
-#endif
-
// Windows specific constant indicating the maximum number of touch points the
// inject api will allow. This also sets the maximum numerical value for touch
// ids we can use when injecting touch points on Windows.
@@ -1362,7 +1355,7 @@ class nsIWidget : public nsSupportsWeakReference {
return true;
}
virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext) {}
- virtual RefPtr<mozilla::layers::NativeLayerRoot> GetNativeLayerRoot() {
+ virtual mozilla::layers::NativeLayerRoot* GetNativeLayerRoot() {
return nullptr;
}
virtual already_AddRefed<DrawTarget> StartRemoteDrawing();
diff --git a/widget/uikit/nsWindow.h b/widget/uikit/nsWindow.h
@@ -111,7 +111,7 @@ class nsWindow final : public nsIWidget {
void* aCallbackData) override;
*/
- RefPtr<mozilla::layers::NativeLayerRoot> GetNativeLayerRoot() override;
+ mozilla::layers::NativeLayerRoot* GetNativeLayerRoot() override;
void HandleMainThreadCATransaction();
diff --git a/widget/uikit/nsWindow.mm b/widget/uikit/nsWindow.mm
@@ -1143,7 +1143,7 @@ int32_t nsWindow::RoundsWidgetCoordinatesTo() {
return 1;
}
-RefPtr<layers::NativeLayerRoot> nsWindow::GetNativeLayerRoot() {
+layers::NativeLayerRoot* nsWindow::GetNativeLayerRoot() {
return mNativeLayerRoot;
}