Update configs. IGNORE BROKEN CHANGESETS CLOSED TREE NO BUG a=release ba=release
[gecko.git] / gfx / webrender_bindings / RenderTextureHostWrapper.h
blob67f26b2a6585cb76ca4ed4e5440cad001e63543f
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);
31 // RenderTextureHost
32 wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override;
33 void Unlock() override;
34 void ClearCachedResources() override;
35 void PrepareForUse() override;
36 void NotifyForUse() override;
37 void NotifyNotUsed() override;
38 bool SyncObjectNeeded() override;
39 RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() override;
40 RenderDXGITextureHost* AsRenderDXGITextureHost() override;
41 RenderDXGIYCbCrTextureHost* AsRenderDXGIYCbCrTextureHost() override;
42 RenderDcompSurfaceTextureHost* AsRenderDcompSurfaceTextureHost() override;
43 RenderAndroidHardwareBufferTextureHost*
44 AsRenderAndroidHardwareBufferTextureHost() override;
45 RenderAndroidSurfaceTextureHost* AsRenderAndroidSurfaceTextureHost() override;
46 RenderTextureHostSWGL* AsRenderTextureHostSWGL() override;
47 void SetIsSoftwareDecodedVideo() override;
48 bool IsSoftwareDecodedVideo() override;
50 // RenderTextureHostSWGL
51 size_t GetPlaneCount() const override;
52 gfx::SurfaceFormat GetFormat() const override;
53 gfx::ColorDepth GetColorDepth() const override;
54 gfx::YUVRangedColorSpace GetYUVColorSpace() const override;
55 bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
56 PlaneInfo& aPlaneInfo) override;
57 void UnmapPlanes() override;
59 // This is just a wrapper, so doesn't need to report the
60 // size of the wrapped object (which reports itself).
61 size_t Bytes() override { return 0; }
63 protected:
64 // RenderTextureHost
65 std::pair<gfx::Point, gfx::Point> GetUvCoords(
66 gfx::IntSize aTextureSize) const override;
68 private:
69 ~RenderTextureHostWrapper() override;
71 void EnsureTextureHost() const;
72 RenderTextureHostSWGL* EnsureRenderTextureHostSWGL() const;
74 ExternalImageId mExternalImageId;
75 mutable RefPtr<RenderTextureHost> mTextureHost;
78 } // namespace wr
79 } // namespace mozilla
81 #endif // MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H