2016-07-18 07:24:27 +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/. */
|
|
|
|
|
|
|
|
#include "InProcessCompositorSession.h"
|
|
|
|
|
2016-07-20 14:37:00 +03:00
|
|
|
// so we can cast an APZCTreeManager to an IAPZCTreeManager
|
|
|
|
#include "mozilla/layers/APZCTreeManager.h"
|
|
|
|
#include "mozilla/layers/IAPZCTreeManager.h"
|
|
|
|
|
2016-07-18 07:24:27 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
InProcessCompositorSession::InProcessCompositorSession(widget::CompositorWidget* aWidget,
|
|
|
|
CompositorBridgeChild* aChild,
|
|
|
|
CompositorBridgeParent* aParent)
|
2016-07-18 07:24:27 +03:00
|
|
|
: CompositorSession(aWidget->AsDelegate(), aChild, aParent->RootLayerTreeId()),
|
2016-07-18 07:24:27 +03:00
|
|
|
mCompositorBridgeParent(aParent),
|
|
|
|
mCompositorWidget(aWidget)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ RefPtr<InProcessCompositorSession>
|
|
|
|
InProcessCompositorSession::Create(nsIWidget* aWidget,
|
2016-11-08 18:42:19 +03:00
|
|
|
LayerManager* aLayerManager,
|
2016-07-18 07:24:27 +03:00
|
|
|
const uint64_t& aRootLayerTreeId,
|
2016-07-18 07:24:27 +03:00
|
|
|
CSSToLayoutDeviceScale aScale,
|
2017-01-13 01:29:41 +03:00
|
|
|
const CompositorOptions& aOptions,
|
2016-07-18 07:24:27 +03:00
|
|
|
bool aUseExternalSurfaceSize,
|
2017-04-14 11:06:09 +03:00
|
|
|
const gfx::IntSize& aSurfaceSize,
|
|
|
|
uint32_t aNamespace)
|
2016-07-18 07:24:27 +03:00
|
|
|
{
|
|
|
|
CompositorWidgetInitData initData;
|
|
|
|
aWidget->GetCompositorWidgetInitData(&initData);
|
|
|
|
|
2017-01-13 01:29:42 +03:00
|
|
|
RefPtr<CompositorWidget> widget = CompositorWidget::CreateLocal(initData, aOptions, aWidget);
|
2017-04-14 11:06:09 +03:00
|
|
|
RefPtr<CompositorBridgeChild> child = new CompositorBridgeChild(aLayerManager, aNamespace);
|
2016-07-18 07:24:27 +03:00
|
|
|
RefPtr<CompositorBridgeParent> parent =
|
2017-01-13 01:29:41 +03:00
|
|
|
child->InitSameProcess(widget, aRootLayerTreeId, aScale, aOptions, aUseExternalSurfaceSize, aSurfaceSize);
|
2016-07-18 07:24:27 +03:00
|
|
|
|
|
|
|
return new InProcessCompositorSession(widget, child, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
CompositorBridgeParent*
|
|
|
|
InProcessCompositorSession::GetInProcessBridge() const
|
|
|
|
{
|
|
|
|
return mCompositorBridgeParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
InProcessCompositorSession::SetContentController(GeckoContentController* aController)
|
|
|
|
{
|
2016-07-18 07:24:27 +03:00
|
|
|
mCompositorBridgeParent->SetControllerForLayerTree(mRootLayerTreeId, aController);
|
2016-07-18 07:24:27 +03:00
|
|
|
}
|
|
|
|
|
2016-08-29 16:18:00 +03:00
|
|
|
RefPtr<IAPZCTreeManager>
|
2016-07-18 07:24:27 +03:00
|
|
|
InProcessCompositorSession::GetAPZCTreeManager() const
|
|
|
|
{
|
2016-07-18 07:24:27 +03:00
|
|
|
return mCompositorBridgeParent->GetAPZCTreeManager(mRootLayerTreeId);
|
2016-07-18 07:24:27 +03:00
|
|
|
}
|
|
|
|
|
2016-11-06 21:56:53 +03:00
|
|
|
bool
|
2016-11-14 22:47:01 +03:00
|
|
|
InProcessCompositorSession::Reset(const nsTArray<LayersBackend>& aBackendHints,
|
|
|
|
uint64_t aSeqNo,
|
|
|
|
TextureFactoryIdentifier* aOutIdentifier)
|
2016-11-06 21:56:53 +03:00
|
|
|
{
|
2016-11-14 22:47:01 +03:00
|
|
|
return mCompositorBridgeParent->ResetCompositor(aBackendHints, aSeqNo, aOutIdentifier);
|
2016-11-06 21:56:53 +03:00
|
|
|
}
|
|
|
|
|
2016-07-18 07:24:27 +03:00
|
|
|
void
|
|
|
|
InProcessCompositorSession::Shutdown()
|
|
|
|
{
|
|
|
|
// Destroy will synchronously wait for the parent to acknowledge shutdown,
|
|
|
|
// at which point CBP will defer a Release on the compositor thread. We
|
|
|
|
// can safely release our reference now, and let the destructor run on either
|
|
|
|
// thread.
|
|
|
|
mCompositorBridgeChild->Destroy();
|
|
|
|
mCompositorBridgeChild = nullptr;
|
|
|
|
mCompositorBridgeParent = nullptr;
|
|
|
|
mCompositorWidget = 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)
|
2016-07-18 07:24:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|