Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=99: */
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 0 : RemoteCompositorSession::RemoteCompositorSession(nsBaseWidget* aWidget,
24 : CompositorBridgeChild* aChild,
25 : CompositorWidgetDelegate* aWidgetDelegate,
26 : APZCTreeManagerChild* aAPZ,
27 0 : const uint64_t& aRootLayerTreeId)
28 : : CompositorSession(aWidgetDelegate, aChild, aRootLayerTreeId),
29 : mWidget(aWidget),
30 0 : mAPZ(aAPZ)
31 : {
32 0 : GPUProcessManager::Get()->RegisterRemoteProcessSession(this);
33 0 : if (mAPZ) {
34 0 : mAPZ->SetCompositorSession(this);
35 : }
36 0 : }
37 :
38 0 : RemoteCompositorSession::~RemoteCompositorSession()
39 : {
40 : // This should have been shutdown first.
41 0 : MOZ_ASSERT(!mCompositorBridgeChild);
42 : #if defined(MOZ_WIDGET_ANDROID)
43 : MOZ_ASSERT(!mUiCompositorControllerChild);
44 : #endif //defined(MOZ_WIDGET_ANDROID)
45 0 : }
46 :
47 : void
48 0 : RemoteCompositorSession::NotifySessionLost()
49 : {
50 : // Re-entrancy should be impossible: when we are being notified of a lost
51 : // session, we have by definition not shut down yet. We will shutdown, but
52 : // then will be removed from the notification list.
53 0 : mWidget->NotifyCompositorSessionLost(this);
54 0 : }
55 :
56 : CompositorBridgeParent*
57 0 : RemoteCompositorSession::GetInProcessBridge() const
58 : {
59 0 : return nullptr;
60 : }
61 :
62 : void
63 0 : RemoteCompositorSession::SetContentController(GeckoContentController* aController)
64 : {
65 0 : mContentController = aController;
66 0 : mCompositorBridgeChild->SendPAPZConstructor(new APZChild(aController), 0);
67 0 : }
68 :
69 : GeckoContentController*
70 0 : RemoteCompositorSession::GetContentController()
71 : {
72 0 : return mContentController.get();
73 : }
74 :
75 : nsIWidget*
76 0 : RemoteCompositorSession::GetWidget() const
77 : {
78 0 : return mWidget;
79 : }
80 :
81 : RefPtr<IAPZCTreeManager>
82 0 : RemoteCompositorSession::GetAPZCTreeManager() const
83 : {
84 0 : return mAPZ;
85 : }
86 :
87 : void
88 0 : RemoteCompositorSession::Shutdown()
89 : {
90 0 : mContentController = nullptr;
91 0 : if (mAPZ) {
92 0 : mAPZ->SetCompositorSession(nullptr);
93 : }
94 0 : mCompositorBridgeChild->Destroy();
95 0 : mCompositorBridgeChild = nullptr;
96 0 : mCompositorWidgetDelegate = nullptr;
97 0 : mWidget = nullptr;
98 : #if defined(MOZ_WIDGET_ANDROID)
99 : if (mUiCompositorControllerChild) {
100 : mUiCompositorControllerChild->Destroy();
101 : mUiCompositorControllerChild = nullptr;
102 : }
103 : #endif //defined(MOZ_WIDGET_ANDROID)
104 0 : GPUProcessManager::Get()->UnregisterRemoteProcessSession(this);
105 0 : }
106 :
107 : } // namespace layers
108 : } // namespace mozilla
|