Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)

This commit is contained in:
David Anderson 2016-05-23 00:27:01 -07:00
Родитель ef7fdfc03a
Коммит ecf249bd9a
7 изменённых файлов: 145 добавлений и 15 удалений

Просмотреть файл

@ -33,12 +33,12 @@ private:
};
already_AddRefed<CompositorSession>
CompositorSession::CreateTopLevel(widget::CompositorWidgetProxy* aWidgetProxy,
ClientLayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
bool aUseExternalSurfaceSize,
int aSurfaceWidth, int aSurfaceHeight)
CompositorSession::CreateInProcess(widget::CompositorWidgetProxy* aWidgetProxy,
ClientLayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
bool aUseExternalSurfaceSize,
int aSurfaceWidth, int aSurfaceHeight)
{
RefPtr<InProcessCompositorSession> session = new InProcessCompositorSession(
aWidgetProxy,

Просмотреть файл

@ -14,6 +14,9 @@ namespace mozilla {
namespace widget {
class CompositorWidgetProxy;
} // namespace widget
namespace gfx {
class GPUProcessManager;
} // namespace gfx
namespace layers {
class GeckoContentController;
@ -26,17 +29,11 @@ class ClientLayerManager;
// or not it's in-process or out-of-process.
class CompositorSession
{
friend class gfx::GPUProcessManager;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorSession)
static already_AddRefed<CompositorSession> CreateTopLevel(
widget::CompositorWidgetProxy* aWidgetProxy,
ClientLayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
bool aUseExternalSurfaceSize,
int aSurfaceWidth, int aSurfaceHeight);
virtual void Shutdown() = 0;
// This returns a CompositorBridgeParent if the compositor resides in the same process.
@ -58,6 +55,14 @@ protected:
CompositorSession();
virtual ~CompositorSession();
static already_AddRefed<CompositorSession> CreateInProcess(
widget::CompositorWidgetProxy* aWidgetProxy,
ClientLayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
bool aUseExternalSurfaceSize,
int aSurfaceWidth, int aSurfaceHeight);
protected:
RefPtr<CompositorBridgeChild> mCompositorBridgeChild;

Просмотреть файл

@ -0,0 +1,64 @@
/* -*- 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 "GPUProcessManager.h"
#include "mozilla/layers/CompositorSession.h"
#include "mozilla/StaticPtr.h"
namespace mozilla {
namespace gfx {
using namespace mozilla::layers;
static StaticAutoPtr<GPUProcessManager> sSingleton;
GPUProcessManager*
GPUProcessManager::Get()
{
MOZ_ASSERT(sSingleton);
return sSingleton;
}
void
GPUProcessManager::Initialize()
{
sSingleton = new GPUProcessManager();
}
void
GPUProcessManager::Shutdown()
{
sSingleton = nullptr;
}
GPUProcessManager::GPUProcessManager()
{
}
GPUProcessManager::~GPUProcessManager()
{
}
already_AddRefed<CompositorSession>
GPUProcessManager::CreateTopLevelCompositor(widget::CompositorWidgetProxy* aProxy,
ClientLayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
bool aUseExternalSurfaceSize,
int aSurfaceWidth,
int aSurfaceHeight)
{
return CompositorSession::CreateInProcess(
aProxy,
aLayerManager,
aScale,
aUseAPZ,
aUseExternalSurfaceSize,
aSurfaceWidth,
aSurfaceHeight);
}
} // namespace gfx
} // namespace mozilla

Просмотреть файл

@ -0,0 +1,52 @@
/* -*- 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/. */
#ifndef _include_mozilla_gfx_ipc_GPUProcessManager_h_
#define _include_mozilla_gfx_ipc_GPUProcessManager_h_
#include "base/basictypes.h"
#include "Units.h"
namespace mozilla {
namespace layers {
class CompositorSession;
class ClientLayerManager;
} // namespace layers
namespace widget {
class CompositorWidgetProxy;
} // namespace widget
namespace gfx {
// The GPUProcessManager is a singleton responsible for creating GPU-bound
// objects that may live in another process. Currently, it provides access
// to the compositor via CompositorBridgeParent.
class GPUProcessManager final
{
public:
static void Initialize();
static void Shutdown();
static GPUProcessManager* Get();
~GPUProcessManager();
already_AddRefed<layers::CompositorSession> CreateTopLevelCompositor(
widget::CompositorWidgetProxy* aProxy,
layers::ClientLayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
bool aUseExternalSurfaceSize,
int aSurfaceWidth,
int aSurfaceHeight);
private:
GPUProcessManager();
DISALLOW_COPY_AND_ASSIGN(GPUProcessManager);
};
} // namespace gfx
} // namespace mozilla
#endif // _include_mozilla_gfx_ipc_GPUProcessManager_h_

Просмотреть файл

@ -10,6 +10,7 @@ EXPORTS.mozilla += [
]
EXPORTS.mozilla.gfx += [
'GPUProcessManager.h',
'SharedDIB.h',
]
@ -30,6 +31,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
UNIFIED_SOURCES += [
'CompositorSession.cpp',
'D3DMessageUtils.cpp',
'GPUProcessManager.cpp',
'SharedDIB.cpp',
]

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/SharedBufferManagerChild.h"
#include "mozilla/layers/ISurfaceAllocator.h" // for GfxMemoryImageReporter
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TimeStamp.h"
@ -591,6 +592,8 @@ gfxPlatform::Init()
gfxPrefs::GetSingleton();
MediaPrefs::GetSingleton();
GPUProcessManager::Initialize();
auto fwd = new CrashStatsLogForwarder("GraphicsCriticalError");
fwd->SetCircularBufferSize(gfxPrefs::GfxLoggingCrashLength());
@ -839,6 +842,8 @@ gfxPlatform::Shutdown()
GLContextProviderEGL::Shutdown();
#endif
GPUProcessManager::Shutdown();
// This is a bit iffy - we're assuming that we were the ones that set the
// log forwarder in the Factory, so that it's our responsibility to
// delete it.

Просмотреть файл

@ -58,6 +58,7 @@
#include "mozilla/layers/APZCCallbackHelper.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/Move.h"
#include "mozilla/Services.h"
#include "mozilla/Snprintf.h"
@ -1284,7 +1285,8 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
RefPtr<ClientLayerManager> lm = new ClientLayerManager(this);
mCompositorSession = CompositorSession::CreateTopLevel(
gfx::GPUProcessManager* gpu = gfx::GPUProcessManager::Get();
mCompositorSession = gpu->CreateTopLevelCompositor(
mCompositorWidgetProxy,
lm,
GetDefaultScale(),