/src/mozilla-central/gfx/ipc/InProcessCompositorSession.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 "InProcessCompositorSession.h" |
8 | | |
9 | | #include "mozilla/layers/IAPZCTreeManager.h" |
10 | | #include "nsBaseWidget.h" |
11 | | |
12 | | namespace mozilla { |
13 | | namespace layers { |
14 | | |
15 | | InProcessCompositorSession::InProcessCompositorSession(widget::CompositorWidget* aWidget, |
16 | | nsBaseWidget* baseWidget, |
17 | | CompositorBridgeChild* aChild, |
18 | | CompositorBridgeParent* aParent) |
19 | | : CompositorSession(aWidget->AsDelegate(), aChild, aParent->RootLayerTreeId()), |
20 | | mWidget(baseWidget), |
21 | | mCompositorBridgeParent(aParent), |
22 | | mCompositorWidget(aWidget) |
23 | 0 | { |
24 | 0 | GPUProcessManager::Get()->RegisterInProcessSession(this); |
25 | 0 | } |
26 | | |
27 | | /* static */ RefPtr<InProcessCompositorSession> |
28 | | InProcessCompositorSession::Create(nsBaseWidget* aWidget, |
29 | | LayerManager* aLayerManager, |
30 | | const LayersId& aRootLayerTreeId, |
31 | | CSSToLayoutDeviceScale aScale, |
32 | | const CompositorOptions& aOptions, |
33 | | bool aUseExternalSurfaceSize, |
34 | | const gfx::IntSize& aSurfaceSize, |
35 | | uint32_t aNamespace) |
36 | 0 | { |
37 | 0 | CompositorWidgetInitData initData; |
38 | 0 | aWidget->GetCompositorWidgetInitData(&initData); |
39 | 0 |
|
40 | 0 | RefPtr<CompositorWidget> widget = CompositorWidget::CreateLocal(initData, aOptions, aWidget); |
41 | 0 | RefPtr<CompositorBridgeParent> parent = |
42 | 0 | CompositorManagerParent::CreateSameProcessWidgetCompositorBridge(aScale, aOptions, |
43 | 0 | aUseExternalSurfaceSize, |
44 | 0 | aSurfaceSize); |
45 | 0 | MOZ_ASSERT(parent); |
46 | 0 | parent->InitSameProcess(widget, aRootLayerTreeId); |
47 | 0 |
|
48 | 0 | RefPtr<CompositorBridgeChild> child = |
49 | 0 | CompositorManagerChild::CreateSameProcessWidgetCompositorBridge(aLayerManager, |
50 | 0 | aNamespace); |
51 | 0 | MOZ_ASSERT(child); |
52 | 0 |
|
53 | 0 | return new InProcessCompositorSession(widget, aWidget, child, parent); |
54 | 0 | } |
55 | | |
56 | | void |
57 | | InProcessCompositorSession::NotifySessionLost() |
58 | 0 | { |
59 | 0 | mWidget->NotifyCompositorSessionLost(this); |
60 | 0 | } |
61 | | |
62 | | CompositorBridgeParent* |
63 | | InProcessCompositorSession::GetInProcessBridge() const |
64 | 0 | { |
65 | 0 | return mCompositorBridgeParent; |
66 | 0 | } |
67 | | |
68 | | void |
69 | | InProcessCompositorSession::SetContentController(GeckoContentController* aController) |
70 | 0 | { |
71 | 0 | mCompositorBridgeParent->SetControllerForLayerTree(mRootLayerTreeId, aController); |
72 | 0 | } |
73 | | |
74 | | RefPtr<IAPZCTreeManager> |
75 | | InProcessCompositorSession::GetAPZCTreeManager() const |
76 | 0 | { |
77 | 0 | return mCompositorBridgeParent->GetAPZCTreeManager(mRootLayerTreeId); |
78 | 0 | } |
79 | | |
80 | | nsIWidget* |
81 | | InProcessCompositorSession::GetWidget() const |
82 | 0 | { |
83 | 0 | return mWidget; |
84 | 0 | } |
85 | | |
86 | | void |
87 | | InProcessCompositorSession::Shutdown() |
88 | 0 | { |
89 | 0 | // Destroy will synchronously wait for the parent to acknowledge shutdown, |
90 | 0 | // at which point CBP will defer a Release on the compositor thread. We |
91 | 0 | // can safely release our reference now, and let the destructor run on either |
92 | 0 | // thread. |
93 | | #if defined(MOZ_WIDGET_ANDROID) |
94 | | if (mUiCompositorControllerChild) { |
95 | | mUiCompositorControllerChild->Destroy(); |
96 | | mUiCompositorControllerChild = nullptr; |
97 | | } |
98 | | #endif //defined(MOZ_WIDGET_ANDROID) |
99 | | mCompositorBridgeChild->Destroy(); |
100 | 0 | mCompositorBridgeChild = nullptr; |
101 | 0 | mCompositorBridgeParent = nullptr; |
102 | 0 | mCompositorWidget = nullptr; |
103 | 0 | GPUProcessManager::Get()->UnregisterInProcessSession(this); |
104 | 0 | } |
105 | | |
106 | | } // namespace layers |
107 | | } // namespace mozilla |