summaryrefslogtreecommitdiffstats
path: root/gfx/webrender_bindings/RenderDcompSurfaceTextureHost.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /gfx/webrender_bindings/RenderDcompSurfaceTextureHost.h
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/webrender_bindings/RenderDcompSurfaceTextureHost.h')
-rw-r--r--gfx/webrender_bindings/RenderDcompSurfaceTextureHost.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/gfx/webrender_bindings/RenderDcompSurfaceTextureHost.h b/gfx/webrender_bindings/RenderDcompSurfaceTextureHost.h
new file mode 100644
index 0000000000..7533e7c75f
--- /dev/null
+++ b/gfx/webrender_bindings/RenderDcompSurfaceTextureHost.h
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: ; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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_GFX_RENDERDCOMPSURFACETEXTUREHOST_H
+#define MOZILLA_GFX_RENDERDCOMPSURFACETEXTUREHOST_H
+
+#include "GLTypes.h"
+#include "RenderTextureHostSWGL.h"
+#include "mozilla/webrender/RenderThread.h"
+
+struct IDCompositionDevice;
+struct IDCompositionSurface;
+
+inline mozilla::LazyLogModule gDcompSurface("DcompSurface");
+
+namespace mozilla::wr {
+
+/**
+ * A render texture host is responsible to create a dcomp surface from an
+ * existing dcomp handle. Currently usage is that MF media engine will create
+ * a surface handle from another remote process, and we reconstruct the surface
+ * and use it in the DCLayerTree in the GPU process.
+ */
+class RenderDcompSurfaceTextureHost final : public RenderTextureHostSWGL {
+ public:
+ RenderDcompSurfaceTextureHost(HANDLE aHandle, gfx::IntSize aSize,
+ gfx::SurfaceFormat aFormat);
+
+ // RenderTextureHost
+ RenderDcompSurfaceTextureHost* AsRenderDcompSurfaceTextureHost() override {
+ return this;
+ }
+
+ // RenderTextureHostSWGL
+ gfx::SurfaceFormat GetFormat() const override { return mFormat; }
+ gfx::ColorDepth GetColorDepth() const override {
+ return gfx::ColorDepth::COLOR_8;
+ }
+ size_t GetPlaneCount() const override { return 1; }
+ bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
+ PlaneInfo& aPlaneInfo) override {
+ return false;
+ }
+ void UnmapPlanes() override {}
+ gfx::YUVRangedColorSpace GetYUVColorSpace() const override {
+ return gfx::YUVRangedColorSpace::GbrIdentity;
+ }
+ size_t Bytes() override { return 0; }
+
+ gfx::IntSize GetSize() const { return mSize; };
+
+ HANDLE GetDcompSurfaceHandle() const { return mHandle; }
+
+ // Not thread-safe. They should only be called on the renderer thread on the
+ // GPU process.
+ IDCompositionSurface* CreateSurfaceFromDevice(IDCompositionDevice* aDevice);
+ IDCompositionSurface* GetSurface() const { return mDcompSurface; };
+
+ private:
+ const HANDLE mHandle;
+ const gfx::IntSize mSize;
+ const gfx::SurfaceFormat mFormat;
+ RefPtr<IDCompositionSurface> mDcompSurface;
+};
+
+} // namespace mozilla::wr
+
+#endif // MOZILLA_GFX_RENDERDCOMPSURFACETEXTUREHOST_H