From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- gfx/layers/ipc/CompositorManagerChild.h | 125 ++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 gfx/layers/ipc/CompositorManagerChild.h (limited to 'gfx/layers/ipc/CompositorManagerChild.h') diff --git a/gfx/layers/ipc/CompositorManagerChild.h b/gfx/layers/ipc/CompositorManagerChild.h new file mode 100644 index 0000000000..072b0d028e --- /dev/null +++ b/gfx/layers/ipc/CompositorManagerChild.h @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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 MOZILLA_GFX_COMPOSITORMANAGERCHILD_H +#define MOZILLA_GFX_COMPOSITORMANAGERCHILD_H + +#include // for size_t +#include // for uint32_t, uint64_t +#include "mozilla/Atomics.h" +#include "mozilla/Attributes.h" // for override +#include "mozilla/RefPtr.h" // for already_AddRefed +#include "mozilla/StaticPtr.h" // for StaticRefPtr +#include "mozilla/layers/CompositableForwarder.h" // for FwdTransactionCounter +#include "mozilla/layers/PCompositorManagerChild.h" + +namespace mozilla { +namespace layers { + +class CompositorBridgeChild; +class CompositorManagerParent; +class WebRenderLayerManager; + +class CompositorManagerChild : public PCompositorManagerChild { + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorManagerChild, override) + + public: + static bool IsInitialized(uint64_t aProcessToken); + static void InitSameProcess(uint32_t aNamespace, uint64_t aProcessToken); + static bool Init(Endpoint&& aEndpoint, + uint32_t aNamespace, uint64_t aProcessToken = 0); + static void Shutdown(); + static void OnGPUProcessLost(uint64_t aProcessToken); + + static bool CreateContentCompositorBridge(uint32_t aNamespace); + + static already_AddRefed CreateWidgetCompositorBridge( + uint64_t aProcessToken, WebRenderLayerManager* aLayerManager, + uint32_t aNamespace, CSSToLayoutDeviceScale aScale, + const CompositorOptions& aOptions, bool aUseExternalSurfaceSize, + const gfx::IntSize& aSurfaceSize, uint64_t aInnerWindowId); + + static already_AddRefed + CreateSameProcessWidgetCompositorBridge(WebRenderLayerManager* aLayerManager, + uint32_t aNamespace); + + static CompositorManagerChild* GetInstance() { + MOZ_ASSERT(NS_IsMainThread()); + return sInstance; + } + + // Threadsafe way to get the compositor process ID. + static base::ProcessId GetOtherPid() { return sOtherPid; } + + bool CanSend() const { + MOZ_ASSERT(NS_IsMainThread()); + return mCanSend; + } + + bool SameProcess() const { + MOZ_ASSERT(NS_IsMainThread()); + return mSameProcess; + } + + uint32_t GetNextResourceId() { + MOZ_ASSERT(NS_IsMainThread()); + return ++mResourceId; + } + + uint32_t GetNamespace() const { return mNamespace; } + + bool OwnsExternalImageId(const wr::ExternalImageId& aId) const { + return mNamespace == static_cast(wr::AsUint64(aId) >> 32); + } + + wr::ExternalImageId GetNextExternalImageId() { + uint64_t id = GetNextResourceId(); + MOZ_RELEASE_ASSERT(id != 0); + id |= (static_cast(mNamespace) << 32); + return wr::ToExternalImageId(id); + } + + void ActorDestroy(ActorDestroyReason aReason) override; + + void HandleFatalError(const char* aMsg) override; + + void ProcessingError(Result aCode, const char* aReason) override; + + bool ShouldContinueFromReplyTimeout() override; + + mozilla::ipc::IPCResult RecvNotifyWebRenderError( + const WebRenderError&& aError); + + FwdTransactionCounter& GetFwdTransactionCounter() { + return mFwdTransactionCounter; + } + + private: + static StaticRefPtr sInstance; + static Atomic sOtherPid; + + CompositorManagerChild(CompositorManagerParent* aParent, + uint64_t aProcessToken, uint32_t aNamespace); + + CompositorManagerChild(Endpoint&& aEndpoint, + uint64_t aProcessToken, uint32_t aNamespace); + + virtual ~CompositorManagerChild() = default; + + void SetReplyTimeout(); + + uint64_t mProcessToken; + uint32_t mNamespace; + uint32_t mResourceId; + bool mCanSend; + bool mSameProcess; + FwdTransactionCounter mFwdTransactionCounter; +}; + +} // namespace layers +} // namespace mozilla + +#endif -- cgit v1.2.3