summaryrefslogtreecommitdiffstats
path: root/dom/media/ipc/RemoteImageHolder.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/media/ipc/RemoteImageHolder.h
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/ipc/RemoteImageHolder.h')
-rw-r--r--dom/media/ipc/RemoteImageHolder.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/dom/media/ipc/RemoteImageHolder.h b/dom/media/ipc/RemoteImageHolder.h
new file mode 100644
index 0000000000..981e24d150
--- /dev/null
+++ b/dom/media/ipc/RemoteImageHolder.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_media_RemoteImageHolder_h
+#define mozilla_dom_media_RemoteImageHolder_h
+
+#include "MediaData.h"
+#include "ipc/IPCMessageUtils.h"
+#include "mozilla/Maybe.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/layers/LayersSurfaces.h"
+#include "mozilla/layers/VideoBridgeUtils.h"
+
+namespace mozilla {
+namespace layers {
+class BufferRecycleBin;
+class IGPUVideoSurfaceManager;
+class SurfaceDescriptor;
+} // namespace layers
+class RemoteImageHolder final {
+ friend struct ipc::IPDLParamTraits<RemoteImageHolder>;
+
+ public:
+ RemoteImageHolder();
+ RemoteImageHolder(
+ layers::IGPUVideoSurfaceManager* aManager,
+ layers::VideoBridgeSource aSource, const gfx::IntSize& aSize,
+ const gfx::ColorDepth& aColorDepth, const layers::SurfaceDescriptor& aSD,
+ gfx::YUVColorSpace aYUVColorSpace, gfx::ColorSpace2 aColorPrimaries,
+ gfx::TransferFunction aTransferFunction, gfx::ColorRange aColorRange);
+ RemoteImageHolder(RemoteImageHolder&& aOther);
+ // Ensure we never copy this object.
+ RemoteImageHolder(const RemoteImageHolder& aOther) = delete;
+ RemoteImageHolder& operator=(const RemoteImageHolder& aOther) = delete;
+ ~RemoteImageHolder();
+
+ bool IsEmpty() const { return mSD.isNothing(); }
+ // Move content of RemoteImageHolder into a usable Image. Ownership is
+ // transfered to that Image.
+ already_AddRefed<layers::Image> TransferToImage(
+ layers::BufferRecycleBin* aBufferRecycleBin = nullptr);
+
+ private:
+ already_AddRefed<layers::Image> DeserializeImage(
+ layers::BufferRecycleBin* aBufferRecycleBin);
+ // We need a default for the default constructor, never used in practice.
+ layers::VideoBridgeSource mSource = layers::VideoBridgeSource::GpuProcess;
+ gfx::IntSize mSize;
+ gfx::ColorDepth mColorDepth = gfx::ColorDepth::COLOR_8;
+ Maybe<layers::SurfaceDescriptor> mSD;
+ RefPtr<layers::IGPUVideoSurfaceManager> mManager;
+ gfx::YUVColorSpace mYUVColorSpace = {};
+ gfx::ColorSpace2 mColorPrimaries = {};
+ gfx::TransferFunction mTransferFunction = {};
+ gfx::ColorRange mColorRange = {};
+};
+
+ template <>
+ struct ipc::IPDLParamTraits<RemoteImageHolder> {
+ static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor,
+ RemoteImageHolder&& aParam);
+ static bool Read(IPC::MessageReader* aReader, IProtocol* aActor,
+ RemoteImageHolder* aResult);
+};
+
+} // namespace mozilla
+
+#endif // mozilla_dom_media_RemoteImageHolder_h