tor-browser

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

RenderRootStateManager.h (4102B)


      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 GFX_RENDERROOTSTATEMANAGER_H
      8 #define GFX_RENDERROOTSTATEMANAGER_H
      9 
     10 #include "mozilla/webrender/WebRenderAPI.h"
     11 
     12 #include "mozilla/layers/IpcResourceUpdateQueue.h"
     13 #include "mozilla/layers/SharedSurfacesChild.h"
     14 #include "mozilla/layers/WebRenderCommandBuilder.h"
     15 #include "nsTHashSet.h"
     16 
     17 namespace mozilla {
     18 
     19 namespace layers {
     20 
     21 class RenderRootStateManager {
     22  typedef nsTHashSet<RefPtr<WebRenderUserData>> WebRenderUserDataRefTable;
     23 
     24 public:
     25  void AddRef();
     26  void Release();
     27 
     28  RenderRootStateManager() : mLayerManager(nullptr), mDestroyed(false) {}
     29 
     30  void Destroy();
     31  bool IsDestroyed() { return mDestroyed; }
     32  wr::IpcResourceUpdateQueue& AsyncResourceUpdates();
     33  WebRenderBridgeChild* WrBridge() const;
     34  WebRenderCommandBuilder& CommandBuilder();
     35  WebRenderUserDataRefTable* GetWebRenderUserDataTable();
     36  WebRenderLayerManager* LayerManager() { return mLayerManager; }
     37 
     38  void AddImageKeyForDiscard(wr::ImageKey);
     39  void AddBlobImageKeyForDiscard(wr::BlobImageKey);
     40  void AddSnapshotImageKeyForDiscard(wr::SnapshotImageKey);
     41  void AddUnusedSnapshotImageKeyForDiscard(wr::SnapshotImageKey);
     42  void DiscardImagesInTransaction(wr::IpcResourceUpdateQueue& aResources);
     43  void DiscardUnusedImagesInTransaction(wr::IpcResourceUpdateQueue& aResources);
     44  void DiscardLocalImages();
     45 
     46  void ClearCachedResources();
     47 
     48  // Methods to manage the compositor animation ids. Active animations are still
     49  // going, and when they end we discard them and remove them from the active
     50  // list.
     51  void AddActiveCompositorAnimationId(uint64_t aId);
     52  void AddCompositorAnimationsIdForDiscard(uint64_t aId);
     53  void DiscardCompositorAnimations();
     54 
     55  void RegisterAsyncAnimation(const wr::ImageKey& aKey,
     56                              SharedSurfacesAnimation* aAnimation);
     57  void DeregisterAsyncAnimation(const wr::ImageKey& aKey);
     58  void ClearAsyncAnimations();
     59  void WrReleasedImages(const nsTArray<wr::ExternalImageKeyPair>& aPairs);
     60 
     61  void AddWebRenderParentCommand(const WebRenderParentCommand& aCmd);
     62  void UpdateResources(wr::IpcResourceUpdateQueue& aResources);
     63  void AddPipelineIdForCompositable(const wr::PipelineId& aPipelineId,
     64                                    const CompositableHandle& aHandle,
     65                                    CompositableHandleOwner aOwner);
     66  void RemovePipelineIdForCompositable(const wr::PipelineId& aPipelineId);
     67  /// Release TextureClient that is bounded to ImageKey.
     68  /// It is used for recycling TextureClient.
     69  void ReleaseTextureOfImage(const wr::ImageKey& aKey);
     70  Maybe<wr::FontInstanceKey> GetFontKeyForScaledFont(
     71      gfx::ScaledFont* aScaledFont, wr::IpcResourceUpdateQueue& aResources);
     72  Maybe<wr::FontKey> GetFontKeyForUnscaledFont(
     73      gfx::UnscaledFont* aUnscaledFont, wr::IpcResourceUpdateQueue& aResources);
     74 
     75  void FlushAsyncResourceUpdates();
     76 
     77 private:
     78  WebRenderLayerManager* mLayerManager;
     79  Maybe<wr::IpcResourceUpdateQueue> mAsyncResourceUpdates;
     80  nsTArray<wr::ImageKey> mImageKeysToDelete;
     81  nsTArray<wr::BlobImageKey> mBlobImageKeysToDelete;
     82  nsTArray<wr::SnapshotImageKey> mSnapshotImageKeysToDelete;
     83  nsTArray<wr::SnapshotImageKey> mUnusedSnapshotImageKeysToDelete;
     84  std::unordered_map<uint64_t, RefPtr<SharedSurfacesAnimation>>
     85      mAsyncAnimations;
     86 
     87  // Set of compositor animation ids for which there are active animations (as
     88  // of the last transaction) on the compositor side.
     89  std::unordered_set<uint64_t> mActiveCompositorAnimationIds;
     90  // Compositor animation ids for animations that are done now and that we want
     91  // the compositor to discard information for.
     92  nsTArray<uint64_t> mDiscardedCompositorAnimationsIds;
     93 
     94  bool mDestroyed;
     95 
     96  friend class WebRenderLayerManager;
     97 };
     98 
     99 }  // namespace layers
    100 }  // namespace mozilla
    101 
    102 #endif /* GFX_RENDERROOTSTATEMANAGER_H */