Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / gfx / webrender_bindings / RenderTextureHostWrapper.h
blob068cabe23cfc7e19c522f2e52b5415446c5c15de
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/. */
7 #ifndef MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H
8 #define MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H
10 #include "RenderTextureHostSWGL.h"
12 namespace mozilla {
14 namespace wr {
16 /**
17 * RenderTextureHost of GPUVideoTextureHost.
19 * GPUVideoTextureHost wraps TextureHost. This class wraps RenderTextureHost of
20 * the wrapped TextureHost. Lifetime of the wrapped TextureHost is usually
21 * longer than GPUVideoTextureHost and the wrapped TextureHost is used by
22 * multiple GPUVideoTextureHosts. This class is used to reduce recreations of
23 * the wrappded RenderTextureHost. Initializations of some
24 * RenderTextureHosts(RenderDXGITextureHost and
25 * RenderDXGIYCbCrTextureHost) have overhead.
27 class RenderTextureHostWrapper final : public RenderTextureHostSWGL {
28 public:
29 explicit RenderTextureHostWrapper(ExternalImageId aExternalImageId);
30 RenderTextureHostWrapper(const layers::RemoteTextureId aTextureId,
31 const layers::RemoteTextureOwnerId aOwnerId,
32 const base::ProcessId aForPid);
34 // RenderTextureHost
35 wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override;
36 void Unlock() override;
37 void ClearCachedResources() override;
38 void PrepareForUse() override;
39 void NotifyForUse() override;
40 void NotifyNotUsed() override;
41 bool SyncObjectNeeded() override;
42 RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() override;
43 RenderDXGITextureHost* AsRenderDXGITextureHost() override;
44 RenderDXGIYCbCrTextureHost* AsRenderDXGIYCbCrTextureHost() override;
45 RenderDcompSurfaceTextureHost* AsRenderDcompSurfaceTextureHost() override;
46 RenderAndroidHardwareBufferTextureHost*
47 AsRenderAndroidHardwareBufferTextureHost() override;
48 RenderAndroidSurfaceTextureHost* AsRenderAndroidSurfaceTextureHost() override;
49 RenderTextureHostSWGL* AsRenderTextureHostSWGL() override;
50 bool IsWrappingAsyncRemoteTexture() override;
51 void SetIsSoftwareDecodedVideo() override;
52 bool IsSoftwareDecodedVideo() override;
54 // RenderTextureHostSWGL
55 size_t GetPlaneCount() const override;
56 gfx::SurfaceFormat GetFormat() const override;
57 gfx::ColorDepth GetColorDepth() const override;
58 gfx::YUVRangedColorSpace GetYUVColorSpace() const override;
59 bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
60 PlaneInfo& aPlaneInfo) override;
61 void UnmapPlanes() override;
63 // This is just a wrapper, so doesn't need to report the
64 // size of the wrapped object (which reports itself).
65 size_t Bytes() override { return 0; }
67 protected:
68 // RenderTextureHost
69 std::pair<gfx::Point, gfx::Point> GetUvCoords(
70 gfx::IntSize aTextureSize) const override;
72 private:
73 ~RenderTextureHostWrapper() override;
75 void EnsureTextureHost() const;
76 void EnsureRemoteTexture() const;
77 RenderTextureHostSWGL* EnsureRenderTextureHostSWGL() const;
79 ExternalImageId mExternalImageId;
80 mutable RefPtr<RenderTextureHost> mTextureHost;
82 Maybe<layers::RemoteTextureId> mTextureId;
83 Maybe<layers::RemoteTextureOwnerId> mOwnerId;
84 Maybe<base::ProcessId> mForPid;
87 } // namespace wr
88 } // namespace mozilla
90 #endif // MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H