2020-05-22 22:42:38 +03:00
|
|
|
/* -*- 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_RENDERTEXTUREHOSTWRAPPER_H
|
|
|
|
#define MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H
|
|
|
|
|
2020-10-02 01:18:52 +03:00
|
|
|
#include "RenderTextureHostSWGL.h"
|
2020-05-22 22:42:38 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace wr {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RenderTextureHost of GPUVideoTextureHost.
|
|
|
|
*
|
|
|
|
* GPUVideoTextureHost wraps TextureHost. This class wraps RenderTextureHost of
|
|
|
|
* the wrapped TextureHost. Lifetime of the wrapped TextureHost is usually
|
|
|
|
* longer than GPUVideoTextureHost and the wrapped TextureHost is used by
|
|
|
|
* multiple GPUVideoTextureHosts. This class is used to reduce recreations of
|
|
|
|
* the wrappded RenderTextureHost. Initializations of some
|
2020-10-14 10:58:18 +03:00
|
|
|
* RenderTextureHosts(RenderDXGITextureHost and
|
|
|
|
* RenderDXGIYCbCrTextureHost) have overhead.
|
2020-05-22 22:42:38 +03:00
|
|
|
*/
|
2020-10-02 01:18:52 +03:00
|
|
|
class RenderTextureHostWrapper final : public RenderTextureHostSWGL {
|
2020-05-22 22:42:38 +03:00
|
|
|
public:
|
|
|
|
explicit RenderTextureHostWrapper(ExternalImageId aExternalImageId);
|
|
|
|
|
2020-10-02 01:18:52 +03:00
|
|
|
// RenderTextureHost
|
2020-05-22 22:42:38 +03:00
|
|
|
wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL,
|
|
|
|
wr::ImageRendering aRendering) override;
|
|
|
|
void Unlock() override;
|
|
|
|
void ClearCachedResources() override;
|
2020-10-14 10:58:18 +03:00
|
|
|
RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() override;
|
|
|
|
RenderDXGITextureHost* AsRenderDXGITextureHost() override;
|
2020-08-04 04:19:59 +03:00
|
|
|
|
2020-10-02 01:18:52 +03:00
|
|
|
// RenderTextureHostSWGL
|
2020-10-22 06:59:17 +03:00
|
|
|
size_t GetPlaneCount() const override;
|
|
|
|
gfx::SurfaceFormat GetFormat() const override;
|
|
|
|
gfx::ColorDepth GetColorDepth() const override;
|
|
|
|
gfx::YUVColorSpace GetYUVColorSpace() const override;
|
2020-11-06 01:10:34 +03:00
|
|
|
bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) override;
|
2020-10-02 01:18:52 +03:00
|
|
|
void UnmapPlanes() override;
|
2020-09-09 04:04:53 +03:00
|
|
|
|
2020-05-22 22:42:38 +03:00
|
|
|
private:
|
|
|
|
~RenderTextureHostWrapper() override;
|
|
|
|
|
2020-10-02 01:18:52 +03:00
|
|
|
void EnsureTextureHost() const;
|
2020-10-22 06:59:17 +03:00
|
|
|
RenderTextureHostSWGL* EnsureRenderTextureHostSWGL() const;
|
2020-08-04 04:19:59 +03:00
|
|
|
|
2020-05-22 22:42:38 +03:00
|
|
|
const ExternalImageId mExternalImageId;
|
2020-10-02 01:18:52 +03:00
|
|
|
mutable RefPtr<RenderTextureHost> mTextureHost;
|
2020-05-22 22:42:38 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H
|