tor-browser

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

RemoteImageHolder.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_dom_media_RemoteImageHolder_h
      8 #define mozilla_dom_media_RemoteImageHolder_h
      9 
     10 #include "MediaData.h"
     11 #include "ipc/IPCMessageUtils.h"
     12 #include "mozilla/Maybe.h"
     13 #include "mozilla/RefPtr.h"
     14 #include "mozilla/layers/LayersSurfaces.h"
     15 #include "mozilla/layers/VideoBridgeUtils.h"
     16 
     17 namespace mozilla {
     18 namespace layers {
     19 class BufferRecycleBin;
     20 class IGPUVideoSurfaceManager;
     21 class SurfaceDescriptor;
     22 }  // namespace layers
     23 class RemoteImageHolder final {
     24  friend struct IPC::ParamTraits<RemoteImageHolder>;
     25 
     26 public:
     27  RemoteImageHolder();
     28  explicit RemoteImageHolder(layers::SurfaceDescriptor&& aSD);
     29  RemoteImageHolder(
     30      layers::IGPUVideoSurfaceManager* aManager,
     31      layers::VideoBridgeSource aSource, const gfx::IntSize& aSize,
     32      const gfx::ColorDepth& aColorDepth, const layers::SurfaceDescriptor& aSD,
     33      gfx::YUVColorSpace aYUVColorSpace, gfx::ColorSpace2 aColorPrimaries,
     34      gfx::TransferFunction aTransferFunction, gfx::ColorRange aColorRange);
     35  RemoteImageHolder(RemoteImageHolder&& aOther);
     36  // Ensure we never copy this object.
     37  RemoteImageHolder(const RemoteImageHolder& aOther) = delete;
     38  RemoteImageHolder& operator=(const RemoteImageHolder& aOther) = delete;
     39  ~RemoteImageHolder();
     40 
     41  bool IsEmpty() const { return mSD.isNothing(); }
     42  // Move content of RemoteImageHolder into a usable Image. Ownership is
     43  // transfered to that Image.
     44  already_AddRefed<layers::Image> TransferToImage(
     45      layers::BufferRecycleBin* aBufferRecycleBin = nullptr);
     46 
     47 private:
     48  already_AddRefed<layers::Image> DeserializeImage(
     49      layers::BufferRecycleBin* aBufferRecycleBin);
     50  // We need a default for the default constructor, never used in practice.
     51  layers::VideoBridgeSource mSource = layers::VideoBridgeSource::GpuProcess;
     52  gfx::IntSize mSize;
     53  gfx::ColorDepth mColorDepth = gfx::ColorDepth::COLOR_8;
     54  Maybe<layers::SurfaceDescriptor> mSD;
     55  RefPtr<layers::IGPUVideoSurfaceManager> mManager;
     56  gfx::YUVColorSpace mYUVColorSpace = {};
     57  gfx::ColorSpace2 mColorPrimaries = {};
     58  gfx::TransferFunction mTransferFunction = {};
     59  gfx::ColorRange mColorRange = {};
     60 };
     61 
     62 }  // namespace mozilla
     63 
     64 template <>
     65 struct IPC::ParamTraits<mozilla::RemoteImageHolder> {
     66  static void Write(MessageWriter* aWriter,
     67                    mozilla::RemoteImageHolder&& aParam);
     68  static bool Read(MessageReader* aReader, mozilla::RemoteImageHolder* aResult);
     69 };
     70 
     71 #endif  // mozilla_dom_media_RemoteImageHolder_h