PCompositorBridge.ipdl (8628B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: sw=2 ts=8 et : 3 */ 4 /* This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 8 include LayersSurfaces; 9 include LayersMessages; 10 include PlatformWidgetTypes; 11 include PCompositorBridgeTypes; 12 include protocol PAPZ; 13 include protocol PAPZCTreeManager; 14 include protocol PBrowser; 15 include protocol PCompositorManager; 16 include protocol PCompositorWidget; 17 include protocol PTexture; 18 include protocol PWebRenderBridge; 19 include "mozilla/GfxMessageUtils.h"; 20 include "mozilla/layers/LayersMessageUtils.h"; 21 include "mozilla/layers/WebRenderMessageUtils.h"; 22 include "mozilla/layers/CompositorBridgeParent.h"; 23 24 using struct mozilla::null_t from "mozilla/ipc/IPCCore.h"; 25 using struct mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h"; 26 using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; 27 using struct mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h"; 28 using mozilla::layers::ScrollableLayerGuid::ViewID from "mozilla/layers/ScrollableLayerGuid.h"; 29 using mozilla::layers::WindowKind from "mozilla/layers/LayersTypes.h"; 30 using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h"; 31 using mozilla::CSSIntRegion from "Units.h"; 32 using mozilla::LayoutDeviceIntPoint from "Units.h"; 33 using mozilla::LayoutDeviceIntRegion from "Units.h"; 34 using mozilla::LayoutDeviceIntSize from "Units.h"; 35 using class mozilla::TimeStamp from "mozilla/TimeStamp.h"; 36 using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h"; 37 using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h"; 38 using mozilla::wr::PipelineId from "mozilla/webrender/WebRenderTypes.h"; 39 using mozilla::wr::IdNamespace from "mozilla/webrender/WebRenderTypes.h"; 40 using mozilla::wr::RenderReasons from "mozilla/webrender/webrender_ffi.h"; 41 using base::ProcessId from "base/process.h"; 42 using mozilla::wr::MaybeExternalImageId from "mozilla/webrender/WebRenderTypes.h"; 43 using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h"; 44 45 namespace mozilla { 46 namespace layers { 47 48 struct FrameStats { 49 TransactionId id; 50 TimeStamp compositeStart; 51 TimeStamp renderStart; 52 TimeStamp compositeEnd; 53 int32_t contentFrameTime; 54 double resourceUploadTime; 55 TimeStamp transactionStart; 56 TimeStamp refreshStart; 57 TimeStamp fwdTime; 58 TimeStamp sceneBuiltTime; 59 uint32_t skippedComposites; 60 nsCString url; 61 }; 62 63 /** 64 * The PCompositorBridge protocol is a top-level protocol for the compositor. 65 * There is an instance of the protocol for each compositor, plus one for each 66 * content process. In other words: 67 * - There is a CompositorBridgeParent/CompositorBridgeChild pair created 68 * for each "top level browser window", which has its own compositor. The 69 * CompositorBridgeChild instance lives in the UI process, and the 70 * CompositorBridgeParent lives in the GPU process (if there is one) or the 71 * UI process otherwise. 72 * - There is also a ContentCompositorBridgeParent/CompositorBridgeChild 73 * pair created for each content process. The ContentCompositorBridgeParent 74 * lives in the GPU process (if there is one) or the UI process otherwise. The 75 * CompositorBridgeChild is a singleton in the content process. Note that 76 * a given content process may have multiple browser instances (represented 77 * by BrowserChild instances), that are attached to different windows, and therefore 78 * rendered by different compositors. This means that when a browser instance 79 * sends messages via its CompositorBridgeChild, the corresponding 80 * ContentCompositorBridgeParent has to use the layers id in the message 81 * to find the correct compositor or CompositorBridgeParent to pass the message 82 * on to. 83 * 84 * One of the main goals of this protocol is to manage the PLayerTransaction sub- 85 * protocol, which is per-browser. A lot of the functions in the protocol are 86 * basically multiplexing/demultiplexing stuff in PLayerTransaction. 87 */ 88 [ParentImpl="CompositorBridgeParentBase"] 89 sync protocol PCompositorBridge 90 { 91 manager PCompositorManager; 92 93 manages PAPZ; 94 manages PAPZCTreeManager; 95 // A Compositor manages a single Layer Manager (PLayerTransaction) 96 manages PTexture; 97 manages PCompositorWidget; 98 manages PWebRenderBridge; 99 100 child: 101 // The compositor completed a layers transaction. id is the layers id 102 // of the child layer tree that was composited (or 0 when notifying 103 // the root layer tree). 104 // transactionId is the id of the transaction before this composite, or 0 105 // if there was no transaction since the last composite. 106 [Priority=control] async DidComposite(LayersId id, 107 TransactionId[] transactionId, 108 TimeStamp compositeStart, 109 TimeStamp compositeEnd); 110 111 async NotifyFrameStats(FrameStats[] aFrameStats); 112 113 async ParentAsyncMessages(AsyncParentMessageData[] aMessages); 114 115 async ObserveLayersUpdate(LayersId aLayersId, bool aActive); 116 117 async CompositorOptionsChanged(LayersId id, CompositorOptions newOptions); 118 119 async NotifyJankedAnimations(LayersId id, uint64_t[] aJankedAnimations); 120 121 parent: 122 async __delete__(); 123 124 // Must be called before Initialize(). 125 async PCompositorWidget(CompositorWidgetInitData aInitData); 126 127 // When out-of-process, this must be called to finish initialization. 128 sync Initialize(LayersId rootLayerTreeId); 129 130 // Must be called after Initialize(), and only succeeds if AsyncPanZoomEnabled() is true. 131 async PAPZ(LayersId layersId); 132 async PAPZCTreeManager(LayersId layersId); 133 134 // The child is about to be destroyed, so perform any necessary cleanup. 135 sync WillClose(); 136 137 // Pause/resume the compositor. These are intended to be used on mobile, when 138 // the compositor needs to pause/resume in lockstep with the application. 139 sync Pause(); 140 sync Resume(); 141 async ResumeAsync(); 142 143 // See bug 1316632 comment #33 for why this has to be sync. Otherwise, 144 // there are ordering issues with SendPLayerTransactionConstructor. 145 sync NotifyChildCreated(LayersId id) 146 returns (CompositorOptions compositorOptions); 147 148 // This version of NotifyChildCreated also performs a layer tree mapping. 149 // 150 // See bug 1316632 comment #33 for why this has to be sync. Otherwise, 151 // there are ordering issues with SendPLayerTransactionConstructor. 152 sync MapAndNotifyChildCreated(LayersId id, ProcessId owner) 153 returns (CompositorOptions compositorOptions); 154 155 async AdoptChild(LayersId id); 156 157 // Same as NotifyChildCreated, but used when child processes need to 158 // reassociate layers. This must be synchronous to ensure that the 159 // association happens before PLayerTransactions are sent over the 160 // cross-process bridge. 161 sync NotifyChildRecreated(LayersId id) 162 returns (CompositorOptions compositorOptions); 163 164 async NotifyMemoryPressure(); 165 166 // Make sure any pending composites are started immediately and 167 // block until they are completed. 168 sync FlushRendering(RenderReasons aReasons); 169 170 // Same as FlushRendering, but asynchronous, since not all platforms require 171 // synchronous repaints on resize. 172 async FlushRenderingAsync(RenderReasons aReasons); 173 174 // Make sure any pending composites have been received. 175 sync WaitOnTransactionProcessed(); 176 177 // Force an additional frame presentation to be executed. This is used to 178 // work around a windows presentation bug (See Bug 1232042) 179 async ForcePresent(RenderReasons aReasons); 180 181 sync StartFrameTimeRecording(int32_t bufferSize) 182 returns (uint32_t startIndex); 183 184 sync StopFrameTimeRecording(uint32_t startIndex) 185 returns (float[] intervals); 186 187 async PTexture(SurfaceDescriptor aSharedData, ReadLockDescriptor aReadLock, LayersBackend aBackend, TextureFlags aTextureFlags, LayersId id, uint64_t aSerial, MaybeExternalImageId aExternalImageId); 188 189 sync SyncWithCompositor(); 190 191 // The pipelineId is the same as the layersId 192 async PWebRenderBridge(PipelineId pipelineId, LayoutDeviceIntSize aSize, WindowKind aKind); 193 194 sync CheckContentOnlyTDR(uint32_t sequenceNum) 195 returns (bool isContentOnlyTDR); 196 197 async BeginRecording(TimeStamp aRecordingStart) 198 returns (bool success); 199 200 async EndRecording() 201 returns (FrameRecording? recording); 202 203 // To set up sharing the composited output to Firefox Reality on Desktop 204 async RequestFxrOutput(); 205 206 async DynamicToolbarOffsetChanged(int32_t aOffset); 207 }; 208 209 } // layers 210 } // mozilla