fune/gfx/webrender_bindings/RenderTextureHostWrapper.h
alwu efe35b01d5 Bug 1771011 - part2 : wrap media engine's dcomp handle, and use it on our gfx pipeline in the GPU process.r=jolin,sotaro
In this patch, we ask the media engine to return a handle for shareable
dcomp surface, which will then be packaged into a new texture data type
and being shared with the GPU process via the video bridge.

DcompSurfaceImage is the image which contains the handle texture data,
which doesn't support being accessed in the content process. When the
compositor uploads the image to the GPU process, the corresponding
texture host will be created.

The render texture host will be created by that texture host, and it
will be used in DCLayerTree. In DCLayerTree, we create a new type of
surface for our dcomp handle. DCSurfaceHandle will ask the render
texture host to reconstruct the surface by the handle shared from the
remote process (the handle is actually duplicated to the parent process
first due to the sandbox policy, and then be duplicated to the GPU
process later)

DCSurfaceHandle will attach that surface to its visual in order to
display the video frame directly. In the whole process, it's not
possible for Gecko to access any decoded video data which is protected by the
media engine itself.

Depends on D149941

Differential Revision: https://phabricator.services.mozilla.com/D151019
2022-08-13 23:48:07 +00:00

71 lines
2.6 KiB
C++

/* -*- 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
#include "RenderTextureHostSWGL.h"
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
* RenderTextureHosts(RenderDXGITextureHost and
* RenderDXGIYCbCrTextureHost) have overhead.
*/
class RenderTextureHostWrapper final : public RenderTextureHostSWGL {
public:
explicit RenderTextureHostWrapper(ExternalImageId aExternalImageId);
// RenderTextureHost
wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL,
wr::ImageRendering aRendering) override;
void Unlock() override;
void ClearCachedResources() override;
void PrepareForUse() override;
void NotifyForUse() override;
void NotifyNotUsed() override;
bool SyncObjectNeeded() override;
RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() override;
RenderDXGITextureHost* AsRenderDXGITextureHost() override;
RenderDXGIYCbCrTextureHost* AsRenderDXGIYCbCrTextureHost() override;
RenderDcompSurfaceTextureHost* AsRenderDcompSurfaceTextureHost() override;
// RenderTextureHostSWGL
size_t GetPlaneCount() const override;
gfx::SurfaceFormat GetFormat() const override;
gfx::ColorDepth GetColorDepth() const override;
gfx::YUVRangedColorSpace GetYUVColorSpace() const override;
bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) override;
void UnmapPlanes() override;
// This is just a wrapper, so doesn't need to report the
// size of the wrapped object (which reports itself).
size_t Bytes() override { return 0; }
private:
~RenderTextureHostWrapper() override;
void EnsureTextureHost() const;
RenderTextureHostSWGL* EnsureRenderTextureHostSWGL() const;
const ExternalImageId mExternalImageId;
mutable RefPtr<RenderTextureHost> mTextureHost;
};
} // namespace wr
} // namespace mozilla
#endif // MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H