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: */
|
2016-06-11 05:27:24 +03:00
|
|
|
/* 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_gfx_ipc_GPUParent_h__
|
|
|
|
#define _include_gfx_ipc_GPUParent_h__
|
|
|
|
|
2016-07-19 21:56:06 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2016-06-11 05:27:24 +03:00
|
|
|
#include "mozilla/gfx/PGPUParent.h"
|
2020-09-18 14:07:13 +03:00
|
|
|
#include "mozilla/media/MediaUtils.h"
|
2016-06-11 05:27:24 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
2017-01-03 23:13:36 +03:00
|
|
|
|
|
|
|
class TimeStamp;
|
2017-05-30 22:06:14 +03:00
|
|
|
class ChildProfilerController;
|
2017-01-03 23:13:36 +03:00
|
|
|
|
2016-06-11 05:27:24 +03:00
|
|
|
namespace gfx {
|
|
|
|
|
2016-07-19 21:56:06 +03:00
|
|
|
class VsyncBridgeParent;
|
|
|
|
|
2016-06-11 05:27:24 +03:00
|
|
|
class GPUParent final : public PGPUParent {
|
|
|
|
public:
|
|
|
|
GPUParent();
|
|
|
|
~GPUParent();
|
|
|
|
|
2016-09-22 08:38:44 +03:00
|
|
|
static GPUParent* GetSingleton();
|
|
|
|
|
2020-09-18 14:07:13 +03:00
|
|
|
AsyncBlockers& AsyncShutdownService() { return mShutdownBlockers; }
|
|
|
|
|
2018-09-15 02:25:38 +03:00
|
|
|
// Gets the name of the GPU process, in the format expected by about:memory.
|
|
|
|
// There must be a GPU process active, and the caller must be either in that
|
|
|
|
// process or the parent process.
|
|
|
|
static void GetGPUProcessName(nsACString& aStr);
|
|
|
|
|
2021-02-25 18:38:45 +03:00
|
|
|
// Check for memory pressure and notify the parent process if necessary.
|
2021-03-30 01:43:28 +03:00
|
|
|
static bool MaybeFlushMemory();
|
2021-02-25 18:38:45 +03:00
|
|
|
|
2016-06-11 05:27:24 +03:00
|
|
|
bool Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
2021-06-22 21:17:23 +03:00
|
|
|
mozilla::ipc::ScopedPort aPort);
|
2016-11-06 22:01:52 +03:00
|
|
|
void NotifyDeviceReset();
|
2016-06-11 05:27:24 +03:00
|
|
|
|
2019-05-26 17:31:27 +03:00
|
|
|
mozilla::ipc::IPCResult RecvInit(nsTArray<GfxVarUpdate>&& vars,
|
2019-02-06 18:58:43 +03:00
|
|
|
const DevicePrefs& devicePrefs,
|
2020-08-08 00:31:53 +03:00
|
|
|
nsTArray<LayerTreeIdMapping>&& mappings,
|
|
|
|
nsTArray<GfxInfoFeatureStatus>&& features);
|
2017-06-14 18:39:59 +03:00
|
|
|
mozilla::ipc::IPCResult RecvInitCompositorManager(
|
2019-02-06 18:58:43 +03:00
|
|
|
Endpoint<PCompositorManagerParent>&& aEndpoint);
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult RecvInitVsyncBridge(
|
2019-02-06 18:58:43 +03:00
|
|
|
Endpoint<PVsyncBridgeParent>&& aVsyncEndpoint);
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult RecvInitImageBridge(
|
2019-02-06 18:58:43 +03:00
|
|
|
Endpoint<PImageBridgeParent>&& aEndpoint);
|
2019-11-04 06:41:57 +03:00
|
|
|
mozilla::ipc::IPCResult RecvInitVideoBridge(
|
|
|
|
Endpoint<PVideoBridgeParent>&& aEndpoint);
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult RecvInitVRManager(
|
2019-02-06 18:58:43 +03:00
|
|
|
Endpoint<PVRManagerParent>&& aEndpoint);
|
|
|
|
mozilla::ipc::IPCResult RecvInitVR(Endpoint<PVRGPUChild>&& aVRGPUChild);
|
2018-03-25 02:06:01 +03:00
|
|
|
mozilla::ipc::IPCResult RecvInitUiCompositorController(
|
|
|
|
const LayersId& aRootLayerTreeId,
|
2019-02-06 18:58:43 +03:00
|
|
|
Endpoint<PUiCompositorControllerParent>&& aEndpoint);
|
Bug 1340301 - Ensure APZ functions are called from correct threads on Android with GPU process. r=botond
On Android the APZ controller thread is the android UI thread, rather
than the Gecko main thread as on other platforms. There some places
where the main thread requires to call IAPZCTreeManager functions that
must run on the controller thread. Currently we use the function
DispatchToControllerThread() prior to calling various IAPZCTreeManager
APIs to achieve this.
This works just fine for now, as there is no GPU process on
Android. However, once we do add a GPU process we will encounter
issues:
Firstly, there will now be a cross-process APZInputBridge rather than
using an in-process APZCTreeManager. The PAPZInputBridge protocol is
managed by PGPU, and therefore must run on the main thread in the
parent process. The input we require to send over the bridge, however,
originates from the UI thread.
To solve this we can convert PAPZInputBridge to a top-level protocol,
and bind it to the UI thread on Android. We can then send input
directly from the UI thread without issues.
Secondly, the PAPZCTreeManager protocol must also run from the main
thread in the parent process, as it is managed by
PCompositorBridge. Unlike PAPZInputBridge we cannot convert
PAPZCTreeManager in to a top level protocol, as it relies on the
ordering guarantees with PCompositorBridge.
We must therefore ensure that we only dispatch IAPZCTreeManager calls
to the controller thread when using an in-process
APZCTreeManager. Out-of-process calls, on the other hand, must be
dispatched to the main thread where we can send IPDL commands from. To
do this, we move the dispatch logic away from the callsites of
IAPZCTreeManager APIs, and in to the APZCTreeManager and
APZCTreeManagerChild implementations themselves.
Differential Revision: https://phabricator.services.mozilla.com/D131120
2021-11-20 12:49:14 +03:00
|
|
|
mozilla::ipc::IPCResult RecvInitAPZInputBridge(
|
|
|
|
const LayersId& aRootLayerTreeId,
|
|
|
|
Endpoint<PAPZInputBridgeParent>&& aEndpoint);
|
2017-05-30 22:06:14 +03:00
|
|
|
mozilla::ipc::IPCResult RecvInitProfiler(
|
2019-02-06 18:58:43 +03:00
|
|
|
Endpoint<PProfilerChild>&& aEndpoint);
|
|
|
|
mozilla::ipc::IPCResult RecvUpdateVar(const GfxVarUpdate& pref);
|
2019-05-25 13:12:51 +03:00
|
|
|
mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref);
|
2017-06-14 18:39:59 +03:00
|
|
|
mozilla::ipc::IPCResult RecvNewContentCompositorManager(
|
2019-02-06 18:58:43 +03:00
|
|
|
Endpoint<PCompositorManagerParent>&& aEndpoint);
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult RecvNewContentImageBridge(
|
2019-02-06 18:58:43 +03:00
|
|
|
Endpoint<PImageBridgeParent>&& aEndpoint);
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult RecvNewContentVRManager(
|
2019-02-06 18:58:43 +03:00
|
|
|
Endpoint<PVRManagerParent>&& aEndpoint);
|
2019-06-11 05:01:34 +03:00
|
|
|
mozilla::ipc::IPCResult RecvNewContentRemoteDecoderManager(
|
|
|
|
Endpoint<PRemoteDecoderManagerParent>&& aEndpoint);
|
2019-02-06 18:58:43 +03:00
|
|
|
mozilla::ipc::IPCResult RecvGetDeviceStatus(GPUDeviceData* aOutStatus);
|
|
|
|
mozilla::ipc::IPCResult RecvSimulateDeviceReset(GPUDeviceData* aOutStatus);
|
2017-04-04 01:13:38 +03:00
|
|
|
mozilla::ipc::IPCResult RecvAddLayerTreeIdMapping(
|
2019-02-06 18:58:43 +03:00
|
|
|
const LayerTreeIdMapping& aMapping);
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult RecvRemoveLayerTreeIdMapping(
|
2019-02-06 18:58:43 +03:00
|
|
|
const LayerTreeIdMapping& aMapping);
|
|
|
|
mozilla::ipc::IPCResult RecvNotifyGpuObservers(const nsCString& aTopic);
|
2017-01-27 03:35:54 +03:00
|
|
|
mozilla::ipc::IPCResult RecvRequestMemoryReport(
|
|
|
|
const uint32_t& generation, const bool& anonymize,
|
2019-03-01 00:20:40 +03:00
|
|
|
const bool& minimizeMemoryUsage,
|
2020-08-03 21:29:45 +03:00
|
|
|
const Maybe<ipc::FileDescriptor>& DMDFile,
|
|
|
|
const RequestMemoryReportResolver& aResolver);
|
2019-02-06 18:58:43 +03:00
|
|
|
mozilla::ipc::IPCResult RecvShutdownVR();
|
2016-06-11 05:27:24 +03:00
|
|
|
|
2019-05-21 22:01:31 +03:00
|
|
|
mozilla::ipc::IPCResult RecvUpdatePerfStatsCollectionMask(
|
|
|
|
const uint64_t& aMask);
|
|
|
|
mozilla::ipc::IPCResult RecvCollectPerfStatsJSON(
|
|
|
|
CollectPerfStatsJSONResolver&& aResolver);
|
|
|
|
|
2019-10-14 18:26:47 +03:00
|
|
|
#if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
|
|
|
|
mozilla::ipc::IPCResult RecvInitSandboxTesting(
|
|
|
|
Endpoint<PSandboxTestingChild>&& aEndpoint);
|
|
|
|
#endif
|
|
|
|
|
2016-06-11 05:27:24 +03:00
|
|
|
void ActorDestroy(ActorDestroyReason aWhy) override;
|
2016-07-19 21:56:06 +03:00
|
|
|
|
|
|
|
private:
|
2017-01-03 23:13:36 +03:00
|
|
|
const TimeStamp mLaunchTime;
|
2016-07-19 21:56:06 +03:00
|
|
|
RefPtr<VsyncBridgeParent> mVsyncBridge;
|
2017-05-30 22:06:14 +03:00
|
|
|
RefPtr<ChildProfilerController> mProfilerController;
|
2020-09-18 14:07:13 +03:00
|
|
|
AsyncBlockers mShutdownBlockers;
|
2016-06-11 05:27:24 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // _include_gfx_ipc_GPUParent_h__
|