Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set sw=2 ts=2 et 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 : #ifndef mozilla_layers_CrossProcessCompositorBridgeParent_h
8 : #define mozilla_layers_CrossProcessCompositorBridgeParent_h
9 :
10 : #include "mozilla/layers/CompositorBridgeParent.h"
11 : #include "mozilla/layers/CompositorThread.h"
12 :
13 : namespace mozilla {
14 : namespace layers {
15 :
16 : class CompositorOptions;
17 : class CompositorAnimationStorage;
18 :
19 : /**
20 : * This class handles layer updates pushed directly from child processes to
21 : * the compositor thread. It's associated with a CompositorBridgeParent on the
22 : * compositor thread. While it uses the PCompositorBridge protocol to manage
23 : * these updates, it doesn't actually drive compositing itself. For that it
24 : * hands off work to the CompositorBridgeParent it's associated with.
25 : */
26 : class CrossProcessCompositorBridgeParent final : public CompositorBridgeParentBase
27 : {
28 : friend class CompositorBridgeParent;
29 :
30 : public:
31 1 : explicit CrossProcessCompositorBridgeParent(CompositorManagerParent* aManager)
32 1 : : CompositorBridgeParentBase(aManager)
33 : , mNotifyAfterRemotePaint(false)
34 1 : , mDestroyCalled(false)
35 : {
36 1 : }
37 :
38 : virtual void ActorDestroy(ActorDestroyReason aWhy) override;
39 :
40 : // FIXME/bug 774388: work out what shutdown protocol we need.
41 0 : virtual mozilla::ipc::IPCResult RecvInitialize(const uint64_t& aRootLayerTreeId) override { return IPC_FAIL_NO_REASON(this); }
42 0 : virtual mozilla::ipc::IPCResult RecvWillClose() override { return IPC_OK(); }
43 0 : virtual mozilla::ipc::IPCResult RecvPause() override { return IPC_OK(); }
44 0 : virtual mozilla::ipc::IPCResult RecvResume() override { return IPC_OK(); }
45 0 : virtual mozilla::ipc::IPCResult RecvForceIsFirstPaint() override { return IPC_OK(); }
46 : virtual mozilla::ipc::IPCResult RecvNotifyChildCreated(const uint64_t& child, CompositorOptions* aOptions) override;
47 : virtual mozilla::ipc::IPCResult RecvMapAndNotifyChildCreated(const uint64_t& child, const base::ProcessId& pid, CompositorOptions* aOptions) override;
48 0 : virtual mozilla::ipc::IPCResult RecvNotifyChildRecreated(const uint64_t& child, CompositorOptions* aOptions) override { return IPC_FAIL_NO_REASON(this); }
49 0 : virtual mozilla::ipc::IPCResult RecvAdoptChild(const uint64_t& child) override { return IPC_FAIL_NO_REASON(this); }
50 0 : virtual mozilla::ipc::IPCResult RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
51 : const gfx::IntRect& aRect) override
52 0 : { return IPC_OK(); }
53 0 : virtual mozilla::ipc::IPCResult RecvFlushRendering() override { return IPC_OK(); }
54 0 : virtual mozilla::ipc::IPCResult RecvFlushRenderingAsync() override { return IPC_OK(); }
55 0 : virtual mozilla::ipc::IPCResult RecvForcePresent() override { return IPC_OK(); }
56 0 : virtual mozilla::ipc::IPCResult RecvWaitOnTransactionProcessed() override { return IPC_OK(); }
57 0 : virtual mozilla::ipc::IPCResult RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) override { return IPC_OK(); }
58 0 : virtual mozilla::ipc::IPCResult RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) override { return IPC_OK(); }
59 0 : virtual mozilla::ipc::IPCResult RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray<float>* intervals) override { return IPC_OK(); }
60 :
61 : virtual mozilla::ipc::IPCResult RecvClearApproximatelyVisibleRegions(const uint64_t& aLayersId,
62 : const uint32_t& aPresShellId) override;
63 :
64 : virtual mozilla::ipc::IPCResult RecvNotifyApproximatelyVisibleRegion(const ScrollableLayerGuid& aGuid,
65 : const CSSIntRegion& aRegion) override;
66 :
67 0 : virtual mozilla::ipc::IPCResult RecvAllPluginsCaptured() override { return IPC_OK(); }
68 :
69 0 : virtual mozilla::ipc::IPCResult RecvGetFrameUniformity(FrameUniformityData* aOutData) override
70 : {
71 : // Don't support calculating frame uniformity on the child process and
72 : // this is just a stub for now.
73 0 : MOZ_ASSERT(false);
74 : return IPC_OK();
75 : }
76 :
77 : /**
78 : * Tells this CompositorBridgeParent to send a message when the compositor has received the transaction.
79 : */
80 : virtual mozilla::ipc::IPCResult RecvRequestNotifyAfterRemotePaint() override;
81 :
82 : virtual PLayerTransactionParent*
83 : AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints,
84 : const uint64_t& aId) override;
85 :
86 : virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) override;
87 :
88 : virtual void ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
89 : const TransactionInfo& aInfo,
90 : bool aHitTestUpdate) override;
91 : virtual void ForceComposite(LayerTransactionParent* aLayerTree) override;
92 : virtual void NotifyClearCachedResources(LayerTransactionParent* aLayerTree) override;
93 : virtual bool SetTestSampleTime(const uint64_t& aId,
94 : const TimeStamp& aTime) override;
95 : virtual void LeaveTestMode(const uint64_t& aId) override;
96 : virtual void ApplyAsyncProperties(LayerTransactionParent* aLayerTree)
97 : override;
98 : virtual void FlushApzRepaints(const uint64_t& aLayersId) override;
99 : virtual void GetAPZTestData(const uint64_t& aLayersId,
100 : APZTestData* aOutData) override;
101 : virtual void SetConfirmedTargetAPZC(const uint64_t& aLayersId,
102 : const uint64_t& aInputBlockId,
103 : const nsTArray<ScrollableLayerGuid>& aTargets) override;
104 :
105 : virtual AsyncCompositionManager* GetCompositionManager(LayerTransactionParent* aParent) override;
106 0 : virtual mozilla::ipc::IPCResult RecvRemotePluginsReady() override { return IPC_FAIL_NO_REASON(this); }
107 :
108 : virtual void DidComposite(uint64_t aId,
109 : TimeStamp& aCompositeStart,
110 : TimeStamp& aCompositeEnd) override;
111 :
112 : virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
113 : const LayersBackend& aLayersBackend,
114 : const TextureFlags& aFlags,
115 : const uint64_t& aId,
116 : const uint64_t& aSerial,
117 : const wr::MaybeExternalImageId& aExternalImageId) override;
118 :
119 : virtual bool DeallocPTextureParent(PTextureParent* actor) override;
120 :
121 : virtual bool IsSameProcess() const override;
122 :
123 0 : PCompositorWidgetParent* AllocPCompositorWidgetParent(const CompositorWidgetInitData& aInitData) override {
124 : // Not allowed.
125 0 : return nullptr;
126 : }
127 0 : bool DeallocPCompositorWidgetParent(PCompositorWidgetParent* aActor) override {
128 : // Not allowed.
129 0 : return false;
130 : }
131 :
132 : virtual PAPZCTreeManagerParent* AllocPAPZCTreeManagerParent(const uint64_t& aLayersId) override;
133 : virtual bool DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor) override;
134 :
135 : virtual PAPZParent* AllocPAPZParent(const uint64_t& aLayersId) override;
136 : virtual bool DeallocPAPZParent(PAPZParent* aActor) override;
137 :
138 : virtual void UpdatePaintTime(LayerTransactionParent* aLayerTree, const TimeDuration& aPaintTime) override;
139 :
140 : PWebRenderBridgeParent* AllocPWebRenderBridgeParent(const wr::PipelineId& aPipelineId,
141 : const LayoutDeviceIntSize& aSize,
142 : TextureFactoryIdentifier* aTextureFactoryIdentifier,
143 : uint32_t* aIdNamespace) override;
144 : bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
145 :
146 : void ObserveLayerUpdate(uint64_t aLayersId, uint64_t aEpoch, bool aActive) override;
147 :
148 0 : bool IsRemote() const override {
149 0 : return true;
150 : }
151 :
152 : private:
153 : // Private destructor, to discourage deletion outside of Release():
154 : virtual ~CrossProcessCompositorBridgeParent();
155 :
156 : void DeferredDestroy();
157 :
158 : // There can be many CPCPs, and IPDL-generated code doesn't hold a
159 : // reference to top-level actors. So we hold a reference to
160 : // ourself. This is released (deferred) in ActorDestroy().
161 : RefPtr<CrossProcessCompositorBridgeParent> mSelfRef;
162 :
163 : // If true, we should send a RemotePaintIsReady message when the layer transaction
164 : // is received
165 : bool mNotifyAfterRemotePaint;
166 : bool mDestroyCalled;
167 : };
168 :
169 : } // namespace layers
170 : } // namespace mozilla
171 :
172 : #endif // mozilla_layers_CrossProcessCompositorBridgeParent_h
|