2016-05-23 07:27:01 +00: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/. */
|
|
|
|
#ifndef _include_mozilla_gfx_ipc_GPUProcessManager_h_
|
|
|
|
#define _include_mozilla_gfx_ipc_GPUProcessManager_h_
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
2016-05-23 07:28:51 +00:00
|
|
|
#include "base/process.h"
|
2016-05-23 07:27:01 +00:00
|
|
|
#include "Units.h"
|
2016-05-23 07:28:51 +00:00
|
|
|
#include "mozilla/dom/ipc/IdType.h"
|
2016-06-11 02:27:24 +00:00
|
|
|
#include "mozilla/gfx/GPUProcessHost.h"
|
2016-06-28 00:05:34 +00:00
|
|
|
#include "mozilla/gfx/Point.h"
|
2016-05-23 07:28:51 +00:00
|
|
|
#include "mozilla/ipc/Transport.h"
|
2016-06-11 02:27:24 +00:00
|
|
|
#include "nsIObserverService.h"
|
2016-05-23 07:27:01 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
2016-05-23 07:27:51 +00:00
|
|
|
class APZCTreeManager;
|
2016-05-23 07:27:01 +00:00
|
|
|
class CompositorSession;
|
|
|
|
class ClientLayerManager;
|
2016-05-23 07:28:03 +00:00
|
|
|
class CompositorUpdateObserver;
|
2016-05-23 07:28:51 +00:00
|
|
|
class PCompositorBridgeParent;
|
2016-05-23 07:27:01 +00:00
|
|
|
} // namespace layers
|
|
|
|
namespace widget {
|
2016-06-30 02:35:24 +00:00
|
|
|
class CompositorWidgetProxy;
|
2016-05-23 07:27:01 +00:00
|
|
|
} // namespace widget
|
2016-05-23 07:28:51 +00:00
|
|
|
namespace dom {
|
|
|
|
class ContentParent;
|
|
|
|
class TabParent;
|
|
|
|
} // namespace dom
|
|
|
|
namespace ipc {
|
|
|
|
class GeckoChildProcessHost;
|
|
|
|
} // namespace ipc
|
2016-05-23 07:27:01 +00:00
|
|
|
namespace gfx {
|
|
|
|
|
2016-06-11 02:27:24 +00:00
|
|
|
class GPUChild;
|
|
|
|
|
2016-05-23 07:27:01 +00:00
|
|
|
// 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.
|
2016-06-11 02:27:24 +00:00
|
|
|
class GPUProcessManager final : public GPUProcessHost::Listener
|
2016-05-23 07:27:01 +00:00
|
|
|
{
|
2016-05-23 07:27:51 +00:00
|
|
|
typedef layers::APZCTreeManager APZCTreeManager;
|
2016-05-23 07:28:03 +00:00
|
|
|
typedef layers::CompositorUpdateObserver CompositorUpdateObserver;
|
2016-05-23 07:27:51 +00:00
|
|
|
|
2016-05-23 07:27:01 +00:00
|
|
|
public:
|
|
|
|
static void Initialize();
|
|
|
|
static void Shutdown();
|
|
|
|
static GPUProcessManager* Get();
|
|
|
|
|
|
|
|
~GPUProcessManager();
|
|
|
|
|
2016-06-11 02:27:24 +00:00
|
|
|
// If not using a GPU process, launch a new GPU process asynchronously.
|
|
|
|
void EnableGPUProcess();
|
|
|
|
|
|
|
|
// Ensure that GPU-bound methods can be used. If no GPU process is being
|
|
|
|
// used, or one is launched and ready, this function returns immediately.
|
|
|
|
// Otherwise it blocks until the GPU process has finished launching.
|
|
|
|
void EnsureGPUReady();
|
|
|
|
|
2016-05-23 07:27:01 +00:00
|
|
|
already_AddRefed<layers::CompositorSession> CreateTopLevelCompositor(
|
2016-06-30 02:35:24 +00:00
|
|
|
widget::CompositorWidgetProxy* aProxy,
|
2016-05-23 07:27:01 +00:00
|
|
|
layers::ClientLayerManager* aLayerManager,
|
|
|
|
CSSToLayoutDeviceScale aScale,
|
|
|
|
bool aUseAPZ,
|
|
|
|
bool aUseExternalSurfaceSize,
|
2016-06-28 00:05:34 +00:00
|
|
|
const gfx::IntSize& aSurfaceSize);
|
2016-05-23 07:27:01 +00:00
|
|
|
|
2016-05-23 07:28:51 +00:00
|
|
|
layers::PCompositorBridgeParent* CreateTabCompositorBridge(
|
|
|
|
ipc::Transport* aTransport,
|
2016-05-28 01:03:12 +00:00
|
|
|
base::ProcessId aOtherProcess);
|
2016-05-23 07:28:51 +00:00
|
|
|
|
2016-05-23 07:27:51 +00:00
|
|
|
// This returns a reference to the APZCTreeManager to which
|
|
|
|
// pan/zoom-related events can be sent.
|
|
|
|
already_AddRefed<APZCTreeManager> GetAPZCTreeManagerForLayers(uint64_t aLayersId);
|
|
|
|
|
2016-05-23 07:27:57 +00:00
|
|
|
// Allocate an ID that can be used to refer to a layer tree and
|
|
|
|
// associated resources that live only on the compositor thread.
|
|
|
|
//
|
|
|
|
// Must run on the content main thread.
|
|
|
|
uint64_t AllocateLayerTreeId();
|
|
|
|
|
|
|
|
// Release compositor-thread resources referred to by |aID|.
|
|
|
|
//
|
|
|
|
// Must run on the content main thread.
|
|
|
|
void DeallocateLayerTreeId(uint64_t aLayersId);
|
|
|
|
|
2016-05-23 07:28:03 +00:00
|
|
|
void RequestNotifyLayerTreeReady(uint64_t aLayersId, CompositorUpdateObserver* aObserver);
|
|
|
|
void RequestNotifyLayerTreeCleared(uint64_t aLayersId, CompositorUpdateObserver* aObserver);
|
|
|
|
void SwapLayerTreeObservers(uint64_t aLayer, uint64_t aOtherLayer);
|
|
|
|
|
2016-05-23 07:28:51 +00:00
|
|
|
// Creates a new RemoteContentController for aTabId. Should only be called on
|
|
|
|
// the main thread.
|
|
|
|
//
|
|
|
|
// aLayersId The layers id for the browser corresponding to aTabId.
|
|
|
|
// aContentParent The ContentParent for the process that the TabChild for
|
|
|
|
// aTabId lives in.
|
|
|
|
// aBrowserParent The toplevel TabParent for aTabId.
|
|
|
|
bool UpdateRemoteContentController(uint64_t aLayersId,
|
|
|
|
dom::ContentParent* aContentParent,
|
|
|
|
const dom::TabId& aTabId,
|
|
|
|
dom::TabParent* aBrowserParent);
|
|
|
|
|
2016-06-11 02:27:24 +00:00
|
|
|
void OnProcessLaunchComplete(GPUProcessHost* aHost) override;
|
2016-06-11 02:37:03 +00:00
|
|
|
void OnProcessUnexpectedShutdown(GPUProcessHost* aHost) override;
|
2016-06-11 02:27:24 +00:00
|
|
|
|
2016-06-27 06:33:20 +00:00
|
|
|
// Returns access to the PGPU protocol if a GPU process is present.
|
|
|
|
GPUChild* GetGPUChild() {
|
|
|
|
return mGPUChild;
|
|
|
|
}
|
|
|
|
|
2016-06-11 02:27:24 +00:00
|
|
|
private:
|
|
|
|
// Called from our xpcom-shutdown observer.
|
|
|
|
void OnXPCOMShutdown();
|
|
|
|
|
2016-05-23 07:27:01 +00:00
|
|
|
private:
|
|
|
|
GPUProcessManager();
|
|
|
|
|
2016-06-11 02:27:24 +00:00
|
|
|
// Permanently disable the GPU process and record a message why.
|
|
|
|
void DisableGPUProcess(const char* aMessage);
|
|
|
|
|
|
|
|
// Shutdown the GPU process.
|
|
|
|
void DestroyProcess();
|
|
|
|
|
2016-05-23 07:27:01 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(GPUProcessManager);
|
2016-06-11 02:27:24 +00:00
|
|
|
|
|
|
|
class Observer final : public nsIObserver {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
explicit Observer(GPUProcessManager* aManager);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
~Observer() {}
|
|
|
|
|
|
|
|
GPUProcessManager* mManager;
|
|
|
|
};
|
|
|
|
friend class Observer;
|
|
|
|
|
|
|
|
private:
|
|
|
|
RefPtr<Observer> mObserver;
|
|
|
|
GPUProcessHost* mProcess;
|
|
|
|
GPUChild* mGPUChild;
|
2016-05-23 07:27:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // _include_mozilla_gfx_ipc_GPUProcessManager_h_
|