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"
|
2017-04-06 01:42:50 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
#include "mozilla/layers/UiCompositorControllerChild.h"
|
|
|
|
#endif // defined(MOZ_WIDGET_ANDROID)
|
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)
|
|
|
|
{
|
2017-06-15 21:34:00 +03:00
|
|
|
GPUProcessManager::Get()->RegisterRemoteProcessSession(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);
|
2017-04-06 01:42:50 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
MOZ_ASSERT(!mUiCompositorControllerChild);
|
|
|
|
#endif //defined(MOZ_WIDGET_ANDROID)
|
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.
|
2017-06-15 21:34:00 +03:00
|
|
|
mWidget->NotifyCompositorSessionLost(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*
|
2017-06-15 21:34:00 +03:00
|
|
|
RemoteCompositorSession::GetWidget() const
|
2016-09-24 16:46:02 +03:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2017-04-06 01:42:50 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
if (mUiCompositorControllerChild) {
|
|
|
|
mUiCompositorControllerChild->Destroy();
|
|
|
|
mUiCompositorControllerChild = nullptr;
|
|
|
|
}
|
|
|
|
#endif //defined(MOZ_WIDGET_ANDROID)
|
2017-06-15 21:34:00 +03:00
|
|
|
GPUProcessManager::Get()->UnregisterRemoteProcessSession(this);
|
2016-07-18 07:24:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|