Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/ipc/RemoteCompositorSession.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "RemoteCompositorSession.h"
8
#include "mozilla/VsyncDispatcher.h"
9
#include "mozilla/layers/APZChild.h"
10
#include "mozilla/layers/APZCTreeManagerChild.h"
11
#include "mozilla/Unused.h"
12
#include "nsBaseWidget.h"
13
#if defined(MOZ_WIDGET_ANDROID)
14
#include "mozilla/layers/UiCompositorControllerChild.h"
15
#endif // defined(MOZ_WIDGET_ANDROID)
16
17
namespace mozilla {
18
namespace layers {
19
20
using namespace gfx;
21
using namespace widget;
22
23
RemoteCompositorSession::RemoteCompositorSession(nsBaseWidget* aWidget,
24
                                                 CompositorBridgeChild* aChild,
25
                                                 CompositorWidgetDelegate* aWidgetDelegate,
26
                                                 APZCTreeManagerChild* aAPZ,
27
                                                 const LayersId& aRootLayerTreeId)
28
 : CompositorSession(aWidgetDelegate, aChild, aRootLayerTreeId),
29
   mWidget(aWidget),
30
   mAPZ(aAPZ)
31
0
{
32
0
  MOZ_ASSERT(!gfxPlatform::IsHeadless());
33
0
  GPUProcessManager::Get()->RegisterRemoteProcessSession(this);
34
0
  if (mAPZ) {
35
0
    mAPZ->SetCompositorSession(this);
36
0
  }
37
0
}
38
39
RemoteCompositorSession::~RemoteCompositorSession()
40
0
{
41
0
  // This should have been shutdown first.
42
0
  MOZ_ASSERT(!mCompositorBridgeChild);
43
#if defined(MOZ_WIDGET_ANDROID)
44
  MOZ_ASSERT(!mUiCompositorControllerChild);
45
#endif //defined(MOZ_WIDGET_ANDROID)
46
}
47
48
void
49
RemoteCompositorSession::NotifySessionLost()
50
0
{
51
0
  // Re-entrancy should be impossible: when we are being notified of a lost
52
0
  // session, we have by definition not shut down yet. We will shutdown, but
53
0
  // then will be removed from the notification list.
54
0
  mWidget->NotifyCompositorSessionLost(this);
55
0
}
56
57
CompositorBridgeParent*
58
RemoteCompositorSession::GetInProcessBridge() const
59
0
{
60
0
  return nullptr;
61
0
}
62
63
void
64
RemoteCompositorSession::SetContentController(GeckoContentController* aController)
65
0
{
66
0
  mContentController = aController;
67
0
  mCompositorBridgeChild->SendPAPZConstructor(new APZChild(aController), LayersId{0});
68
0
}
69
70
GeckoContentController*
71
RemoteCompositorSession::GetContentController()
72
0
{
73
0
  return mContentController.get();
74
0
}
75
76
nsIWidget*
77
RemoteCompositorSession::GetWidget() const
78
0
{
79
0
  return mWidget;
80
0
}
81
82
RefPtr<IAPZCTreeManager>
83
RemoteCompositorSession::GetAPZCTreeManager() const
84
0
{
85
0
  return mAPZ;
86
0
}
87
88
void
89
RemoteCompositorSession::Shutdown()
90
0
{
91
0
  mContentController = nullptr;
92
0
  if (mAPZ) {
93
0
    mAPZ->SetCompositorSession(nullptr);
94
0
    mAPZ->Destroy();
95
0
  }
96
0
  mCompositorBridgeChild->Destroy();
97
0
  mCompositorBridgeChild = nullptr;
98
0
  mCompositorWidgetDelegate = nullptr;
99
0
  mWidget = nullptr;
100
#if defined(MOZ_WIDGET_ANDROID)
101
  if (mUiCompositorControllerChild) {
102
    mUiCompositorControllerChild->Destroy();
103
    mUiCompositorControllerChild = nullptr;
104
  }
105
#endif //defined(MOZ_WIDGET_ANDROID)
106
  GPUProcessManager::Get()->UnregisterRemoteProcessSession(this);
107
0
}
108
109
} // namespace layers
110
} // namespace mozilla