2016-07-18 07:24:28 +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/. */
|
2016-08-29 16:18:00 +03:00
|
|
|
|
2016-07-18 07:24:28 +03:00
|
|
|
#include "RemoteCompositorSession.h"
|
2016-09-30 11:23:52 +03:00
|
|
|
#include "mozilla/VsyncDispatcher.h"
|
2016-08-29 16:18:00 +03:00
|
|
|
#include "mozilla/layers/APZChild.h"
|
|
|
|
#include "mozilla/layers/APZCTreeManagerChild.h"
|
2016-11-06 21:56:53 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2016-09-20 11:16:03 +03:00
|
|
|
#include "nsBaseWidget.h"
|
2016-08-29 16:18:00 +03:00
|
|
|
|
2016-07-18 07:24:28 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
using namespace gfx;
|
|
|
|
using namespace widget;
|
|
|
|
|
2016-09-20 11:16:03 +03:00
|
|
|
RemoteCompositorSession::RemoteCompositorSession(nsBaseWidget* aWidget,
|
|
|
|
CompositorBridgeChild* aChild,
|
2016-07-18 07:24:28 +03:00
|
|
|
CompositorWidgetDelegate* aWidgetDelegate,
|
2016-08-29 16:18:00 +03:00
|
|
|
APZCTreeManagerChild* aAPZ,
|
2016-07-18 07:24:28 +03:00
|
|
|
const uint64_t& aRootLayerTreeId)
|
2016-09-20 11:16:03 +03:00
|
|
|
: CompositorSession(aWidgetDelegate, aChild, aRootLayerTreeId),
|
|
|
|
mWidget(aWidget),
|
|
|
|
mAPZ(aAPZ)
|
|
|
|
{
|
|
|
|
GPUProcessManager::Get()->RegisterSession(this);
|
2016-09-24 23:10:12 +03:00
|
|
|
if (mAPZ) {
|
|
|
|
mAPZ->SetCompositorSession(this);
|
|
|
|
}
|
2016-09-20 11:16:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
RemoteCompositorSession::~RemoteCompositorSession()
|
|
|
|
{
|
|
|
|
// This should have been shutdown first.
|
|
|
|
MOZ_ASSERT(!mCompositorBridgeChild);
|
|
|
|
}
|
|
|
|
|
2016-11-06 22:01:52 +03:00
|
|
|
void
|
2016-11-14 22:47:01 +03:00
|
|
|
RemoteCompositorSession::NotifyDeviceReset(uint64_t aSeqNo)
|
2016-11-06 22:01:52 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mWidget);
|
2016-11-14 22:47:01 +03:00
|
|
|
mWidget->OnRenderingDeviceReset(aSeqNo);
|
2016-11-06 22:01:52 +03:00
|
|
|
}
|
|
|
|
|
2016-09-20 11:16:03 +03:00
|
|
|
void
|
|
|
|
RemoteCompositorSession::NotifySessionLost()
|
2016-07-18 07:24:28 +03:00
|
|
|
{
|
2016-09-20 11:16:03 +03:00
|
|
|
// Re-entrancy should be impossible: when we are being notified of a lost
|
|
|
|
// session, we have by definition not shut down yet. We will shutdown, but
|
|
|
|
// then will be removed from the notification list.
|
|
|
|
MOZ_ASSERT(mWidget);
|
|
|
|
mWidget->NotifyRemoteCompositorSessionLost(this);
|
2016-07-18 07:24:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CompositorBridgeParent*
|
|
|
|
RemoteCompositorSession::GetInProcessBridge() const
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RemoteCompositorSession::SetContentController(GeckoContentController* aController)
|
|
|
|
{
|
2016-09-21 17:26:33 +03:00
|
|
|
mContentController = aController;
|
2016-08-29 16:18:00 +03:00
|
|
|
mCompositorBridgeChild->SendPAPZConstructor(new APZChild(aController), 0);
|
2016-07-18 07:24:28 +03:00
|
|
|
}
|
|
|
|
|
2016-09-21 17:26:33 +03:00
|
|
|
GeckoContentController*
|
|
|
|
RemoteCompositorSession::GetContentController()
|
|
|
|
{
|
|
|
|
return mContentController.get();
|
|
|
|
}
|
|
|
|
|
2016-09-24 16:46:02 +03:00
|
|
|
nsIWidget*
|
|
|
|
RemoteCompositorSession::GetWidget()
|
|
|
|
{
|
|
|
|
return mWidget;
|
|
|
|
}
|
|
|
|
|
2016-08-29 16:18:00 +03:00
|
|
|
RefPtr<IAPZCTreeManager>
|
2016-07-18 07:24:28 +03:00
|
|
|
RemoteCompositorSession::GetAPZCTreeManager() const
|
|
|
|
{
|
2016-08-29 16:18:00 +03:00
|
|
|
return mAPZ;
|
2016-07-18 07:24:28 +03:00
|
|
|
}
|
|
|
|
|
2016-11-06 21:56:53 +03:00
|
|
|
bool
|
2016-11-14 22:47:01 +03:00
|
|
|
RemoteCompositorSession::Reset(const nsTArray<LayersBackend>& aBackendHints,
|
|
|
|
uint64_t aSeqNo,
|
|
|
|
TextureFactoryIdentifier* aOutIdentifier)
|
2016-11-06 21:56:53 +03:00
|
|
|
{
|
|
|
|
bool didReset;
|
2016-11-14 22:47:01 +03:00
|
|
|
Unused << mCompositorBridgeChild->SendReset(aBackendHints, aSeqNo, &didReset, aOutIdentifier);
|
2016-11-06 21:56:53 +03:00
|
|
|
return didReset;
|
|
|
|
}
|
|
|
|
|
2016-07-18 07:24:28 +03:00
|
|
|
void
|
|
|
|
RemoteCompositorSession::Shutdown()
|
|
|
|
{
|
2016-09-21 17:26:33 +03:00
|
|
|
mContentController = nullptr;
|
2016-09-24 23:10:12 +03:00
|
|
|
if (mAPZ) {
|
|
|
|
mAPZ->SetCompositorSession(nullptr);
|
|
|
|
}
|
2016-07-18 07:24:28 +03:00
|
|
|
mCompositorBridgeChild->Destroy();
|
|
|
|
mCompositorBridgeChild = nullptr;
|
|
|
|
mCompositorWidgetDelegate = nullptr;
|
2016-09-20 11:16:03 +03:00
|
|
|
mWidget = nullptr;
|
|
|
|
GPUProcessManager::Get()->UnregisterSession(this);
|
2016-07-18 07:24:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|