2017-10-28 02:10:06 +03:00
|
|
|
/* -*- 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
|
2017-06-14 18:39:59 +03:00
|
|
|
* 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_COMPOSITORMANAGERPARENT_H
|
|
|
|
#define MOZILLA_GFX_COMPOSITORMANAGERPARENT_H
|
|
|
|
|
|
|
|
#include <stdint.h> // for uint32_t
|
|
|
|
#include "mozilla/Attributes.h" // for override
|
|
|
|
#include "mozilla/StaticPtr.h" // for StaticRefPtr
|
|
|
|
#include "mozilla/StaticMutex.h" // for StaticMutex
|
|
|
|
#include "mozilla/RefPtr.h" // for already_AddRefed
|
|
|
|
#include "mozilla/layers/PCompositorManagerParent.h"
|
|
|
|
#include "nsTArray.h" // for AutoTArray
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2017-06-14 18:39:59 +03:00
|
|
|
class CompositorBridgeParent;
|
2017-11-01 20:34:43 +03:00
|
|
|
class CompositorThreadHolder;
|
2017-06-14 18:39:59 +03:00
|
|
|
|
2017-09-18 23:13:03 +03:00
|
|
|
#ifndef DEBUG
|
|
|
|
#define COMPOSITOR_MANAGER_PARENT_EXPLICIT_SHUTDOWN
|
|
|
|
#endif
|
|
|
|
|
2017-06-14 18:39:59 +03:00
|
|
|
class CompositorManagerParent final : public PCompositorManagerParent
|
|
|
|
{
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorManagerParent)
|
|
|
|
|
|
|
|
public:
|
|
|
|
static already_AddRefed<CompositorManagerParent> CreateSameProcess();
|
|
|
|
static void Create(Endpoint<PCompositorManagerParent>&& aEndpoint);
|
2017-09-18 23:13:03 +03:00
|
|
|
static void Shutdown();
|
2017-06-14 18:39:59 +03:00
|
|
|
|
2017-06-14 18:39:59 +03:00
|
|
|
static already_AddRefed<CompositorBridgeParent>
|
|
|
|
CreateSameProcessWidgetCompositorBridge(CSSToLayoutDeviceScale aScale,
|
|
|
|
const CompositorOptions& aOptions,
|
|
|
|
bool aUseExternalSurfaceSize,
|
|
|
|
const gfx::IntSize& aSurfaceSize);
|
|
|
|
|
2017-10-30 20:10:29 +03:00
|
|
|
mozilla::ipc::IPCResult RecvAddSharedSurface(const wr::ExternalImageId& aId,
|
|
|
|
const SurfaceDescriptorShared& aDesc) override;
|
|
|
|
mozilla::ipc::IPCResult RecvRemoveSharedSurface(const wr::ExternalImageId& aId) override;
|
2018-09-25 16:13:51 +03:00
|
|
|
mozilla::ipc::IPCResult RecvReportSharedSurfacesMemory(ReportSharedSurfacesMemoryResolver&&) override;
|
2017-10-30 20:10:29 +03:00
|
|
|
|
2018-08-20 16:23:54 +03:00
|
|
|
virtual mozilla::ipc::IPCResult RecvNotifyMemoryPressure() override;
|
|
|
|
|
2018-09-08 02:03:13 +03:00
|
|
|
virtual mozilla::ipc::IPCResult RecvReportMemory(ReportMemoryResolver&&) override;
|
|
|
|
|
2017-09-26 20:21:52 +03:00
|
|
|
void BindComplete();
|
2017-06-14 18:39:59 +03:00
|
|
|
void ActorDestroy(ActorDestroyReason aReason) override;
|
|
|
|
|
2017-06-14 18:40:00 +03:00
|
|
|
bool DeallocPCompositorBridgeParent(PCompositorBridgeParent* aActor) override;
|
|
|
|
PCompositorBridgeParent* AllocPCompositorBridgeParent(const CompositorBridgeOptions& aOpt) override;
|
2017-06-14 18:39:59 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
static StaticRefPtr<CompositorManagerParent> sInstance;
|
|
|
|
static StaticMutex sMutex;
|
|
|
|
|
2017-09-18 23:13:03 +03:00
|
|
|
#ifdef COMPOSITOR_MANAGER_PARENT_EXPLICIT_SHUTDOWN
|
|
|
|
static StaticAutoPtr<nsTArray<CompositorManagerParent*>> sActiveActors;
|
|
|
|
static void ShutdownInternal();
|
|
|
|
#endif
|
|
|
|
|
2017-06-14 18:39:59 +03:00
|
|
|
CompositorManagerParent();
|
|
|
|
~CompositorManagerParent() override;
|
|
|
|
|
|
|
|
void Bind(Endpoint<PCompositorManagerParent>&& aEndpoint);
|
|
|
|
|
|
|
|
void DeallocPCompositorManagerParent() override;
|
|
|
|
|
2017-08-17 16:24:07 +03:00
|
|
|
void DeferredDestroy();
|
|
|
|
|
2017-11-01 20:34:43 +03:00
|
|
|
RefPtr<CompositorThreadHolder> mCompositorThreadHolder;
|
2017-06-14 18:40:00 +03:00
|
|
|
|
|
|
|
AutoTArray<RefPtr<CompositorBridgeParent>, 1> mPendingCompositorBridges;
|
2017-06-14 18:39:59 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|