2016-06-11 05:27:24 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=99: */
|
|
|
|
/* 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/. */
|
|
|
|
#include "GPUParent.h"
|
|
|
|
#include "gfxConfig.h"
|
2016-07-20 07:11:44 +03:00
|
|
|
#include "gfxPlatform.h"
|
2016-06-27 09:33:20 +03:00
|
|
|
#include "gfxPrefs.h"
|
2016-06-11 05:27:24 +03:00
|
|
|
#include "GPUProcessHost.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
2016-08-04 21:33:42 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2016-06-11 05:27:24 +03:00
|
|
|
#include "mozilla/ipc/ProcessChild.h"
|
2016-07-18 07:24:28 +03:00
|
|
|
#include "mozilla/layers/CompositorBridgeParent.h"
|
|
|
|
#include "mozilla/layers/CompositorThread.h"
|
2016-07-20 10:19:27 +03:00
|
|
|
#include "mozilla/layers/ImageBridgeParent.h"
|
2016-07-21 10:14:59 +03:00
|
|
|
#include "VRManager.h"
|
|
|
|
#include "VRManagerParent.h"
|
|
|
|
#include "VsyncBridgeParent.h"
|
2016-06-11 05:27:24 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
using namespace ipc;
|
2016-07-18 07:24:28 +03:00
|
|
|
using namespace layers;
|
2016-06-11 05:27:24 +03:00
|
|
|
|
|
|
|
GPUParent::GPUParent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GPUParent::~GPUParent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GPUParent::Init(base::ProcessId aParentPid,
|
|
|
|
MessageLoop* aIOLoop,
|
|
|
|
IPC::Channel* aChannel)
|
|
|
|
{
|
|
|
|
if (NS_WARN_IF(!Open(aChannel, aParentPid, aIOLoop))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-27 09:33:20 +03:00
|
|
|
// Ensure gfxPrefs are initialized.
|
|
|
|
gfxPrefs::GetSingleton();
|
2016-08-13 22:25:18 +03:00
|
|
|
gfxConfig::Init();
|
2016-08-04 21:33:42 +03:00
|
|
|
gfxVars::Initialize();
|
2016-07-18 07:24:28 +03:00
|
|
|
CompositorThreadHolder::Start();
|
2016-07-21 10:14:59 +03:00
|
|
|
VRManager::ManagerInit();
|
2016-07-20 07:11:44 +03:00
|
|
|
gfxPlatform::InitNullMetadata();
|
2016-06-27 09:33:20 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-08-04 21:33:42 +03:00
|
|
|
GPUParent::RecvInit(nsTArray<GfxPrefSetting>&& prefs,
|
|
|
|
nsTArray<GfxVarUpdate>&& vars)
|
2016-06-27 09:33:20 +03:00
|
|
|
{
|
2016-07-20 23:55:07 +03:00
|
|
|
const nsTArray<gfxPrefs::Pref*>& globalPrefs = gfxPrefs::all();
|
|
|
|
for (auto& setting : prefs) {
|
|
|
|
gfxPrefs::Pref* pref = globalPrefs[setting.index()];
|
2016-06-27 09:33:20 +03:00
|
|
|
pref->SetCachedValue(setting.value());
|
|
|
|
}
|
2016-08-04 21:33:42 +03:00
|
|
|
for (const auto& var : vars) {
|
|
|
|
gfxVars::ApplyUpdate(var);
|
|
|
|
}
|
2016-07-19 21:56:06 +03:00
|
|
|
return true;
|
|
|
|
}
|
2016-06-27 09:33:20 +03:00
|
|
|
|
2016-07-19 21:56:06 +03:00
|
|
|
bool
|
|
|
|
GPUParent::RecvInitVsyncBridge(Endpoint<PVsyncBridgeParent>&& aVsyncEndpoint)
|
|
|
|
{
|
|
|
|
VsyncBridgeParent::Start(Move(aVsyncEndpoint));
|
2016-06-11 05:27:24 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-20 10:19:27 +03:00
|
|
|
bool
|
|
|
|
GPUParent::RecvInitImageBridge(Endpoint<PImageBridgeParent>&& aEndpoint)
|
|
|
|
{
|
|
|
|
ImageBridgeParent::CreateForGPUProcess(Move(aEndpoint));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-21 10:14:59 +03:00
|
|
|
bool
|
|
|
|
GPUParent::RecvInitVRManager(Endpoint<PVRManagerParent>&& aEndpoint)
|
|
|
|
{
|
|
|
|
VRManagerParent::CreateForGPUProcess(Move(aEndpoint));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-11 05:27:24 +03:00
|
|
|
bool
|
2016-06-27 09:33:20 +03:00
|
|
|
GPUParent::RecvUpdatePref(const GfxPrefSetting& setting)
|
2016-06-11 05:27:24 +03:00
|
|
|
{
|
2016-06-27 09:33:20 +03:00
|
|
|
gfxPrefs::Pref* pref = gfxPrefs::all()[setting.index()];
|
|
|
|
pref->SetCachedValue(setting.value());
|
2016-06-11 05:27:24 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-08-04 21:33:42 +03:00
|
|
|
bool
|
|
|
|
GPUParent::RecvUpdateVar(const GfxVarUpdate& aUpdate)
|
|
|
|
{
|
|
|
|
gfxVars::ApplyUpdate(aUpdate);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-18 07:24:28 +03:00
|
|
|
static void
|
|
|
|
OpenParent(RefPtr<CompositorBridgeParent> aParent,
|
|
|
|
Endpoint<PCompositorBridgeParent>&& aEndpoint)
|
|
|
|
{
|
|
|
|
if (!aParent->Bind(Move(aEndpoint))) {
|
|
|
|
MOZ_CRASH("Failed to bind compositor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GPUParent::RecvNewWidgetCompositor(Endpoint<layers::PCompositorBridgeParent>&& aEndpoint,
|
|
|
|
const CSSToLayoutDeviceScale& aScale,
|
2016-07-26 11:57:11 +03:00
|
|
|
const TimeDuration& aVsyncRate,
|
2016-07-18 07:24:28 +03:00
|
|
|
const bool& aUseExternalSurfaceSize,
|
|
|
|
const IntSize& aSurfaceSize)
|
|
|
|
{
|
|
|
|
RefPtr<CompositorBridgeParent> cbp =
|
2016-07-26 11:57:11 +03:00
|
|
|
new CompositorBridgeParent(aScale, aVsyncRate, aUseExternalSurfaceSize, aSurfaceSize);
|
2016-07-18 07:24:28 +03:00
|
|
|
|
|
|
|
MessageLoop* loop = CompositorThreadHolder::Loop();
|
|
|
|
loop->PostTask(NewRunnableFunction(OpenParent, cbp, Move(aEndpoint)));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-18 07:24:28 +03:00
|
|
|
bool
|
|
|
|
GPUParent::RecvNewContentCompositorBridge(Endpoint<PCompositorBridgeParent>&& aEndpoint)
|
|
|
|
{
|
|
|
|
return CompositorBridgeParent::CreateForContent(Move(aEndpoint));
|
|
|
|
}
|
|
|
|
|
2016-07-20 10:19:27 +03:00
|
|
|
bool
|
|
|
|
GPUParent::RecvNewContentImageBridge(Endpoint<PImageBridgeParent>&& aEndpoint)
|
|
|
|
{
|
|
|
|
return ImageBridgeParent::CreateForContent(Move(aEndpoint));
|
|
|
|
}
|
|
|
|
|
2016-07-21 10:14:59 +03:00
|
|
|
bool
|
|
|
|
GPUParent::RecvNewContentVRManager(Endpoint<PVRManagerParent>&& aEndpoint)
|
|
|
|
{
|
|
|
|
return VRManagerParent::CreateForContent(Move(aEndpoint));
|
|
|
|
}
|
|
|
|
|
2016-06-11 05:27:24 +03:00
|
|
|
void
|
|
|
|
GPUParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
if (AbnormalShutdown == aWhy) {
|
|
|
|
NS_WARNING("Shutting down GPU process early due to a crash!");
|
|
|
|
ProcessChild::QuickExit();
|
|
|
|
}
|
|
|
|
|
2016-06-11 05:37:03 +03:00
|
|
|
#ifndef NS_FREE_PERMANENT_DATA
|
|
|
|
// No point in going through XPCOM shutdown because we don't keep persistent
|
|
|
|
// state. Currently we quick-exit in RecvBeginShutdown so this should be
|
|
|
|
// unreachable.
|
|
|
|
ProcessChild::QuickExit();
|
|
|
|
#endif
|
2016-07-18 07:24:28 +03:00
|
|
|
|
2016-07-19 21:56:06 +03:00
|
|
|
if (mVsyncBridge) {
|
|
|
|
mVsyncBridge->Shutdown();
|
|
|
|
}
|
2016-07-18 07:24:28 +03:00
|
|
|
CompositorThreadHolder::Shutdown();
|
2016-08-13 22:25:18 +03:00
|
|
|
gfxVars::Shutdown();
|
|
|
|
gfxConfig::Shutdown();
|
|
|
|
gfxPrefs::DestroySingleton();
|
2016-07-18 07:24:28 +03:00
|
|
|
XRE_ShutdownChildProcess();
|
2016-06-11 05:27:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|