Files
firefox/gfx/ipc/InProcessCompositorSession.h
Jamie Nicol 8e99051731 Bug 2028516 - Ensure WebRenderLayerManager's mWrChild cannot be null. r=gfx-reviewers,lsalzman
Future patches to make WebRenderLayerManager able to be initialised
asynchronously will be made simpler if we can rely on mWrChild always
being non-null. This patch achieves this by moving the first part of
Initialize(), which creates the WebRenderBridgeChild, to a static
Create() function, which then passes the non-null WebRenderBridgeChild
to the constructor. Some existing but now redundant null checks are
removed.

Unfortunately there is a chicken or egg problem, as
WebRenderLayerManager::Create() requires a pointer to the
CompositorBridgeChild, but the CompositorBridgeChild is created by the
CompositorSession which requires the WebRenderLayerManager in order to
call CompositorBridgeChild::InitForWidget().

To solve this we remove the WebRenderLayerManager argument from
CompositorBridgeChild::InitForWidget(), and instead have the widget
call the function CompositorBridgeChild::CreateLayerManager() to
obtain the layer manager.

Differential Revision: https://phabricator.services.mozilla.com/D291522
2026-04-02 11:49:01 +00:00

51 lines
1.7 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _include_mozilla_gfx_ipc_InProcessCompositorSession_h_
#define _include_mozilla_gfx_ipc_InProcessCompositorSession_h_
#include "CompositorSession.h"
#include "mozilla/gfx/Point.h"
#include "Units.h"
class nsIWidget;
namespace mozilla {
namespace layers {
class CompositorOptions;
// A CompositorSession where both the child and parent CompositorBridge reside
// in the same process.
class InProcessCompositorSession final : public CompositorSession {
public:
static RefPtr<InProcessCompositorSession> Create(
nsIWidget* baseWidget, const LayersId& aRootLayerTreeId,
CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize,
uint32_t aNamespace, uint64_t aInnerWindowId);
CompositorBridgeParent* GetInProcessBridge() const override;
void SetContentController(GeckoContentController* aController) override;
nsIWidget* GetWidget() const;
RefPtr<IAPZCTreeManager> GetAPZCTreeManager() const override;
void Shutdown() override;
void NotifySessionLost();
private:
InProcessCompositorSession(nsIWidget* aWidget,
widget::CompositorWidget* aCompositorWidget,
CompositorBridgeChild* aChild,
CompositorBridgeParent* aParent);
private:
RefPtr<CompositorBridgeParent> mCompositorBridgeParent;
RefPtr<CompositorWidget> mCompositorWidget;
};
} // namespace layers
} // namespace mozilla
#endif // _include_mozilla_gfx_ipc_InProcessCompositorSession_h_