Bug 1682030 - Remove NPAPI plugin async rendering support r=bas,jgilbert,ipc-reviewers,mccr8

Removes async (windowless) NPAPI plugin rendering methods used to render a plugin to an offscreen surface in the GPU process.  None of this code is used since we have removed all NPAPI plugin support.

Differential Revision: https://phabricator.services.mozilla.com/D107152
This commit is contained in:
David Parks 2021-04-05 23:48:40 +00:00
parent 0fcbfe4bda
commit bd753c5ff6
11 changed files with 0 additions and 434 deletions

View File

@ -1241,12 +1241,6 @@ bool GLBlitHelper::BlitImage(layers::GPUVideoImage* const srcImage,
const auto& desc = data->SD();
if (desc.type() ==
layers::SurfaceDescriptorGPUVideo::TSurfaceDescriptorPlugin) {
MOZ_ASSERT_UNREACHABLE(
"BlitImage does not support plugin surface descriptors");
return false;
}
MOZ_ASSERT(
desc.type() ==
layers::SurfaceDescriptorGPUVideo::TSurfaceDescriptorRemoteDecoder);

View File

@ -355,19 +355,6 @@ already_AddRefed<TextureHost> CreateBackendIndependentTextureHost(
break;
}
case SurfaceDescriptor::TSurfaceDescriptorGPUVideo: {
if (aDesc.get_SurfaceDescriptorGPUVideo().type() ==
SurfaceDescriptorGPUVideo::TSurfaceDescriptorPlugin) {
MOZ_ASSERT(aDeallocator && aDeallocator->UsesImageBridge());
auto ibpBase = static_cast<ImageBridgeParent*>(aDeallocator);
result =
ibpBase->LookupTextureHost(aDesc.get_SurfaceDescriptorGPUVideo());
if (!result) {
return nullptr;
}
MOZ_ASSERT(aFlags == result->GetFlags());
break;
}
MOZ_ASSERT(aDesc.get_SurfaceDescriptorGPUVideo().type() ==
SurfaceDescriptorGPUVideo::TSurfaceDescriptorRemoteDecoder);
result = GPUVideoTextureHost::CreateFromDescriptor(

View File

@ -33,8 +33,6 @@
#include "mozilla/layers/PCompositorBridgeParent.h"
#include "mozilla/webrender/WebRenderTypes.h"
struct DxgiAdapterDesc;
namespace mozilla {
class CancelableRunnable;
@ -295,14 +293,6 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent,
Endpoint<PCanvasParent>&& aEndpoint) = 0;
virtual mozilla::ipc::IPCResult RecvReleasePCanvasParent() = 0;
virtual mozilla::ipc::IPCResult RecvSupportsAsyncDXGISurface(bool* value) {
return IPC_FAIL_NO_REASON(this);
}
virtual mozilla::ipc::IPCResult RecvPreferredDXGIAdapter(
DxgiAdapterDesc* desc) {
return IPC_FAIL_NO_REASON(this);
}
virtual already_AddRefed<PWebGLParent> AllocPWebGLParent() = 0;
bool mCanSend;

View File

@ -15,7 +15,6 @@
# include "mozilla/gfx/DeviceManagerDx.h" // for DeviceManagerDx
# include "mozilla/layers/ImageDataSerializer.h"
#endif
#include "mozilla/D3DMessageUtils.h" // for DxgiAdapterDesc
#include "mozilla/dom/WebGLParent.h"
#include "mozilla/ipc/Transport.h" // for Transport
#include "mozilla/layers/AnimationHelper.h" // for CompositorAnimationStorage
@ -684,63 +683,6 @@ void ContentCompositorBridgeParent::ObserveLayersUpdate(
Unused << state->mParent->SendObserveLayersUpdate(aLayersId, aEpoch, aActive);
}
static inline bool AllowDirectDXGISurfaceDrawing() {
if (!StaticPrefs::dom_ipc_plugins_asyncdrawing_enabled()) {
return false;
}
#if defined(XP_WIN)
gfx::DeviceManagerDx* dm = gfx::DeviceManagerDx::Get();
MOZ_ASSERT(dm);
if (!dm || !dm->GetCompositorDevice() || !dm->TextureSharingWorks()) {
return false;
}
return true;
#else
return false;
#endif
}
mozilla::ipc::IPCResult
ContentCompositorBridgeParent::RecvSupportsAsyncDXGISurface(bool* value) {
*value = AllowDirectDXGISurfaceDrawing();
return IPC_OK();
}
mozilla::ipc::IPCResult ContentCompositorBridgeParent::RecvPreferredDXGIAdapter(
DxgiAdapterDesc* aOutDesc) {
PodZero(aOutDesc);
#ifdef XP_WIN
if (!AllowDirectDXGISurfaceDrawing()) {
return IPC_FAIL_NO_REASON(this);
}
RefPtr<ID3D11Device> device =
gfx::DeviceManagerDx::Get()->GetCompositorDevice();
if (!device) {
return IPC_FAIL_NO_REASON(this);
}
RefPtr<IDXGIDevice> dxgi;
if (FAILED(device->QueryInterface(__uuidof(IDXGIDevice),
getter_AddRefs(dxgi))) ||
!dxgi) {
return IPC_FAIL_NO_REASON(this);
}
RefPtr<IDXGIAdapter> adapter;
if (FAILED(dxgi->GetAdapter(getter_AddRefs(adapter))) || !adapter) {
return IPC_FAIL_NO_REASON(this);
}
DXGI_ADAPTER_DESC desc;
if (FAILED(adapter->GetDesc(&desc))) {
return IPC_FAIL_NO_REASON(this);
}
*aOutDesc = DxgiAdapterDesc::From(desc);
#endif
return IPC_OK();
}
already_AddRefed<dom::PWebGLParent>
ContentCompositorBridgeParent::AllocPWebGLParent() {
RefPtr<dom::PWebGLParent> parent = new dom::WebGLParent();

View File

@ -212,10 +212,6 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase {
UniquePtr<SurfaceDescriptor> LookupSurfaceDescriptorForClientTexture(
const int64_t aTextureId) final;
mozilla::ipc::IPCResult RecvSupportsAsyncDXGISurface(bool* value) override;
mozilla::ipc::IPCResult RecvPreferredDXGIAdapter(
DxgiAdapterDesc* desc) override;
private:
// Private destructor, to discourage deletion outside of Release():
virtual ~ContentCompositorBridgeParent();

View File

@ -514,284 +514,5 @@ void ImageBridgeParent::NotifyBufferNotUsedOfCompositorBridge(
#endif
}
#if defined(OS_WIN)
ImageBridgeParent::PluginTextureDatas::PluginTextureDatas(
UniquePtr<D3D11TextureData>&& aPluginTextureData,
UniquePtr<D3D11TextureData>&& aDisplayTextureData)
: mPluginTextureData(std::move(aPluginTextureData)),
mDisplayTextureData(std::move(aDisplayTextureData)) {}
ImageBridgeParent::PluginTextureDatas::~PluginTextureDatas() {}
#endif // defined(OS_WIN)
mozilla::ipc::IPCResult ImageBridgeParent::RecvMakeAsyncPluginSurfaces(
SurfaceFormat aFormat, IntSize aSize, SurfaceDescriptorPlugin* aSD) {
#if defined(OS_WIN)
*aSD = SurfaceDescriptorPlugin();
RefPtr<ID3D11Device> d3dDevice =
DeviceManagerDx::Get()->GetCompositorDevice();
if (!d3dDevice) {
NS_WARNING("Failed to get D3D11 device for plugin display");
return IPC_OK();
}
auto pluginSurf = WrapUnique(D3D11TextureData::Create(
aSize, aFormat, ALLOC_FOR_OUT_OF_BAND_CONTENT, d3dDevice));
if (!pluginSurf) {
NS_ERROR("Failed to create plugin surface");
return IPC_OK();
}
auto dispSurf = WrapUnique(D3D11TextureData::Create(
aSize, aFormat, ALLOC_FOR_OUT_OF_BAND_CONTENT, d3dDevice));
if (!dispSurf) {
NS_ERROR("Failed to create plugin display surface");
return IPC_OK();
}
// Identify plugin surfaces with a simple non-zero 64-bit ID.
static uint64_t sPluginSurfaceId = 1;
SurfaceDescriptor pluginSD, dispSD;
if ((!pluginSurf->Serialize(pluginSD)) || (!dispSurf->Serialize(dispSD))) {
NS_ERROR("Failed to make surface descriptors for plugin");
return IPC_OK();
}
if (!mPluginTextureDatas.put(
sPluginSurfaceId, MakeUnique<PluginTextureDatas>(
std::move(pluginSurf), std::move(dispSurf)))) {
NS_ERROR("Failed to add plugin surfaces to map");
return IPC_OK();
}
SurfaceDescriptorPlugin sd(sPluginSurfaceId, pluginSD, dispSD);
RefPtr<TextureHost> displayHost = CreateTextureHostD3D11(
dispSD, this, LayersBackend::LAYERS_NONE, TextureFlags::RECYCLE);
if (!displayHost) {
NS_ERROR("Failed to create plugin display texture host");
return IPC_OK();
}
if (!mGPUVideoTextureHosts.put(sPluginSurfaceId, displayHost)) {
NS_ERROR("Failed to add plugin display texture host to map");
return IPC_OK();
}
*aSD = sd;
++sPluginSurfaceId;
#endif // defined(OS_WIN)
return IPC_OK();
}
mozilla::ipc::IPCResult ImageBridgeParent::RecvUpdateAsyncPluginSurface(
const SurfaceDescriptorPlugin& aSD) {
#if defined(OS_WIN)
uint64_t surfaceId = aSD.id();
auto itTextures = mPluginTextureDatas.lookup(surfaceId);
if (!itTextures) {
return IPC_OK();
}
auto& textures = itTextures->value();
if (!textures->IsValid()) {
// The display texture may be gone. The plugin texture should never be gone
// here.
MOZ_ASSERT(textures->mPluginTextureData);
return IPC_OK();
}
RefPtr<ID3D11Device> device = DeviceManagerDx::Get()->GetCompositorDevice();
if (!device) {
NS_WARNING("Failed to get D3D11 device for plugin display");
return IPC_OK();
}
RefPtr<ID3D11DeviceContext> context;
device->GetImmediateContext(getter_AddRefs(context));
if (!context) {
NS_WARNING("Could not get an immediate D3D11 context");
return IPC_OK();
}
RefPtr<IDXGIKeyedMutex> dispMutex;
HRESULT hr = textures->mDisplayTextureData->GetD3D11Texture()->QueryInterface(
__uuidof(IDXGIKeyedMutex), (void**)getter_AddRefs(dispMutex));
if (FAILED(hr) || !dispMutex) {
NS_WARNING("Could not acquire plugin display IDXGIKeyedMutex");
return IPC_OK();
}
RefPtr<IDXGIKeyedMutex> pluginMutex;
hr = textures->mPluginTextureData->GetD3D11Texture()->QueryInterface(
__uuidof(IDXGIKeyedMutex), (void**)getter_AddRefs(pluginMutex));
if (FAILED(hr) || !pluginMutex) {
NS_WARNING("Could not acquire plugin offscreen IDXGIKeyedMutex");
return IPC_OK();
}
{
AutoTextureLock lock1(dispMutex, hr);
if (hr == WAIT_ABANDONED || hr == WAIT_TIMEOUT || FAILED(hr)) {
NS_WARNING(
"Could not acquire DXGI surface lock - display forgot to release?");
return IPC_OK();
}
AutoTextureLock lock2(pluginMutex, hr);
if (hr == WAIT_ABANDONED || hr == WAIT_TIMEOUT || FAILED(hr)) {
NS_WARNING(
"Could not acquire DXGI surface lock - plugin forgot to release?");
return IPC_OK();
}
context->CopyResource(textures->mDisplayTextureData->GetD3D11Texture(),
textures->mPluginTextureData->GetD3D11Texture());
}
#endif // defined(OS_WIN)
return IPC_OK();
}
mozilla::ipc::IPCResult ImageBridgeParent::RecvReadbackAsyncPluginSurface(
const SurfaceDescriptorPlugin& aSD, SurfaceDescriptor* aResult) {
#if defined(OS_WIN)
*aResult = null_t();
auto itTextures = mPluginTextureDatas.lookup(aSD.id());
if (!itTextures) {
return IPC_OK();
}
auto& textures = itTextures->value();
D3D11TextureData* displayTexData = textures->mDisplayTextureData.get();
MOZ_RELEASE_ASSERT(displayTexData);
if ((!displayTexData) || (!displayTexData->GetD3D11Texture())) {
NS_WARNING("Error in plugin display texture");
return IPC_OK();
}
MOZ_ASSERT(displayTexData->GetSurfaceFormat() == SurfaceFormat::B8G8R8A8 ||
displayTexData->GetSurfaceFormat() == SurfaceFormat::B8G8R8X8);
RefPtr<ID3D11Device> device;
displayTexData->GetD3D11Texture()->GetDevice(getter_AddRefs(device));
if (!device) {
NS_WARNING("Failed to get D3D11 device for plugin display");
return IPC_OK();
}
UniquePtr<BufferTextureData> shmemTexData(BufferTextureData::Create(
displayTexData->GetSize(), displayTexData->GetSurfaceFormat(),
gfx::BackendType::SKIA, LayersBackend::LAYERS_NONE,
displayTexData->GetTextureFlags(), TextureAllocationFlags::ALLOC_DEFAULT,
this));
if (!shmemTexData) {
NS_WARNING("Could not create BufferTextureData");
return IPC_OK();
}
if (!gfx::Factory::ReadbackTexture(shmemTexData.get(),
displayTexData->GetD3D11Texture())) {
NS_WARNING("Failed to read plugin texture into Shmem");
return IPC_OK();
}
// Take the Shmem from the TextureData.
shmemTexData->Serialize(*aResult);
#endif // defined(OS_WIN)
return IPC_OK();
}
mozilla::ipc::IPCResult ImageBridgeParent::RecvRemoveAsyncPluginSurface(
const SurfaceDescriptorPlugin& aSD, bool aIsFrontSurface) {
#if defined(OS_WIN)
auto itTextures = mPluginTextureDatas.lookup(aSD.id());
if (!itTextures) {
return IPC_OK();
}
auto& textures = itTextures->value();
if (aIsFrontSurface) {
textures->mDisplayTextureData = nullptr;
} else {
textures->mPluginTextureData = nullptr;
}
if ((!textures->mDisplayTextureData) && (!textures->mPluginTextureData)) {
mPluginTextureDatas.remove(aSD.id());
}
#endif // defined(OS_WIN)
return IPC_OK();
}
#if defined(OS_WIN)
RefPtr<TextureHost> GetNullPluginTextureHost() {
class NullPluginTextureHost : public TextureHost {
public:
NullPluginTextureHost() : TextureHost(TextureFlags::NO_FLAGS) {}
~NullPluginTextureHost() {}
gfx::SurfaceFormat GetFormat() const override {
return gfx::SurfaceFormat::UNKNOWN;
}
already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override {
return nullptr;
}
gfx::IntSize GetSize() const override { return gfx::IntSize(); }
bool BindTextureSource(CompositableTextureSourceRef& aTexture) override {
return false;
}
const char* Name() override { return "NullPluginTextureHost"; }
virtual bool Lock() { return false; }
void CreateRenderTexture(
const wr::ExternalImageId& aExternalImageId) override {}
uint32_t NumSubTextures() override { return 0; }
void PushResourceUpdates(wr::TransactionBuilder& aResources,
ResourceUpdateOp aOp,
const Range<wr::ImageKey>& aImageKeys,
const wr::ExternalImageId& aExtID) override {}
void PushDisplayItems(wr::DisplayListBuilder& aBuilder,
const wr::LayoutRect& aBounds,
const wr::LayoutRect& aClip,
wr::ImageRendering aFilter,
const Range<wr::ImageKey>& aImageKeys,
PushDisplayItemFlagSet aFlags) override {}
};
static StaticRefPtr<TextureHost> sNullPluginTextureHost;
if (!sNullPluginTextureHost) {
sNullPluginTextureHost = new NullPluginTextureHost();
ClearOnShutdown(&sNullPluginTextureHost);
};
MOZ_ASSERT(sNullPluginTextureHost);
return sNullPluginTextureHost.get();
}
#endif // defined(OS_WIN)
RefPtr<TextureHost> ImageBridgeParent::LookupTextureHost(
const SurfaceDescriptorPlugin& aDescriptor) {
#if defined(OS_WIN)
auto it = mGPUVideoTextureHosts.lookup(aDescriptor.id());
RefPtr<TextureHost> ret = it ? it->value() : nullptr;
return ret ? ret : GetNullPluginTextureHost();
#else
MOZ_ASSERT_UNREACHABLE("Unsupported architecture.");
return nullptr;
#endif // defined(OS_WIN)
}
} // namespace layers
} // namespace mozilla

View File

@ -122,20 +122,6 @@ class ImageBridgeParent final : public PImageBridgeParent,
bool IPCOpen() const override { return !mClosed; }
// See PluginInstanceParent for details on the Windows async plugin
// rendering protocol.
mozilla::ipc::IPCResult RecvMakeAsyncPluginSurfaces(
SurfaceFormat aFormat, IntSize aSize, SurfaceDescriptorPlugin* aSD);
mozilla::ipc::IPCResult RecvUpdateAsyncPluginSurface(
const SurfaceDescriptorPlugin& aSD);
mozilla::ipc::IPCResult RecvReadbackAsyncPluginSurface(
const SurfaceDescriptorPlugin& aSD, SurfaceDescriptor* aResult);
mozilla::ipc::IPCResult RecvRemoveAsyncPluginSurface(
const SurfaceDescriptorPlugin& aSD, bool aIsFrontSurface);
RefPtr<TextureHost> LookupTextureHost(
const SurfaceDescriptorPlugin& aDescriptor);
protected:
void Bind(Endpoint<PImageBridgeParent>&& aEndpoint);
@ -157,28 +143,6 @@ class ImageBridgeParent final : public PImageBridgeParent,
static ImageBridgeMap sImageBridges;
RefPtr<CompositorThreadHolder> mCompositorThreadHolder;
#if defined(OS_WIN)
// Owns a pair of textures used to double-buffer a plugin async rendering
// instance.
struct PluginTextureDatas {
UniquePtr<D3D11TextureData> mPluginTextureData;
UniquePtr<D3D11TextureData> mDisplayTextureData;
PluginTextureDatas(UniquePtr<D3D11TextureData>&& aPluginTextureData,
UniquePtr<D3D11TextureData>&& aDisplayTextureData);
~PluginTextureDatas();
PluginTextureDatas(const PluginTextureDatas& o) = delete;
PluginTextureDatas& operator=(const PluginTextureDatas& o) = delete;
bool IsValid() { return mPluginTextureData && mDisplayTextureData; }
};
HashMap<WindowsHandle, RefPtr<TextureHost>> mGPUVideoTextureHosts;
HashMap<WindowsHandle, UniquePtr<PluginTextureDatas>> mPluginTextureDatas;
#endif // defined(OS_WIN)
};
} // namespace layers

View File

@ -122,15 +122,8 @@ namespace layers {
MaybeVideoBridgeSource source;
};
[Comparable] struct SurfaceDescriptorPlugin {
uint64_t id;
SurfaceDescriptorD3D10 pluginSurf;
SurfaceDescriptorD3D10 displaySurf;
};
[Comparable] union SurfaceDescriptorGPUVideo {
SurfaceDescriptorRemoteDecoder;
SurfaceDescriptorPlugin;
};
[Comparable] struct RGBDescriptor {

View File

@ -47,7 +47,6 @@ using base::ProcessId from "base/process.h";
using mozilla::wr::MaybeExternalImageId from "mozilla/webrender/WebRenderTypes.h";
using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h";
using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h";
using struct DxgiAdapterDesc from "mozilla/D3DMessageUtils.h";
namespace mozilla {
namespace layers {
@ -257,11 +256,6 @@ parent:
async EndRecordingToMemory()
returns (CollectedFramesParams? frames);
sync SupportsAsyncDXGISurface()
returns (bool value);
sync PreferredDXGIAdapter()
returns (DxgiAdapterDesc desc);
// To set up sharing the composited output to Firefox Reality on Desktop
async RequestFxrOutput();

View File

@ -56,13 +56,6 @@ parent:
sync NewCompositable(CompositableHandle aHandle, TextureInfo aInfo, LayersBackend aBackend);
async ReleaseCompositable(CompositableHandle aHandle);
sync MakeAsyncPluginSurfaces(SurfaceFormat format, IntSize size)
returns (SurfaceDescriptorPlugin aSD);
async UpdateAsyncPluginSurface(SurfaceDescriptorPlugin aSD);
sync ReadbackAsyncPluginSurface(SurfaceDescriptorPlugin aSD)
returns (SurfaceDescriptor result);
async RemoveAsyncPluginSurface(SurfaceDescriptorPlugin aSD, bool isFrontSurface);
};

View File

@ -923,19 +923,11 @@ platform = win
[PCompositorWidget::LeavePresentLock]
description = Release the exclusive lock that EnterPresentLock obtained
platform = win
[PCompositorBridge::SupportsAsyncDXGISurface]
description = legacy sync IPC - please add detailed description
[PCompositorBridge::PreferredDXGIAdapter]
description = legacy sync IPC - please add detailed description
[PCompositorWidget::ClearTransparentWindow]
description = Synchronously clear the widget surface. Does not rely on (Enter|Leave)PresentLock. When call returns, window surface has been fully updated with cleared pixel values.
platform = win
[PImageBridge::NewCompositable]
description = legacy sync IPC - please add detailed description
[PImageBridge::MakeAsyncPluginSurfaces]
description = When plugin asks content to synchronously make surfaces, content needs to synchronously get those surfaces from the compositor process since sandboxing forbids content to make them itself.
[PImageBridge::ReadbackAsyncPluginSurface]
description = When content needs to synchronously readback a plugin surface, the compositor process needs to synchronously perform the operation since sandboxing forbids content to perform graphics operations.
[PLayerTransaction::SetTestSampleTime]
description = legacy sync IPC - please add detailed description
[PLayerTransaction::LeaveTestMode]