summaryrefslogtreecommitdiffstats
path: root/gfx/layers/composite/RemoteTextureHostWrapper.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 /gfx/layers/composite/RemoteTextureHostWrapper.h
parentInitial commit. (diff)
downloadfirefox-upstream/124.0.1.tar.xz
firefox-upstream/124.0.1.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--gfx/layers/composite/RemoteTextureHostWrapper.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/gfx/layers/composite/RemoteTextureHostWrapper.h b/gfx/layers/composite/RemoteTextureHostWrapper.h
new file mode 100644
index 0000000000..5131ee4ae3
--- /dev/null
+++ b/gfx/layers/composite/RemoteTextureHostWrapper.h
@@ -0,0 +1,116 @@
+/* -*- 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_GFX_RemoteTextureHostWrapper_H
+#define MOZILLA_GFX_RemoteTextureHostWrapper_H
+
+#include "mozilla/layers/TextureHost.h"
+#include "mozilla/Monitor.h"
+
+namespace mozilla::layers {
+
+// This class wraps TextureHost of remote texture.
+// mRemoteTexture holds TextureHost of mTextureId.
+class RemoteTextureHostWrapper : public TextureHost {
+ public:
+ static RefPtr<TextureHost> Create(const RemoteTextureId aTextureId,
+ const RemoteTextureOwnerId aOwnerId,
+ const base::ProcessId aForPid,
+ const gfx::IntSize aSize,
+ const TextureFlags aFlags);
+
+ void DeallocateDeviceData() override {}
+
+ gfx::SurfaceFormat GetFormat() const override;
+
+ already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override {
+ return nullptr;
+ }
+
+ gfx::YUVColorSpace GetYUVColorSpace() const override;
+ gfx::ColorDepth GetColorDepth() const override;
+ gfx::ColorRange GetColorRange() const override;
+
+ gfx::IntSize GetSize() const override;
+
+ bool IsValid() override;
+
+#ifdef MOZ_LAYERS_HAVE_LOG
+ const char* Name() override { return "RemoteTextureHostWrapper"; }
+#endif
+
+ void CreateRenderTexture(
+ const wr::ExternalImageId& aExternalImageId) override;
+
+ uint32_t NumSubTextures() override;
+
+ void PushResourceUpdates(wr::TransactionBuilder& aResources,
+ ResourceUpdateOp aOp,
+ const Range<wr::ImageKey>& aImageKeys,
+ const wr::ExternalImageId& aExtID) override;
+
+ void PushDisplayItems(wr::DisplayListBuilder& aBuilder,
+ const wr::LayoutRect& aBounds,
+ const wr::LayoutRect& aClip, wr::ImageRendering aFilter,
+ const Range<wr::ImageKey>& aImageKeys,
+ PushDisplayItemFlagSet aFlags) override;
+
+ bool SupportsExternalCompositing(WebRenderBackend aBackend) override;
+
+ void UnbindTextureSource() override;
+
+ void NotifyNotUsed() override;
+
+ RemoteTextureHostWrapper* AsRemoteTextureHostWrapper() override {
+ return this;
+ }
+
+ TextureHostType GetTextureHostType() override;
+
+ bool IsWrappingSurfaceTextureHost() override;
+
+ bool NeedsDeferredDeletion() const override;
+
+ AndroidHardwareBuffer* GetAndroidHardwareBuffer() const override;
+
+ bool IsReadyForRendering();
+
+ void ApplyTextureFlagsToRemoteTexture();
+
+ const RemoteTextureId mTextureId;
+ const RemoteTextureOwnerId mOwnerId;
+ const base::ProcessId mForPid;
+ const gfx::IntSize mSize;
+
+ protected:
+ RemoteTextureHostWrapper(const RemoteTextureId aTextureId,
+ const RemoteTextureOwnerId aOwnerId,
+ const base::ProcessId aForPid,
+ const gfx::IntSize aSize, const TextureFlags aFlags);
+ virtual ~RemoteTextureHostWrapper();
+ void MaybeCreateRenderTexture();
+
+ // Called only by RemoteTextureMap
+ TextureHost* GetRemoteTextureHost(const MonitorAutoLock& aProofOfLock);
+ // Called only by RemoteTextureMap
+ void SetRemoteTextureHost(const MonitorAutoLock& aProofOfLock,
+ TextureHost* aTextureHost);
+ void ClearRemoteTextureHost(const MonitorAutoLock& aProofOfLock);
+
+ // Updated by RemoteTextureMap
+ //
+ // Hold compositable ref of remote texture's TextureHost that is used for
+ // building WebRender display list. It is TextureHost of mTextureId.
+ CompositableTextureHostRef mRemoteTexture;
+
+ bool mRenderTextureCreated = false;
+
+ friend class RemoteTextureMap;
+};
+
+} // namespace mozilla::layers
+
+#endif // MOZILLA_GFX_RemoteTextureHostWrapper_H