tor-browser

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

RemoteLayerTreeOwner.h (2769B)


      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_layout_RemoteLayerTreeOwner_h
      8 #define mozilla_layout_RemoteLayerTreeOwner_h
      9 
     10 #include "base/process.h"
     11 #include "mozilla/dom/ipc/IdType.h"
     12 #include "mozilla/layers/CompositorOptions.h"
     13 #include "mozilla/layers/LayersTypes.h"
     14 #include "nsDisplayList.h"
     15 
     16 class nsFrameLoader;
     17 class nsSubDocumentFrame;
     18 
     19 namespace mozilla {
     20 
     21 namespace dom {
     22 class BrowserParent;
     23 }  // namespace dom
     24 
     25 namespace layers {
     26 struct TextureFactoryIdentifier;
     27 }  // namespace layers
     28 
     29 namespace layout {
     30 
     31 /**
     32 * RemoteLayerTreeOwner connects and manages layer trees for remote frames. It
     33 * is directly owned by a BrowserParent and always lives in the parent process.
     34 */
     35 class RemoteLayerTreeOwner final {
     36  typedef mozilla::layers::CompositorOptions CompositorOptions;
     37  typedef mozilla::layers::LayerManager LayerManager;
     38  typedef mozilla::layers::LayersId LayersId;
     39  typedef mozilla::layers::TextureFactoryIdentifier TextureFactoryIdentifier;
     40 
     41 public:
     42  RemoteLayerTreeOwner();
     43  virtual ~RemoteLayerTreeOwner();
     44 
     45  bool Initialize(dom::BrowserParent* aBrowserParent);
     46  void Destroy();
     47 
     48  void EnsureLayersConnected(CompositorOptions* aCompositorOptions);
     49  bool AttachWindowRenderer();
     50  void OwnerContentChanged();
     51 
     52  LayersId GetLayersId() const { return mLayersId; }
     53  CompositorOptions GetCompositorOptions() const { return mCompositorOptions; }
     54 
     55  void GetTextureFactoryIdentifier(
     56      TextureFactoryIdentifier* aTextureFactoryIdentifier) const;
     57 
     58  bool IsInitialized() const { return mInitialized; }
     59  bool IsLayersConnected() const { return mLayersConnected; }
     60 
     61 private:
     62  // The process id of the remote frame. This is used by the compositor to
     63  // do security checks on incoming layer transactions.
     64  base::ProcessId mTabProcessId;
     65  // The layers id of the remote frame.
     66  LayersId mLayersId;
     67  // The compositor options for this layers id. This is only meaningful if
     68  // the compositor actually knows about this layers id (i.e. when
     69  // mLayersConnected is true).
     70  CompositorOptions mCompositorOptions;
     71 
     72  dom::BrowserParent* mBrowserParent;
     73  RefPtr<WindowRenderer> mWindowRenderer;
     74 
     75  bool mInitialized;
     76  // A flag that indicates whether or not the compositor knows about the
     77  // layers id. In some cases this RemoteLayerTreeOwner is not connected to the
     78  // compositor and so this flag is false.
     79  bool mLayersConnected;
     80 };
     81 
     82 }  // namespace layout
     83 }  // namespace mozilla
     84 
     85 #endif  // mozilla_layout_RemoteLayerTreeOwner_h