Bug 1330037 - Introduce a CompositorOptions struct that holds options on a per-compositor basis. r=dvander

MozReview-Commit-ID: Kja7zpCDmp3

--HG--
extra : rebase_source : 001c841957ca7abe0ae3b3793b674e1986e4575c
This commit is contained in:
Kartikaya Gupta 2017-01-12 17:29:41 -05:00
parent dd7ec3a99b
commit 6c437b31b9
11 changed files with 70 additions and 19 deletions

View File

@ -0,0 +1,41 @@
/* -*- 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_CompositorOptions_h_
#define _include_mozilla_gfx_ipc_CompositorOptions_h_
namespace mozilla {
namespace layers {
/**
* This class holds options that are "per compositor" - that is, these options
* affect a particular CompositorBridgeParent and all the content that it
* renders.
*
* This class is intended to be created by a platform widget (but NOT
* PuppetWidget) and passed to the graphics code during initialization of the
* top level compositor associated with that widget. The options are immutable
* after creation. The CompositorBridgeParent holds the canonical version of
* the options, but they may be accessed by other parts of the code as needed,
* and are accessible to content processes over PCompositorBridge as well.
*/
class CompositorOptions
{
public:
explicit CompositorOptions(bool aUseAPZ)
: mUseAPZ(aUseAPZ)
{
}
bool UseAPZ() const { return mUseAPZ; }
private:
bool mUseAPZ;
};
} // namespace layers
} // namespace mozilla
#endif // _include_mozilla_gfx_ipc_CompositorOptions_h_

View File

