tor-browser

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

CompositorSession.h (3584B)


      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 #ifndef _include_mozilla_gfx_ipc_CompositorSession_h_
      7 #define _include_mozilla_gfx_ipc_CompositorSession_h_
      8 
      9 #include "base/basictypes.h"
     10 #include "mozilla/layers/LayersTypes.h"
     11 #include "mozilla/layers/CompositorTypes.h"
     12 #include "nsISupportsImpl.h"
     13 #if defined(MOZ_WIDGET_ANDROID)
     14 #  include "mozilla/layers/UiCompositorControllerChild.h"
     15 #endif  // defined(MOZ_WIDGET_ANDROID)
     16 
     17 class nsIWidget;
     18 
     19 namespace mozilla {
     20 namespace widget {
     21 class CompositorWidget;
     22 class CompositorWidgetDelegate;
     23 }  // namespace widget
     24 namespace gfx {
     25 class GPUProcessHost;
     26 class GPUProcessManager;
     27 }  // namespace gfx
     28 namespace layers {
     29 
     30 class GeckoContentController;
     31 class IAPZCTreeManager;
     32 class CompositorBridgeParent;
     33 class CompositorBridgeChild;
     34 class ClientLayerManager;
     35 
     36 // A CompositorSession provides access to a compositor without exposing whether
     37 // or not it's in-process or out-of-process.
     38 class CompositorSession {
     39  friend class gfx::GPUProcessManager;
     40 
     41 protected:
     42  typedef gfx::GPUProcessHost GPUProcessHost;
     43  typedef widget::CompositorWidget CompositorWidget;
     44  typedef widget::CompositorWidgetDelegate CompositorWidgetDelegate;
     45 
     46 public:
     47  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorSession)
     48 
     49  virtual void Shutdown() = 0;
     50 
     51  // This returns a CompositorBridgeParent if the compositor resides in the same
     52  // process.
     53  virtual CompositorBridgeParent* GetInProcessBridge() const = 0;
     54 
     55  // Set the GeckoContentController for the root of the layer tree.
     56  virtual void SetContentController(GeckoContentController* aController) = 0;
     57 
     58  // Return the Async Pan/Zoom Tree Manager for this compositor.
     59  virtual RefPtr<IAPZCTreeManager> GetAPZCTreeManager() const = 0;
     60 
     61  // Return the child end of the compositor IPC bridge.
     62  CompositorBridgeChild* GetCompositorBridgeChild();
     63 
     64  // Return the proxy for accessing the compositor's widget.
     65  CompositorWidgetDelegate* GetCompositorWidgetDelegate() {
     66    return mCompositorWidgetDelegate;
     67  }
     68 
     69  // Return the id of the root layer tree.
     70  LayersId RootLayerTreeId() const { return mRootLayerTreeId; }
     71 
     72 #if defined(MOZ_WIDGET_ANDROID)
     73  // Set the UiCompositorControllerChild after Session creation so the Session
     74  // constructor doesn't get mucked up for other platforms.
     75  void SetUiCompositorControllerChild(
     76      RefPtr<UiCompositorControllerChild>&& aUiController) {
     77    mUiCompositorControllerChild = std::move(aUiController);
     78  }
     79 
     80  RefPtr<UiCompositorControllerChild> GetUiCompositorControllerChild() {
     81    return mUiCompositorControllerChild;
     82  }
     83 #endif  // defined(MOZ_WIDGET_ANDROID)
     84 protected:
     85  CompositorSession(nsIWidget* aWidget, CompositorWidgetDelegate* aDelegate,
     86                    CompositorBridgeChild* aChild,
     87                    const LayersId& aRootLayerTreeId);
     88  virtual ~CompositorSession();
     89 
     90 protected:
     91  nsIWidget* mWidget;
     92  CompositorWidgetDelegate* mCompositorWidgetDelegate;
     93  RefPtr<CompositorBridgeChild> mCompositorBridgeChild;
     94  LayersId mRootLayerTreeId;
     95 #if defined(MOZ_WIDGET_ANDROID)
     96  RefPtr<UiCompositorControllerChild> mUiCompositorControllerChild;
     97 #endif  // defined(MOZ_WIDGET_ANDROID)
     98 private:
     99  DISALLOW_COPY_AND_ASSIGN(CompositorSession);
    100 };
    101 
    102 }  // namespace layers
    103 }  // namespace mozilla
    104 
    105 #endif  // _include_mozilla_gfx_ipc_CompositorSession_h_