gecko-dev/gfx/ipc/GPUChild.cpp

76 строки
1.7 KiB
C++

/* -*- 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 "GPUChild.h"
#include "gfxPrefs.h"
#include "GPUProcessHost.h"
namespace mozilla {
namespace gfx {
GPUChild::GPUChild(GPUProcessHost* aHost)
: mHost(aHost)
{
MOZ_COUNT_CTOR(GPUChild);
}
GPUChild::~GPUChild()
{
MOZ_COUNT_DTOR(GPUChild);
}
void
GPUChild::Init()
{
// Build a list of prefs the GPU process will need. Note that because we
// limit the GPU process to prefs contained in gfxPrefs, we can simplify
// the message in two ways: one, we only need to send its index in gfxPrefs
// rather than its name, and two, we only need to send prefs that don't
// have their default value.
nsTArray<GfxPrefSetting> prefs;
for (auto pref : gfxPrefs::all()) {
if (pref->HasDefaultValue()) {
return;
}
GfxPrefValue value;
pref->GetCachedValue(&value);
prefs.AppendElement(GfxPrefSetting(pref->Index(), value));
}
SendInit(prefs);
}
void
GPUChild::ActorDestroy(ActorDestroyReason aWhy)
{
mHost->OnChannelClosed();
}
class DeferredDeleteGPUChild : public Runnable
{
public:
explicit DeferredDeleteGPUChild(UniquePtr<GPUChild>&& aChild)
: mChild(Move(aChild))
{
}
NS_IMETHODIMP Run() override {
return NS_OK;
}
private:
UniquePtr<GPUChild> mChild;
};
/* static */ void
GPUChild::Destroy(UniquePtr<GPUChild>&& aChild)
{
NS_DispatchToMainThread(new DeferredDeleteGPUChild(Move(aChild)));
}
} // namespace gfx
} // namespace mozilla