@ -12,6 +12,7 @@
#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/APZCTreeManagerChild.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/CompositorOptions.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/ImageBridgeParent.h"
#include "mozilla/layers/InProcessCompositorSession.h"
@ -487,7 +488,7 @@ RefPtr<CompositorSession>
GPUProcessManager::CreateTopLevelCompositor(nsBaseWidget* aWidget,
LayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize)
{
@ -503,7 +504,7 @@ GPUProcessManager::CreateTopLevelCompositor(nsBaseWidget* aWidget,
aLayerManager,
layerTreeId,
aScale,
aUseAPZ,
aOptions,
aUseExternalSurfaceSize,
aSurfaceSize);
if (session) {
@ -519,7 +520,7 @@ GPUProcessManager::CreateTopLevelCompositor(nsBaseWidget* aWidget,
aLayerManager,
layerTreeId,
aScale,
aUseAPZ,
aOptions,
aUseExternalSurfaceSize,
aSurfaceSize);
}
@ -529,7 +530,7 @@ GPUProcessManager::CreateRemoteSession(nsBaseWidget* aWidget,
LayerManager* aLayerManager,
const uint64_t& aRootLayerTreeId,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize)
{
@ -585,7 +586,7 @@ GPUProcessManager::CreateRemoteSession(nsBaseWidget* aWidget,
}
RefPtr<APZCTreeManagerChild> apz = nullptr;
if (aUseAPZ) {
if (aOptions.UseAPZ()) {
PAPZCTreeManagerChild* papz = child->SendPAPZCTreeManagerConstructor(0);
if (!papz) {
return nullptr;

View File

@ -24,6 +24,7 @@ class nsBaseWidget;
namespace mozilla {
namespace layers {
class IAPZCTreeManager;
class CompositorOptions;
class CompositorSession;
class CompositorUpdateObserver;
class PCompositorBridgeChild;
@ -56,6 +57,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener
{
friend class layers::RemoteCompositorSession;
typedef layers::CompositorOptions CompositorOptions;
typedef layers::CompositorSession CompositorSession;
typedef layers::CompositorUpdateObserver CompositorUpdateObserver;
typedef layers::IAPZCTreeManager IAPZCTreeManager;
@ -83,7 +85,7 @@ public:
nsBaseWidget* aWidget,
LayerManager* aLayerManager,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize);
@ -197,7 +199,7 @@ private:
LayerManager* aLayerManager,
const uint64_t& aRootLayerTreeId,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize);

View File

@ -27,7 +27,7 @@ InProcessCompositorSession::Create(nsIWidget* aWidget,
LayerManager* aLayerManager,
const uint64_t& aRootLayerTreeId,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize)
{
@ -37,7 +37,7 @@ InProcessCompositorSession::Create(nsIWidget* aWidget,
RefPtr<CompositorWidget> widget = CompositorWidget::CreateLocal(initData, aWidget);
RefPtr<CompositorBridgeChild> child = new CompositorBridgeChild(aLayerManager);
RefPtr<CompositorBridgeParent> parent =
child->InitSameProcess(widget, aRootLayerTreeId, aScale, aUseAPZ, aUseExternalSurfaceSize, aSurfaceSize);
child->InitSameProcess(widget, aRootLayerTreeId, aScale, aOptions, aUseExternalSurfaceSize, aSurfaceSize);
return new InProcessCompositorSession(widget, child, parent);
}

View File

@ -13,6 +13,8 @@
namespace mozilla {
namespace layers {
class CompositorOptions;
// A CompositorSession where both the child and parent CompositorBridge reside
// in the same process.
class InProcessCompositorSession final : public CompositorSession
@ -23,7 +25,7 @@ public:
LayerManager* aLayerManager,
const uint64_t& aRootLayerTreeId,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
const CompositorOptions& aOptions,
bool aUseExternalSurfaceSize,
const gfx::IntSize& aSurfaceSize);

View File

@ -23,6 +23,7 @@ EXPORTS.mozilla.gfx += [
]
EXPORTS.mozilla.layers += [
'CompositorOptions.h',
'CompositorSession.h',
'InProcessCompositorSession.h',
'RemoteCompositorSession.h',

View File

@ -234,7 +234,7 @@ CompositorBridgeParent*
CompositorBridgeChild::InitSameProcess(widget::CompositorWidget* aWidget,
const uint64_t& aLayerTreeId,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
const CompositorOptions& aOptions,
bool aUseExternalSurface,
const gfx::IntSize& aSurfaceSize)
{
@ -250,7 +250,7 @@ CompositorBridgeChild::InitSameProcess(widget::CompositorWidget* aWidget,
MOZ_RELEASE_ASSERT(ok);
InitIPDL();
mCompositorBridgeParent->InitSameProcess(aWidget, aLayerTreeId, aUseAPZ);
mCompositorBridgeParent->InitSameProcess(aWidget, aLayerTreeId, aOptions);
return mCompositorBridgeParent;
}

View File

@ -38,6 +38,7 @@ class IAPZCTreeManager;
class APZCTreeManagerChild;
class ClientLayerManager;
class CompositorBridgeParent;
class CompositorOptions;
class TextureClient;
class TextureClientPool;
struct FrameMetrics;
@ -80,7 +81,7 @@ public:
widget::CompositorWidget* aWidget,
const uint64_t& aLayerTreeId,
CSSToLayoutDeviceScale aScale,
bool aUseAPZ,
const CompositorOptions& aOptions,
bool aUseExternalSurface,
const gfx::IntSize& aSurfaceSize);

View File

@ -39,6 +39,7 @@
#include "mozilla/layers/BasicCompositor.h" // for BasicCompositor
#include "mozilla/layers/Compositor.h" // for Compositor
#include "mozilla/layers/CompositorOGL.h" // for CompositorOGL
#include "mozilla/layers/CompositorOptions.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/CompositorVsyncScheduler.h"
@ -321,11 +322,11 @@ CompositorBridgeParent::CompositorBridgeParent(CSSToLayoutDeviceScale aScale,
void
CompositorBridgeParent::InitSameProcess(widget::CompositorWidget* aWidget,
const uint64_t& aLayerTreeId,
bool aUseAPZ)
const CompositorOptions& aOptions)
{
mWidget = aWidget;
mRootLayerTreeID = aLayerTreeId;
if (aUseAPZ) {
if (aOptions.UseAPZ()) {
mApzcTreeManager = new APZCTreeManager();
}

View File

@ -63,6 +63,7 @@ class APZCTreeManagerParent;
class AsyncCompositionManager;
class Compositor;
class CompositorBridgeParent;
class CompositorOptions;
class CompositorVsyncScheduler;
class HostLayerManager;
class LayerTransactionParent;
@ -163,7 +164,7 @@ public:
// free the compositor.
void InitSameProcess(widget::CompositorWidget* aWidget,
const uint64_t& aLayerTreeId,
bool aUseAPZ);
const CompositorOptions& aOptions);
// Must only be called by GPUParent. After invoking this, the IPC channel
// is active and RecvWillStop/ActorDestroy must be called to free the

View File

@ -55,6 +55,7 @@
#include "mozilla/layers/APZEventState.h"
#include "mozilla/layers/APZThreadUtils.h"
#include "mozilla/layers/ChromeProcessController.h"
#include "mozilla/layers/CompositorOptions.h"
#include "mozilla/layers/InputAPZContext.h"
#include "mozilla/layers/APZCCallbackHelper.h"
#include "mozilla/dom/ContentChild.h"
@ -1297,20 +1298,20 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
RefPtr<ClientLayerManager> lm = new ClientLayerManager(this);
bool useAPZ = UseAPZ();
CompositorOptions options(UseAPZ());
gfx::GPUProcessManager* gpu = gfx::GPUProcessManager::Get();
mCompositorSession = gpu->CreateTopLevelCompositor(
this,
lm,
GetDefaultScale(),
useAPZ,
options,
UseExternalCompositingSurface(),
gfx::IntSize(aWidth, aHeight));
mCompositorBridgeChild = mCompositorSession->GetCompositorBridgeChild();
mCompositorWidgetDelegate = mCompositorSession->GetCompositorWidgetDelegate();
if (useAPZ) {
if (options.UseAPZ()) {
mAPZC = mCompositorSession->GetAPZCTreeManager();
ConfigureAPZCTreeManager();
} else {