tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ContentCompositorBridgeParent.h (7081B)


      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 #ifndef mozilla_layers_ContentCompositorBridgeParent_h
      8 #define mozilla_layers_ContentCompositorBridgeParent_h
      9 
     10 #include "mozilla/ipc/ProtocolUtils.h"
     11 #include "mozilla/layers/CompositorBridgeParent.h"
     12 #include "mozilla/layers/CompositorThread.h"
     13 
     14 namespace mozilla::layers {
     15 
     16 class CompositorOptions;
     17 
     18 /**
     19 * This class handles layer updates pushed directly from child processes to
     20 * the compositor thread. It's associated with a CompositorBridgeParent on the
     21 * compositor thread. While it uses the PCompositorBridge protocol to manage
     22 * these updates, it doesn't actually drive compositing itself. For that it
     23 * hands off work to the CompositorBridgeParent it's associated with.
     24 */
     25 class ContentCompositorBridgeParent final : public CompositorBridgeParentBase {
     26  friend class CompositorBridgeParent;
     27 
     28 public:
     29  explicit ContentCompositorBridgeParent(CompositorManagerParent* aManager)
     30      : CompositorBridgeParentBase(aManager), mDestroyCalled(false) {}
     31 
     32  void ActorDestroy(ActorDestroyReason aWhy) override;
     33 
     34  // FIXME/bug 774388: work out what shutdown protocol we need.
     35  mozilla::ipc::IPCResult RecvInitialize(
     36      const LayersId& aRootLayerTreeId) override {
     37    return IPC_FAIL_NO_REASON(this);
     38  }
     39  mozilla::ipc::IPCResult RecvWillClose() override { return IPC_OK(); }
     40  mozilla::ipc::IPCResult RecvPause() override { return IPC_OK(); }
     41  mozilla::ipc::IPCResult RecvRequestFxrOutput() override {
     42    return IPC_FAIL_NO_REASON(this);
     43  }
     44  mozilla::ipc::IPCResult RecvResume() override { return IPC_OK(); }
     45  mozilla::ipc::IPCResult RecvResumeAsync() override { return IPC_OK(); }
     46  mozilla::ipc::IPCResult RecvNotifyChildCreated(
     47      const LayersId& child, CompositorOptions* aOptions) override;
     48  mozilla::ipc::IPCResult RecvMapAndNotifyChildCreated(
     49      const LayersId& child, const base::ProcessId& pid,
     50      CompositorOptions* aOptions) override;
     51  mozilla::ipc::IPCResult RecvNotifyChildRecreated(
     52      const LayersId& child, CompositorOptions* aOptions) override {
     53    return IPC_FAIL_NO_REASON(this);
     54  }
     55  mozilla::ipc::IPCResult RecvAdoptChild(const LayersId& child) override {
     56    return IPC_FAIL_NO_REASON(this);
     57  }
     58  mozilla::ipc::IPCResult RecvFlushRendering(
     59      const wr::RenderReasons&) override {
     60    return IPC_OK();
     61  }
     62  mozilla::ipc::IPCResult RecvFlushRenderingAsync(
     63      const wr::RenderReasons&) override {
     64    return IPC_OK();
     65  }
     66  mozilla::ipc::IPCResult RecvForcePresent(const wr::RenderReasons&) override {
     67    return IPC_OK();
     68  }
     69  mozilla::ipc::IPCResult RecvWaitOnTransactionProcessed() override {
     70    return IPC_OK();
     71  }
     72  mozilla::ipc::IPCResult RecvStartFrameTimeRecording(
     73      const int32_t& aBufferSize, uint32_t* aOutStartIndex) override {
     74    return IPC_OK();
     75  }
     76  mozilla::ipc::IPCResult RecvStopFrameTimeRecording(
     77      const uint32_t& aStartIndex, nsTArray<float>* intervals) override {
     78    return IPC_OK();
     79  }
     80 
     81  mozilla::ipc::IPCResult RecvNotifyMemoryPressure() override;
     82 
     83  mozilla::ipc::IPCResult RecvCheckContentOnlyTDR(
     84      const uint32_t& sequenceNum, bool* isContentOnlyTDR) override;
     85 
     86  mozilla::ipc::IPCResult RecvDynamicToolbarOffsetChanged(
     87      const int32_t& aOffset) override {
     88    return IPC_FAIL_NO_REASON(this);
     89  }
     90 
     91  mozilla::ipc::IPCResult RecvBeginRecording(
     92      const TimeStamp& aRecordingStart,
     93      BeginRecordingResolver&& aResolve) override {
     94    aResolve(false);
     95    return IPC_OK();
     96  }
     97 
     98  mozilla::ipc::IPCResult RecvEndRecording(
     99      EndRecordingResolver&& aResolve) override {
    100    aResolve(Nothing());
    101    return IPC_OK();
    102  }
    103 
    104  bool SetTestSampleTime(const LayersId& aId, const TimeStamp& aTime) override;
    105  void LeaveTestMode(const LayersId& aId) override;
    106  void SetTestAsyncScrollOffset(const LayersId& aLayersId,
    107                                const ScrollableLayerGuid::ViewID& aScrollId,
    108                                const CSSPoint& aPoint) override;
    109  void SetTestAsyncZoom(const LayersId& aLayersId,
    110                        const ScrollableLayerGuid::ViewID& aScrollId,
    111                        const LayerToParentLayerScale& aZoom) override;
    112  void FlushApzRepaints(const LayersId& aLayersId) override;
    113  void GetAPZTestData(const LayersId& aLayersId,
    114                      APZTestData* aOutData) override;
    115  void GetFrameUniformity(const LayersId& aLayersId,
    116                          FrameUniformityData* aOutData) override;
    117  void SetConfirmedTargetAPZC(
    118      const LayersId& aLayersId, const uint64_t& aInputBlockId,
    119      nsTArray<ScrollableLayerGuid>&& aTargets) override;
    120  void EndWheelTransaction(
    121      const LayersId& aLayersId,
    122      PWebRenderBridgeParent::EndWheelTransactionResolver&& aResolve) override;
    123 
    124  // Use DidCompositeLocked if you already hold a lock on
    125  // sIndirectLayerTreesLock; Otherwise use DidComposite, which would request
    126  // the lock automatically.
    127  void DidCompositeLocked(LayersId aId, const VsyncId& aVsyncId,
    128                          TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd);
    129 
    130  PTextureParent* AllocPTextureParent(
    131      const SurfaceDescriptor& aSharedData, ReadLockDescriptor& aReadLock,
    132      const LayersBackend& aLayersBackend, const TextureFlags& aFlags,
    133      const LayersId& aId, const uint64_t& aSerial,
    134      const wr::MaybeExternalImageId& aExternalImageId) override;
    135 
    136  bool DeallocPTextureParent(PTextureParent* actor) override;
    137 
    138  bool IsSameProcess() const override;
    139 
    140  already_AddRefed<PCompositorWidgetParent> AllocPCompositorWidgetParent(
    141      const CompositorWidgetInitData& aInitData) override {
    142    // Not allowed.
    143    return nullptr;
    144  }
    145 
    146  PAPZCTreeManagerParent* AllocPAPZCTreeManagerParent(
    147      const LayersId& aLayersId) override;
    148  bool DeallocPAPZCTreeManagerParent(PAPZCTreeManagerParent* aActor) override;
    149 
    150  PAPZParent* AllocPAPZParent(const LayersId& aLayersId) override;
    151  bool DeallocPAPZParent(PAPZParent* aActor) override;
    152 
    153  PWebRenderBridgeParent* AllocPWebRenderBridgeParent(
    154      const wr::PipelineId& aPipelineId, const LayoutDeviceIntSize& aSize,
    155      const WindowKind& aWindowKind) override;
    156  bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
    157 
    158  void ObserveLayersUpdate(LayersId aLayersId, bool aActive) override;
    159 
    160  bool IsRemote() const override { return true; }
    161 
    162 private:
    163  // Private destructor, to discourage deletion outside of Release():
    164  virtual ~ContentCompositorBridgeParent();
    165 
    166  void DeferredDestroy();
    167 
    168  // There can be many CPCPs, and IPDL-generated code doesn't hold a
    169  // reference to top-level actors.  So we hold a reference to
    170  // ourself.  This is released (deferred) in ActorDestroy().
    171  RefPtr<ContentCompositorBridgeParent> mSelfRef;
    172 
    173  bool mDestroyCalled;
    174 };
    175 
    176 }  // namespace mozilla::layers
    177 
    178 #endif  // mozilla_layers_ContentCompositorBridgeParent_h