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"
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
{
29 explicit RenderTextureHostWrapper(ExternalImageId aExternalImageId
);
32 wr::WrExternalImage
Lock(uint8_t aChannelIndex
, gl::GLContext
* aGL
,
33 wr::ImageRendering aRendering
) override
;
34 void Unlock() override
;
35 void ClearCachedResources() override
;
36 RenderMacIOSurfaceTextureHost
* AsRenderMacIOSurfaceTextureHost() override
;
37 RenderDXGITextureHost
* AsRenderDXGITextureHost() override
;
38 RenderDXGIYCbCrTextureHost
* AsRenderDXGIYCbCrTextureHost() override
;
40 // RenderTextureHostSWGL
41 size_t GetPlaneCount() const override
;
42 gfx::SurfaceFormat
GetFormat() const override
;
43 gfx::ColorDepth
GetColorDepth() const override
;
44 gfx::YUVColorSpace
GetYUVColorSpace() const override
;
45 bool MapPlane(RenderCompositor
* aCompositor
, uint8_t aChannelIndex
,
46 PlaneInfo
& aPlaneInfo
) override
;
47 void UnmapPlanes() override
;
49 // This is just a wrapper, so doesn't need to report the
50 // size of the wrapped object (which reports itself).
51 size_t Bytes() override
{ return 0; }
54 ~RenderTextureHostWrapper() override
;
56 void EnsureTextureHost() const;
57 RenderTextureHostSWGL
* EnsureRenderTextureHostSWGL() const;
59 const ExternalImageId mExternalImageId
;
60 mutable RefPtr
<RenderTextureHost
> mTextureHost
;
64 } // namespace mozilla
66 #endif // MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H