Backed out 4 changesets (bug 1673983) for causing build bustages in RenderCompositorD3D11SWGL. CLOSED TREE

Backed out changeset 134e621d0902 (bug 1673983)
Backed out changeset 81601a02d9b7 (bug 1673983)
Backed out changeset 72d4bf5b093e (bug 1673983)
Backed out changeset 99b2e5c55a25 (bug 1673983)
This commit is contained in:
smolnar 2020-11-05 11:40:36 +02:00
Родитель e581d4d914
Коммит 625b8a74be
28 изменённых файлов: 103 добавлений и 884 удалений

Просмотреть файл

@ -182,7 +182,6 @@ enum class WebRenderCompositor : int8_t {
DIRECT_COMPOSITION,
CORE_ANIMATION,
SOFTWARE,
D3D11,
LAST
};

Просмотреть файл

@ -1718,13 +1718,6 @@ bool CompositorD3D11::Failed(HRESULT hr, const char* aContext) {
return true;
}
SyncObjectHost* CompositorD3D11::GetSyncObject() {
if (mAttachments) {
return mAttachments->mSyncObject;
}
return nullptr;
}
void CompositorD3D11::HandleError(HRESULT hr, Severity aSeverity) {
if (SUCCEEDED(hr)) {
return;

Просмотреть файл

@ -142,15 +142,6 @@ class CompositorD3D11 : public Compositor {
mAllowFrameRecording = aWillRecord;
}
void Readback(gfx::DrawTarget* aDrawTarget) {
mTarget = aDrawTarget;
mTargetBounds = gfx::IntRect();
PaintToTarget();
mTarget = nullptr;
}
SyncObjectHost* GetSyncObject();
private:
enum Severity {
Recoverable,

Просмотреть файл

@ -999,6 +999,12 @@ void DXGITextureHostD3D11::PushResourceUpdates(
MOZ_ASSERT_UNREACHABLE("unexpected to be called without ANGLE");
return;
}
// XXX Software WebRender is not handled yet.
if (gfx::gfxVars::UseSoftwareWebRender()) {
gfxCriticalNoteOnce
<< "Software WebRender is not suppored by DXGITextureHostD3D11.";
return;
}
MOZ_ASSERT(mHandle);
auto method = aOp == TextureHost::ADD_IMAGE
@ -1013,10 +1019,7 @@ void DXGITextureHostD3D11::PushResourceUpdates(
wr::ImageDescriptor descriptor(mSize, GetFormat());
auto imageType =
gfx::gfxVars::UseSoftwareWebRender()
? wr::ExternalImageType::TextureHandle(wr::TextureTarget::Rect)
: wr::ExternalImageType::TextureHandle(
wr::TextureTarget::External);
wr::ExternalImageType::TextureHandle(wr::TextureTarget::External);
(aResources.*method)(aImageKeys[0], descriptor, aExtID, imageType, 0);
break;
}
@ -1035,10 +1038,7 @@ void DXGITextureHostD3D11::PushResourceUpdates(
? gfx::SurfaceFormat::R8G8
: gfx::SurfaceFormat::R16G16);
auto imageType =
gfx::gfxVars::UseSoftwareWebRender()
? wr::ExternalImageType::TextureHandle(wr::TextureTarget::Rect)
: wr::ExternalImageType::TextureHandle(
wr::TextureTarget::External);
wr::ExternalImageType::TextureHandle(wr::TextureTarget::External);
(aResources.*method)(aImageKeys[0], descriptor0, aExtID, imageType, 0);
(aResources.*method)(aImageKeys[1], descriptor1, aExtID, imageType, 1);
break;
@ -1059,10 +1059,11 @@ void DXGITextureHostD3D11::PushDisplayItems(
MOZ_ASSERT_UNREACHABLE("unexpected to be called without ANGLE");
return;
}
bool supportsExternalCompositing = false;
// XXX Software WebRender is not handled yet.
if (gfx::gfxVars::UseSoftwareWebRender()) {
supportsExternalCompositing = true;
gfxCriticalNoteOnce
<< "Software WebRender is not suppored by DXGITextureHostD3D11.";
return;
}
switch (GetFormat()) {
@ -1074,7 +1075,7 @@ void DXGITextureHostD3D11::PushDisplayItems(
aBuilder.PushImage(aBounds, aClip, true, aFilter, aImageKeys[0],
!(mFlags & TextureFlags::NON_PREMULTIPLIED),
wr::ColorF{1.0f, 1.0f, 1.0f, 1.0f},
preferCompositorSurface, supportsExternalCompositing);
preferCompositorSurface);
break;
}
case gfx::SurfaceFormat::P010:
@ -1255,8 +1256,8 @@ bool DXGIYCbCrTextureHostD3D11::BindTextureSource(
void DXGIYCbCrTextureHostD3D11::CreateRenderTexture(
const wr::ExternalImageId& aExternalImageId) {
RefPtr<wr::RenderTextureHost> texture = new wr::RenderDXGIYCbCrTextureHost(
mHandles, mYUVColorSpace, mColorDepth, mColorRange, mSizeY, mSizeCbCr);
RefPtr<wr::RenderTextureHost> texture =
new wr::RenderDXGIYCbCrTextureHost(mHandles, mSizeY, mSizeCbCr);
wr::RenderThread::Get()->RegisterExternalImage(wr::AsUint64(aExternalImageId),
texture.forget());
@ -1274,6 +1275,12 @@ void DXGIYCbCrTextureHostD3D11::PushResourceUpdates(
MOZ_ASSERT_UNREACHABLE("unexpected to be called without ANGLE");
return;
}
// XXX Software WebRender is not handled yet.
if (gfx::gfxVars::UseSoftwareWebRender()) {
gfxCriticalNoteOnce
<< "Software WebRender is not suppored by DXGIYCbCrTextureHostD3D11.";
return;
}
MOZ_ASSERT(mHandles[0] && mHandles[1] && mHandles[2]);
MOZ_ASSERT(aImageKeys.length() == 3);
@ -1287,9 +1294,7 @@ void DXGIYCbCrTextureHostD3D11::PushResourceUpdates(
? &wr::TransactionBuilder::AddExternalImage
: &wr::TransactionBuilder::UpdateExternalImage;
auto imageType =
gfx::gfxVars::UseSoftwareWebRender()
? wr::ExternalImageType::TextureHandle(wr::TextureTarget::Rect)
: wr::ExternalImageType::TextureHandle(wr::TextureTarget::External);
wr::ExternalImageType::TextureHandle(wr::TextureTarget::External);
// y
wr::ImageDescriptor descriptor0(mSizeY, gfx::SurfaceFormat::A8);
@ -1308,10 +1313,11 @@ void DXGIYCbCrTextureHostD3D11::PushDisplayItems(
MOZ_ASSERT_UNREACHABLE("unexpected to be called without ANGLE");
return;
}
bool supportsExternalCompositing = false;
// XXX Software WebRender is not handled yet.
if (gfx::gfxVars::UseSoftwareWebRender()) {
supportsExternalCompositing = true;
gfxCriticalNoteOnce
<< "Software WebRender is not suppored by DXGIYCbCrTextureHostD3D11.";
return;
}
MOZ_ASSERT(aImageKeys.length() == 3);
@ -1320,8 +1326,7 @@ void DXGIYCbCrTextureHostD3D11::PushDisplayItems(
aBounds, aClip, true, aImageKeys[0], aImageKeys[1], aImageKeys[2],
wr::ToWrColorDepth(mColorDepth), wr::ToWrYuvColorSpace(mYUVColorSpace),
wr::ToWrColorRange(mColorRange), aFilter,
aFlags.contains(PushDisplayItemFlag::PREFER_COMPOSITOR_SURFACE),
supportsExternalCompositing);
aFlags.contains(PushDisplayItemFlag::PREFER_COMPOSITOR_SURFACE));
}
bool DXGIYCbCrTextureHostD3D11::AcquireTextureSource(

Просмотреть файл

@ -103,9 +103,7 @@ class KnowsCompositor {
bool SupportsD3D11() const {
return GetCompositorBackendType() == layers::LayersBackend::LAYERS_D3D11 ||
(GetCompositorBackendType() == layers::LayersBackend::LAYERS_WR &&
(GetCompositorUseANGLE() ||
mTextureFactoryIdentifier.mWebRenderCompositor ==
layers::WebRenderCompositor::D3D11));
GetCompositorUseANGLE());
}
bool GetCompositorUseANGLE() const {

Просмотреть файл

@ -314,7 +314,7 @@ bool DeviceManagerDx::CreateCompositorDevices() {
// Fallback from WR to D3D11 Non-WR compositor without re-creating gpu process
// could happen when WR causes error. In this case, the attachments are loaded
// synchronously.
if (!gfx::gfxVars::UseWebRender() || gfx::gfxVars::UseSoftwareWebRender()) {
if (!gfx::gfxVars::UseWebRender()) {
PreloadAttachmentsOnCompositorThread();
}
@ -1391,6 +1391,8 @@ IDirectDraw7* DeviceManagerDx::GetDirectDraw() { return mDirectDraw; }
void DeviceManagerDx::GetCompositorDevices(
RefPtr<ID3D11Device>* aOutDevice,
RefPtr<layers::DeviceAttachmentsD3D11>* aOutAttachments) {
MOZ_ASSERT(layers::CompositorThreadHolder::IsInCompositorThread());
RefPtr<ID3D11Device> device;
{
MutexAutoLock lock(mDeviceLock);
@ -1429,8 +1431,7 @@ void DeviceManagerDx::PreloadAttachmentsOnCompositorThread() {
return;
}
bool enableAL = gfxConfig::IsEnabled(Feature::ADVANCED_LAYERS) &&
!gfx::gfxVars::UseSoftwareWebRender();
bool enableAL = gfxConfig::IsEnabled(Feature::ADVANCED_LAYERS);
RefPtr<Runnable> task = NS_NewRunnableFunction(
"DeviceManagerDx::PreloadAttachmentsOnCompositorThread",

Просмотреть файл

@ -69,8 +69,7 @@ gfx::YUVColorSpace RenderBufferTextureHostSWGL::GetYUVColorSpace() const {
}
}
bool RenderBufferTextureHostSWGL::MapPlane(RenderCompositor* aCompositor,
uint8_t aChannelIndex,
bool RenderBufferTextureHostSWGL::MapPlane(uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) {
switch (mDescriptor.type()) {
case layers::BufferDescriptor::TYCbCrDescriptor: {

Просмотреть файл

@ -25,8 +25,7 @@ class RenderBufferTextureHostSWGL final : public RenderTextureHostSWGL {
gfx::YUVColorSpace GetYUVColorSpace() const override;
bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) override;
bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) override;
void UnmapPlanes() override;

Просмотреть файл

@ -6,9 +6,7 @@
#include "RenderCompositor.h"
#include "gfxConfig.h"
#include "GLContext.h"
#include "mozilla/StaticPrefs_gfx.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/layers/SyncObject.h"
#include "mozilla/webrender/RenderCompositorOGL.h"
@ -17,7 +15,6 @@
#ifdef XP_WIN
# include "mozilla/webrender/RenderCompositorANGLE.h"
# include "mozilla/webrender/RenderCompositorD3D11SWGL.h"
#endif
#if defined(MOZ_WAYLAND) || defined(MOZ_WIDGET_ANDROID)
@ -141,17 +138,9 @@ UniquePtr<RenderCompositor> RenderCompositor::Create(
#ifdef XP_MACOSX
// Mac uses NativeLayerCA
return RenderCompositorNativeSWGL::Create(std::move(aWidget), aError);
#elif defined(XP_WIN)
if (StaticPrefs::gfx_webrender_software_d3d11_AtStartup() &&
gfx::gfxConfig::IsEnabled(gfx::Feature::D3D11_COMPOSITING)) {
UniquePtr<RenderCompositor> comp =
RenderCompositorD3D11SWGL::Create(std::move(aWidget), aError);
if (comp) {
return comp;
}
}
#endif
#else
return RenderCompositorSWGL::Create(std::move(aWidget), aError);
#endif
}
#ifdef XP_WIN

Просмотреть файл

@ -30,8 +30,6 @@ class CompositorWidget;
namespace wr {
class RenderCompositorD3D11SWGL;
class RenderCompositor {
public:
static UniquePtr<RenderCompositor> Create(
@ -87,10 +85,6 @@ class RenderCompositor {
return layers::WebRenderCompositor::DRAW;
}
virtual RenderCompositorD3D11SWGL* AsRenderCompositorD3D11SWGL() {
return nullptr;
}
// True if AttachExternalImage supports being used with an external
// image that maps to a RenderBufferTextureHost
virtual bool SupportsExternalBufferTextures() const { return false; }

Просмотреть файл

@ -1,341 +0,0 @@
/* -*- 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/. */
#include "RenderCompositorD3D11SWGL.h"
#include "mozilla/widget/CompositorWidget.h"
#include "mozilla/layers/Effects.h"
#include "mozilla/webrender/RenderD3D11TextureHost.h"
namespace mozilla {
using namespace layers;
namespace wr {
UniquePtr<RenderCompositor> RenderCompositorD3D11SWGL::Create(
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
void* ctx = wr_swgl_create_context();
if (!ctx) {
gfxCriticalNote << "Failed SWGL context creation for WebRender";
return nullptr;
}
RefPtr<CompositorD3D11> compositor =
MakeAndAddRef<CompositorD3D11>(nullptr, aWidget);
nsCString log;
if (!compositor->Initialize(&log)) {
gfxCriticalNote << "Failed to initialize CompositorD3D11 for SWGL: "
<< log.get();
return nullptr;
}
return MakeUnique<RenderCompositorD3D11SWGL>(compositor, std::move(aWidget),
ctx);
}
RenderCompositorD3D11SWGL::RenderCompositorD3D11SWGL(
CompositorD3D11* aCompositor, RefPtr<widget::CompositorWidget>&& aWidget,
void* aContext)
: RenderCompositor(std::move(aWidget)),
mCompositor(aCompositor),
mContext(aContext) {
MOZ_ASSERT(mContext);
mSyncObject = mCompositor->GetSyncObject();
}
RenderCompositorD3D11SWGL::~RenderCompositorD3D11SWGL() {
wr_swgl_destroy_context(mContext);
}
bool RenderCompositorD3D11SWGL::MakeCurrent() {
wr_swgl_make_current(mContext);
return true;
}
bool RenderCompositorD3D11SWGL::BeginFrame() {
MakeCurrent();
IntRect rect = IntRect(IntPoint(0, 0), GetBufferSize().ToUnknownSize());
mCompositor->BeginFrameForWindow(nsIntRegion(rect), Nothing(), rect,
nsIntRegion());
return true;
}
void RenderCompositorD3D11SWGL::CancelFrame() {
mFrameSurfaces.Clear();
mCompositor->CancelFrame();
}
void RenderCompositorD3D11SWGL::CompositorEndFrame() {
for (auto& frameSurface : mFrameSurfaces) {
auto surfaceCursor = mSurfaces.find(frameSurface.mId);
MOZ_RELEASE_ASSERT(surfaceCursor != mSurfaces.end());
Surface& surface = surfaceCursor->second;
for (auto it = surface.mTiles.begin(); it != surface.mTiles.end(); ++it) {
gfx::Point tileOffset(it->first.mX * surface.mTileSize.width,
it->first.mY * surface.mTileSize.height);
gfx::Rect drawRect = it->second.mValidRect + tileOffset;
RefPtr<TexturedEffect> texturedEffect = CreateTexturedEffect(
surface.mIsOpaque ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8,
it->second.mTexture, frameSurface.mFilter, true);
texturedEffect->mTextureCoords =
gfx::Rect(it->second.mValidRect.x / surface.mTileSize.width,
it->second.mValidRect.y / surface.mTileSize.height,
it->second.mValidRect.width / surface.mTileSize.width,
it->second.mValidRect.height / surface.mTileSize.height);
EffectChain effect;
effect.mPrimaryEffect = texturedEffect;
mCompositor->DrawQuad(drawRect, frameSurface.mClipRect, effect, 1.0,
frameSurface.mTransform, drawRect);
}
if (surface.mExternalImage) {
// We need to hold the texture source separately from the effect,
// since the effect doesn't hold a strong reference.
RefPtr<DataTextureSourceD3D11> layer;
RefPtr<TexturedEffect> texturedEffect;
gfx::IntSize size;
if (auto* host = surface.mExternalImage->AsRenderDXGITextureHost()) {
host->EnsureD3D11Texture2D(mCompositor->GetDevice());
layer = new DataTextureSourceD3D11(mCompositor->GetDevice(),
host->GetFormat(),
host->GetD3D11Texture2D());
if (host->GetFormat() == SurfaceFormat::NV12 ||
host->GetFormat() == SurfaceFormat::P010 ||
host->GetFormat() == SurfaceFormat::P016) {
texturedEffect = new EffectNV12(
layer, host->GetYUVColorSpace(), host->GetColorRange(),
host->GetColorDepth(), frameSurface.mFilter);
} else {
MOZ_ASSERT(host->GetFormat() == SurfaceFormat::B8G8R8X8 ||
host->GetFormat() == SurfaceFormat::B8G8R8A8);
texturedEffect = CreateTexturedEffect(host->GetFormat(), layer,
frameSurface.mFilter, true);
}
size = host->GetSize(0);
host->LockInternal();
} else if (auto* host =
surface.mExternalImage->AsRenderDXGIYCbCrTextureHost()) {
host->EnsureD3D11Texture2D(mCompositor->GetDevice());
layer = new DataTextureSourceD3D11(mCompositor->GetDevice(),
SurfaceFormat::A8,
host->GetD3D11Texture2D(0));
RefPtr<DataTextureSourceD3D11> u = new DataTextureSourceD3D11(
mCompositor->GetDevice(), SurfaceFormat::A8,
host->GetD3D11Texture2D(1));
layer->SetNextSibling(u);
RefPtr<DataTextureSourceD3D11> v = new DataTextureSourceD3D11(
mCompositor->GetDevice(), SurfaceFormat::A8,
host->GetD3D11Texture2D(2));
u->SetNextSibling(v);
texturedEffect = new EffectYCbCr(
layer, host->GetYUVColorSpace(), host->GetColorRange(),
host->GetColorDepth(), frameSurface.mFilter);
size = host->GetSize(0);
host->LockInternal();
}
gfx::Rect drawRect(0, 0, size.width, size.height);
EffectChain effect;
effect.mPrimaryEffect = texturedEffect;
mCompositor->DrawQuad(drawRect, frameSurface.mClipRect, effect, 1.0,
frameSurface.mTransform, drawRect);
if (auto* host = surface.mExternalImage->AsRenderDXGITextureHost()) {
host->Unlock();
} else if (auto* host =
surface.mExternalImage->AsRenderDXGIYCbCrTextureHost()) {
host->Unlock();
}
}
}
mFrameSurfaces.Clear();
}
RenderedFrameId RenderCompositorD3D11SWGL::EndFrame(
const nsTArray<DeviceIntRect>& aDirtyRects) {
mCompositor->EndFrame();
return GetNextRenderFrameId();
}
void RenderCompositorD3D11SWGL::Pause() {}
bool RenderCompositorD3D11SWGL::Resume() { return true; }
LayoutDeviceIntSize RenderCompositorD3D11SWGL::GetBufferSize() {
return mWidget->GetClientSize();
}
CompositorCapabilities RenderCompositorD3D11SWGL::GetCompositorCapabilities() {
CompositorCapabilities caps;
caps.virtual_surface_size = 0;
return caps;
}
void RenderCompositorD3D11SWGL::Bind(wr::NativeTileId aId,
wr::DeviceIntPoint* aOffset,
uint32_t* aFboId,
wr::DeviceIntRect aDirtyRect,
wr::DeviceIntRect aValidRect) {
MOZ_RELEASE_ASSERT(false);
}
void RenderCompositorD3D11SWGL::Unbind() { MOZ_RELEASE_ASSERT(false); }
bool RenderCompositorD3D11SWGL::MapTile(wr::NativeTileId aId,
wr::DeviceIntRect aDirtyRect,
wr::DeviceIntRect aValidRect,
void** aData, int32_t* aStride) {
auto surfaceCursor = mSurfaces.find(aId.surface_id);
MOZ_RELEASE_ASSERT(surfaceCursor != mSurfaces.end());
Surface& surface = surfaceCursor->second;
auto layerCursor = surface.mTiles.find(TileKey(aId.x, aId.y));
MOZ_RELEASE_ASSERT(layerCursor != surface.mTiles.end());
mCurrentTile = layerCursor->second;
mCurrentTileDirty = IntRect(aDirtyRect.origin.x, aDirtyRect.origin.y,
aDirtyRect.size.width, aDirtyRect.size.height);
DataSourceSurface::MappedSurface map;
if (!mCurrentTile.mSurface->Map(DataSourceSurface::READ_WRITE, &map)) {
return false;
}
*aData =
map.mData + aValidRect.origin.y * map.mStride + aValidRect.origin.x * 4;
*aStride = map.mStride;
layerCursor->second.mValidRect =
gfx::Rect(aValidRect.origin.x, aValidRect.origin.y, aValidRect.size.width,
aValidRect.size.height);
return true;
}
void RenderCompositorD3D11SWGL::UnmapTile() {
mCurrentTile.mSurface->Unmap();
nsIntRegion dirty(mCurrentTileDirty);
mCurrentTile.mTexture->Update(mCurrentTile.mSurface, &dirty);
}
void RenderCompositorD3D11SWGL::CreateSurface(wr::NativeSurfaceId aId,
wr::DeviceIntPoint aVirtualOffset,
wr::DeviceIntSize aTileSize,
bool aIsOpaque) {
MOZ_RELEASE_ASSERT(mSurfaces.find(aId) == mSurfaces.end());
mSurfaces.insert({aId, Surface{aTileSize, aIsOpaque}});
}
void RenderCompositorD3D11SWGL::CreateExternalSurface(wr::NativeSurfaceId aId,
bool aIsOpaque) {
MOZ_RELEASE_ASSERT(mSurfaces.find(aId) == mSurfaces.end());
Surface surface{wr::DeviceIntSize{}, aIsOpaque};
surface.mIsExternal = true;
mSurfaces.insert({aId, std::move(surface)});
}
void RenderCompositorD3D11SWGL::DestroySurface(NativeSurfaceId aId) {
auto surfaceCursor = mSurfaces.find(aId);
MOZ_RELEASE_ASSERT(surfaceCursor != mSurfaces.end());
mSurfaces.erase(surfaceCursor);
}
void RenderCompositorD3D11SWGL::CreateTile(wr::NativeSurfaceId aId, int32_t aX,
int32_t aY) {
auto surfaceCursor = mSurfaces.find(aId);
MOZ_RELEASE_ASSERT(surfaceCursor != mSurfaces.end());
Surface& surface = surfaceCursor->second;
MOZ_RELEASE_ASSERT(!surface.mIsExternal);
RefPtr<DataTextureSourceD3D11> source =
new DataTextureSourceD3D11(gfx::SurfaceFormat::B8G8R8A8, mCompositor,
layers::TextureFlags::NO_FLAGS);
RefPtr<DataSourceSurface> surf = Factory::CreateDataSourceSurface(
IntSize(surface.mTileSize.width, surface.mTileSize.height),
SurfaceFormat::B8G8R8A8);
surface.mTiles.insert({TileKey(aX, aY), Tile{source, surf}});
}
void RenderCompositorD3D11SWGL::DestroyTile(wr::NativeSurfaceId aId, int32_t aX,
int32_t aY) {
auto surfaceCursor = mSurfaces.find(aId);
MOZ_RELEASE_ASSERT(surfaceCursor != mSurfaces.end());
Surface& surface = surfaceCursor->second;
MOZ_RELEASE_ASSERT(!surface.mIsExternal);
auto layerCursor = surface.mTiles.find(TileKey(aX, aY));
MOZ_RELEASE_ASSERT(layerCursor != surface.mTiles.end());
surface.mTiles.erase(layerCursor);
}
void RenderCompositorD3D11SWGL::AttachExternalImage(
wr::NativeSurfaceId aId, wr::ExternalImageId aExternalImage) {
RenderTextureHost* image =
RenderThread::Get()->GetRenderTexture(aExternalImage);
MOZ_RELEASE_ASSERT(image);
MOZ_RELEASE_ASSERT(image->AsRenderDXGITextureHost() ||
image->AsRenderDXGIYCbCrTextureHost());
auto surfaceCursor = mSurfaces.find(aId);
MOZ_RELEASE_ASSERT(surfaceCursor != mSurfaces.end());
Surface& surface = surfaceCursor->second;
surface.mExternalImage = image;
MOZ_RELEASE_ASSERT(surface.mTiles.empty());
MOZ_RELEASE_ASSERT(surface.mIsExternal);
}
gfx::SamplingFilter ToSamplingFilter(wr::ImageRendering aImageRendering) {
if (aImageRendering == wr::ImageRendering::Auto) {
return gfx::SamplingFilter::LINEAR;
}
return gfx::SamplingFilter::POINT;
}
void RenderCompositorD3D11SWGL::AddSurface(
wr::NativeSurfaceId aId, const wr::CompositorSurfaceTransform& aTransform,
wr::DeviceIntRect aClipRect, wr::ImageRendering aImageRendering) {
Matrix4x4 transform(
aTransform.m11, aTransform.m12, aTransform.m13, aTransform.m14,
aTransform.m21, aTransform.m22, aTransform.m23, aTransform.m24,
aTransform.m31, aTransform.m32, aTransform.m33, aTransform.m34,
aTransform.m41, aTransform.m42, aTransform.m43, aTransform.m44);
gfx::IntRect clipRect(aClipRect.origin.x, aClipRect.origin.y,
aClipRect.size.width, aClipRect.size.height);
mFrameSurfaces.AppendElement(FrameSurface{aId, transform, clipRect,
ToSamplingFilter(aImageRendering)});
}
bool RenderCompositorD3D11SWGL::MaybeReadback(
const gfx::IntSize& aReadbackSize, const wr::ImageFormat& aReadbackFormat,
const Range<uint8_t>& aReadbackBuffer, bool* aNeedsYFlip) {
MOZ_ASSERT(aReadbackFormat == wr::ImageFormat::BGRA8);
auto stride =
aReadbackSize.width * gfx::BytesPerPixel(SurfaceFormat::B8G8R8A8);
RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateDrawTargetForData(
gfx::BackendType::SKIA, &aReadbackBuffer[0], aReadbackSize, stride,
SurfaceFormat::B8G8R8A8, false);
if (!dt) {
return false;
}
mCompositor->Readback(dt);
return true;
}
} // namespace wr
} // namespace mozilla

Просмотреть файл

@ -1,167 +0,0 @@
/* -*- 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_RENDERCOMPOSITOR_D3D11_H
#define MOZILLA_GFX_RENDERCOMPOSITOR_D3D11_H
#include "mozilla/webrender/RenderCompositor.h"
#include "mozilla/layers/TextureD3D11.h"
#include "mozilla/layers/CompositorD3D11.h"
namespace mozilla {
namespace wr {
class RenderCompositorD3D11SWGL : public RenderCompositor {
public:
static UniquePtr<RenderCompositor> Create(
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError);
RenderCompositorD3D11SWGL(layers::CompositorD3D11* aCompositor,
RefPtr<widget::CompositorWidget>&& aWidget,
void* aContext);
virtual ~RenderCompositorD3D11SWGL();
void* swgl() const override { return mContext; }
bool MakeCurrent() override;
bool BeginFrame() override;
void CancelFrame() override;
RenderedFrameId EndFrame(const nsTArray<DeviceIntRect>& aDirtyRects) final;
void Pause() override;
bool Resume() override;
bool SurfaceOriginIsTopLeft() override { return true; }
LayoutDeviceIntSize GetBufferSize() override;
// Should we support this?
bool SupportsExternalBufferTextures() const override { return false; }
layers::WebRenderBackend BackendType() const override {
return layers::WebRenderBackend::SOFTWARE;
}
layers::WebRenderCompositor CompositorType() const override {
return layers::WebRenderCompositor::D3D11;
}
RenderCompositorD3D11SWGL* AsRenderCompositorD3D11SWGL() { return this; }
// Interface for wr::Compositor
CompositorCapabilities GetCompositorCapabilities() override;
bool ShouldUseNativeCompositor() override { return true; }
void CompositorBeginFrame() {}
void CompositorEndFrame();
void Bind(wr::NativeTileId aId, wr::DeviceIntPoint* aOffset, uint32_t* aFboId,
wr::DeviceIntRect aDirtyRect,
wr::DeviceIntRect aValidRect) override;
void Unbind() override;
bool MapTile(wr::NativeTileId aId, wr::DeviceIntRect aDirtyRect,
wr::DeviceIntRect aValidRect, void** aData,
int32_t* aStride) override;
void UnmapTile() override;
void CreateSurface(wr::NativeSurfaceId aId, wr::DeviceIntPoint aVirtualOffset,
wr::DeviceIntSize aTileSize, bool aIsOpaque) override;
void CreateExternalSurface(wr::NativeSurfaceId aId, bool aIsOpaque) override;
void DestroySurface(NativeSurfaceId aId) override;
void CreateTile(wr::NativeSurfaceId, int32_t aX, int32_t aY) override;
void DestroyTile(wr::NativeSurfaceId, int32_t aX, int32_t aY) override;
void AttachExternalImage(wr::NativeSurfaceId aId,
wr::ExternalImageId aExternalImage) override;
void AddSurface(wr::NativeSurfaceId aId,
const wr::CompositorSurfaceTransform& aTransform,
wr::DeviceIntRect aClipRect,
wr::ImageRendering aImageRendering) override;
void EnableNativeCompositor(bool aEnable) {}
void DeInit() override {}
bool MaybeReadback(const gfx::IntSize& aReadbackSize,
const wr::ImageFormat& aReadbackFormat,
const Range<uint8_t>& aReadbackBuffer,
bool* aNeedsYFlip) override;
// TODO: Screenshots etc
struct TileKey {
TileKey(int32_t aX, int32_t aY) : mX(aX), mY(aY) {}
int32_t mX;
int32_t mY;
};
ID3D11Device* GetDevice() { return mCompositor->GetDevice(); }
private:
RefPtr<layers::CompositorD3D11> mCompositor;
void* mContext = nullptr;
struct Tile {
// Each tile retains a texture, and a DataSourceSurface of the
// same size. We draw into the source surface, and then copy the
// changed area into the texture.
// TODO: We should investigate using a D3D11 USAGE_STAGING texture
// that we map for the upload instead, to see if it performs better.
RefPtr<layers::DataTextureSourceD3D11> mTexture;
RefPtr<DataSourceSurface> mSurface;
gfx::Rect mValidRect;
struct KeyHashFn {
std::size_t operator()(const TileKey& aId) const {
return HashGeneric(aId.mX, aId.mY);
}
};
};
struct Surface {
explicit Surface(wr::DeviceIntSize aTileSize, bool aIsOpaque)
: mTileSize(aTileSize), mIsOpaque(aIsOpaque) {}
gfx::IntSize TileSize() {
return gfx::IntSize(mTileSize.width, mTileSize.height);
}
// External images can change size depending on which image
// is attached, so mTileSize will be 0,0 when mIsExternal
// is true.
wr::DeviceIntSize mTileSize;
bool mIsOpaque;
bool mIsExternal = false;
std::unordered_map<TileKey, Tile, Tile::KeyHashFn> mTiles;
RefPtr<RenderTextureHost> mExternalImage;
struct IdHashFn {
std::size_t operator()(const wr::NativeSurfaceId& aId) const {
return HashGeneric(wr::AsUint64(aId));
}
};
};
std::unordered_map<wr::NativeSurfaceId, Surface, Surface::IdHashFn> mSurfaces;
// Temporary state held between MapTile and UnmapTile
Tile mCurrentTile;
gfx::IntRect mCurrentTileDirty;
// The set of surfaces added to be composited for the current frame
struct FrameSurface {
wr::NativeSurfaceId mId;
gfx::Matrix4x4 mTransform;
gfx::IntRect mClipRect;
gfx::SamplingFilter mFilter;
};
nsTArray<FrameSurface> mFrameSurfaces;
};
static inline bool operator==(const RenderCompositorD3D11SWGL::TileKey& a0,
const RenderCompositorD3D11SWGL::TileKey& a1) {
return a0.mX == a1.mX && a0.mY == a1.mY;
}
} // namespace wr
} // namespace mozilla
#endif

Просмотреть файл

@ -58,93 +58,6 @@ ID3D11Texture2D* RenderDXGITextureHost::GetD3D11Texture2D() {
return mTexture;
}
size_t RenderDXGITextureHost::GetPlaneCount() const {
if (mFormat == gfx::SurfaceFormat::NV12 ||
mFormat == gfx::SurfaceFormat::P010 ||
mFormat == gfx::SurfaceFormat::P016) {
return 2;
}
return 1;
}
template <typename T>
static bool MapTexture(T* aHost, RenderCompositor* aCompositor,
RefPtr<ID3D11Texture2D>& aTexture,
RefPtr<ID3D11DeviceContext>& aDeviceContext,
RefPtr<ID3D11Texture2D>& aCpuTexture,
D3D11_MAPPED_SUBRESOURCE& aMappedSubresource) {
RenderCompositorD3D11SWGL* compositor =
aCompositor->AsRenderCompositorD3D11SWGL();
if (!compositor) {
return false;
}
if (!aHost->EnsureD3D11Texture2D(compositor->GetDevice())) {
return false;
}
if (!aHost->LockInternal()) {
return false;
}
D3D11_TEXTURE2D_DESC textureDesc = {0};
aTexture->GetDesc(&textureDesc);
compositor->GetDevice()->GetImmediateContext(getter_AddRefs(aDeviceContext));
textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
textureDesc.Usage = D3D11_USAGE_STAGING;
textureDesc.BindFlags = 0;
textureDesc.MiscFlags = 0;
textureDesc.MipLevels = 1;
HRESULT hr = compositor->GetDevice()->CreateTexture2D(
&textureDesc, nullptr, getter_AddRefs(aCpuTexture));
if (FAILED(hr)) {
return false;
}
aDeviceContext->CopyResource(aCpuTexture, aTexture);
aHost->Unlock();
hr = aDeviceContext->Map(aCpuTexture, 0, D3D11_MAP_READ, 0,
&aMappedSubresource);
return SUCCEEDED(hr);
}
bool RenderDXGITextureHost::MapPlane(RenderCompositor* aCompositor,
uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) {
// TODO: We currently readback from the GPU texture into a new
// staging texture every time this is mapped. We might be better
// off retaining the mapped memory to trade performance for memory
// usage.
if (!mCpuTexture && !MapTexture(this, aCompositor, mTexture, mDeviceContext,
mCpuTexture, mMappedSubresource)) {
return false;
}
aPlaneInfo.mSize = GetSize(aChannelIndex);
aPlaneInfo.mStride = mMappedSubresource.RowPitch;
aPlaneInfo.mData = mMappedSubresource.pData;
// If this is the second plane, then offset the data pointer by the
// size of the first plane.
if (aChannelIndex == 1) {
aPlaneInfo.mData =
(uint8_t*)aPlaneInfo.mData + aPlaneInfo.mStride * GetSize(0).height;
}
return true;
}
void RenderDXGITextureHost::UnmapPlanes() {
mMappedSubresource.pData = nullptr;
if (mCpuTexture) {
mDeviceContext->Unmap(mCpuTexture, 0);
mCpuTexture = nullptr;
}
mDeviceContext = nullptr;
}
bool RenderDXGITextureHost::EnsureD3D11Texture2D() {
if (mTexture) {
return true;
@ -167,16 +80,8 @@ bool RenderDXGITextureHost::EnsureD3D11Texture2D() {
return false;
}
return EnsureD3D11Texture2D(device);
}
bool RenderDXGITextureHost::EnsureD3D11Texture2D(ID3D11Device* aDevice) {
if (mTexture) {
return true;
}
// Get the D3D11 texture from shared handle.
HRESULT hr = aDevice->OpenSharedResource(
HRESULT hr = device->OpenSharedResource(
(HANDLE)mHandle, __uuidof(ID3D11Texture2D),
(void**)(ID3D11Texture2D**)getter_AddRefs(mTexture));
if (FAILED(hr)) {
@ -189,7 +94,6 @@ bool RenderDXGITextureHost::EnsureD3D11Texture2D(ID3D11Device* aDevice) {
return false;
}
MOZ_ASSERT(mTexture.get());
mTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mKeyedMutex));
return true;
}
@ -232,6 +136,7 @@ bool RenderDXGITextureHost::EnsureLockable(wr::ImageRendering aRendering) {
if (!EnsureD3D11Texture2D()) {
return false;
}
mTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mKeyedMutex));
// Create the EGLStream.
mStream = egl->fCreateStreamKHR(nullptr);
@ -318,28 +223,21 @@ wr::WrExternalImage RenderDXGITextureHost::Lock(uint8_t aChannelIndex,
return InvalidToWrExternalImage();
}
if (!LockInternal()) {
return InvalidToWrExternalImage();
}
gfx::IntSize size = GetSize(aChannelIndex);
return NativeTextureToWrExternalImage(GetGLHandle(aChannelIndex), 0, 0,
size.width, size.height);
}
bool RenderDXGITextureHost::LockInternal() {
if (!mLocked) {
if (mKeyedMutex) {
HRESULT hr = mKeyedMutex->AcquireSync(0, 10000);
if (hr != S_OK) {
gfxCriticalError() << "RenderDXGITextureHost AcquireSync timeout, hr="
<< gfx::hexa(hr);
return false;
return InvalidToWrExternalImage();
}
}
mLocked = true;
}
return true;
gfx::IntSize size = GetSize(aChannelIndex);
return NativeTextureToWrExternalImage(GetGLHandle(aChannelIndex), 0, 0,
size.width, size.height);
}
void RenderDXGITextureHost::Unlock() {
@ -414,16 +312,11 @@ gfx::IntSize RenderDXGITextureHost::GetSize(uint8_t aChannelIndex) const {
}
RenderDXGIYCbCrTextureHost::RenderDXGIYCbCrTextureHost(
WindowsHandle (&aHandles)[3], gfx::YUVColorSpace aYUVColorSpace,
gfx::ColorDepth aColorDepth, gfx::ColorRange aColorRange,
gfx::IntSize aSizeY, gfx::IntSize aSizeCbCr)
WindowsHandle (&aHandles)[3], gfx::IntSize aSizeY, gfx::IntSize aSizeCbCr)
: mHandles{aHandles[0], aHandles[1], aHandles[2]},
mSurfaces{0},
mStreams{0},
mTextureHandles{0},
mYUVColorSpace(aYUVColorSpace),
mColorDepth(aColorDepth),
mColorRange(aColorRange),
mSizeY(aSizeY),
mSizeCbCr(aSizeCbCr),
mLocked(false) {
@ -436,31 +329,6 @@ RenderDXGIYCbCrTextureHost::RenderDXGIYCbCrTextureHost(
MOZ_ASSERT(aHandles[0] && aHandles[1] && aHandles[2]);
}
bool RenderDXGIYCbCrTextureHost::MapPlane(RenderCompositor* aCompositor,
uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) {
D3D11_MAPPED_SUBRESOURCE mappedSubresource;
if (!MapTexture(this, aCompositor, mTextures[aChannelIndex], mDeviceContext,
mCpuTexture[aChannelIndex], mappedSubresource)) {
return false;
}
aPlaneInfo.mSize = GetSize(aChannelIndex);
aPlaneInfo.mStride = mappedSubresource.RowPitch;
aPlaneInfo.mData = mappedSubresource.pData;
return true;
}
void RenderDXGIYCbCrTextureHost::UnmapPlanes() {
for (uint32_t i = 0; i < 3; i++) {
if (mCpuTexture[i]) {
mDeviceContext->Unmap(mCpuTexture[i], 0);
mCpuTexture[i] = nullptr;
}
}
mDeviceContext = nullptr;
}
RenderDXGIYCbCrTextureHost::~RenderDXGIYCbCrTextureHost() {
MOZ_COUNT_DTOR_INHERITED(RenderDXGIYCbCrTextureHost, RenderTextureHost);
DeleteTextureHandle();
@ -510,7 +378,27 @@ bool RenderDXGIYCbCrTextureHost::EnsureLockable(wr::ImageRendering aRendering) {
return false;
}
EnsureD3D11Texture2D(device);
for (int i = 0; i < 3; ++i) {
// Get the R8 D3D11 texture from shared handle.
HRESULT hr = device->OpenSharedResource(
(HANDLE)mHandles[i], __uuidof(ID3D11Texture2D),
(void**)(ID3D11Texture2D**)getter_AddRefs(mTextures[i]));
if (FAILED(hr)) {
NS_WARNING(
"RenderDXGIYCbCrTextureHost::EnsureLockable(): Failed to open "
"shared "
"texture");
gfxCriticalNote
<< "RenderDXGIYCbCrTextureHost Failed to open shared texture, hr="
<< gfx::hexa(hr);
return false;
}
}
for (int i = 0; i < 3; ++i) {
mTextures[i]->QueryInterface(
(IDXGIKeyedMutex**)getter_AddRefs(mKeyedMutexs[i]));
}
mGL->fGenTextures(3, mTextureHandles);
bool ok = true;
@ -546,49 +434,6 @@ bool RenderDXGIYCbCrTextureHost::EnsureLockable(wr::ImageRendering aRendering) {
return true;
}
bool RenderDXGIYCbCrTextureHost::EnsureD3D11Texture2D(ID3D11Device* aDevice) {
for (int i = 0; i < 3; ++i) {
// Get the R8 D3D11 texture from shared handle.
HRESULT hr = aDevice->OpenSharedResource(
(HANDLE)mHandles[i], __uuidof(ID3D11Texture2D),
(void**)(ID3D11Texture2D**)getter_AddRefs(mTextures[i]));
if (FAILED(hr)) {
NS_WARNING(
"RenderDXGIYCbCrTextureHost::EnsureLockable(): Failed to open "
"shared "
"texture");
gfxCriticalNote
<< "RenderDXGIYCbCrTextureHost Failed to open shared texture, hr="
<< gfx::hexa(hr);
return false;
}
}
for (int i = 0; i < 3; ++i) {
mTextures[i]->QueryInterface(
(IDXGIKeyedMutex**)getter_AddRefs(mKeyedMutexs[i]));
}
return true;
}
bool RenderDXGIYCbCrTextureHost::LockInternal() {
if (!mLocked) {
if (mKeyedMutexs[0]) {
for (const auto& mutex : mKeyedMutexs) {
HRESULT hr = mutex->AcquireSync(0, 10000);
if (hr != S_OK) {
gfxCriticalError()
<< "RenderDXGIYCbCrTextureHost AcquireSync timeout, hr="
<< gfx::hexa(hr);
return false;
}
}
}
mLocked = true;
}
return true;
}
wr::WrExternalImage RenderDXGIYCbCrTextureHost::Lock(
uint8_t aChannelIndex, gl::GLContext* aGL, wr::ImageRendering aRendering) {
if (mGL.get() != aGL) {
@ -609,8 +454,19 @@ wr::WrExternalImage RenderDXGIYCbCrTextureHost::Lock(
return InvalidToWrExternalImage();
}
if (!LockInternal()) {
return InvalidToWrExternalImage();
if (!mLocked) {
if (mKeyedMutexs[0]) {
for (const auto& mutex : mKeyedMutexs) {
HRESULT hr = mutex->AcquireSync(0, 10000);
if (hr != S_OK) {
gfxCriticalError()
<< "RenderDXGIYCbCrTextureHost AcquireSync timeout, hr="
<< gfx::hexa(hr);
return InvalidToWrExternalImage();
}
}
}
mLocked = true;
}
gfx::IntSize size = GetSize(aChannelIndex);

Просмотреть файл

@ -8,7 +8,7 @@
#define MOZILLA_GFX_RENDERD3D11TEXTUREHOST_H
#include "GLTypes.h"
#include "RenderTextureHostSWGL.h"
#include "RenderTextureHost.h"
struct ID3D11Texture2D;
struct IDXGIKeyedMutex;
@ -17,7 +17,7 @@ namespace mozilla {
namespace wr {
class RenderDXGITextureHost final : public RenderTextureHostSWGL {
class RenderDXGITextureHost final : public RenderTextureHost {
public:
explicit RenderDXGITextureHost(WindowsHandle aHandle,
gfx::SurfaceFormat aFormat,
@ -37,32 +37,14 @@ class RenderDXGITextureHost final : public RenderTextureHostSWGL {
RenderDXGITextureHost* AsRenderDXGITextureHost() override { return this; }
gfx::SurfaceFormat GetFormat() const { return mFormat; }
gfx::YUVColorSpace GetYUVColorSpace() const { return mYUVColorSpace; }
gfx::ColorRange GetColorRange() const { return mColorRange; }
ID3D11Texture2D* GetD3D11Texture2D();
// RenderTextureHostSWGL
gfx::SurfaceFormat GetFormat() const override { return mFormat; }
gfx::ColorDepth GetColorDepth() const override {
if (mFormat == gfx::SurfaceFormat::P010) {
return gfx::ColorDepth::COLOR_10;
}
if (mFormat == gfx::SurfaceFormat::P016) {
return gfx::ColorDepth::COLOR_16;
}
return gfx::ColorDepth::COLOR_8;
}
size_t GetPlaneCount() const override;
bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) override;
void UnmapPlanes() override;
gfx::YUVColorSpace GetYUVColorSpace() const override {
return mYUVColorSpace;
}
bool EnsureD3D11Texture2D(ID3D11Device* aDevice);
bool LockInternal();
private:
virtual ~RenderDXGITextureHost();
@ -77,11 +59,6 @@ class RenderDXGITextureHost final : public RenderTextureHostSWGL {
RefPtr<ID3D11Texture2D> mTexture;
RefPtr<IDXGIKeyedMutex> mKeyedMutex;
// Temporary state between MapPlane and UnmapPlanes.
RefPtr<ID3D11DeviceContext> mDeviceContext;
RefPtr<ID3D11Texture2D> mCpuTexture;
D3D11_MAPPED_SUBRESOURCE mMappedSubresource;
EGLSurface mSurface;
EGLStreamKHR mStream;
@ -97,19 +74,12 @@ class RenderDXGITextureHost final : public RenderTextureHostSWGL {
bool mLocked;
};
class RenderDXGIYCbCrTextureHost final : public RenderTextureHostSWGL {
class RenderDXGIYCbCrTextureHost final : public RenderTextureHost {
public:
explicit RenderDXGIYCbCrTextureHost(WindowsHandle (&aHandles)[3],
gfx::YUVColorSpace aYUVColorSpace,
gfx::ColorDepth aColorDepth,
gfx::ColorRange aColorRange,
gfx::IntSize aSizeY,
gfx::IntSize aSizeCbCr);
RenderDXGIYCbCrTextureHost* AsRenderDXGIYCbCrTextureHost() override {
return this;
}
wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL,
wr::ImageRendering aRendering) override;
void Unlock() override;
@ -120,28 +90,6 @@ class RenderDXGIYCbCrTextureHost final : public RenderTextureHostSWGL {
bool SyncObjectNeeded() override { return true; }
gfx::ColorRange GetColorRange() const { return mColorRange; }
// RenderTextureHostSWGL
gfx::SurfaceFormat GetFormat() const override {
return gfx::SurfaceFormat::YUV;
}
gfx::ColorDepth GetColorDepth() const override { return mColorDepth; }
size_t GetPlaneCount() const override { return 3; }
bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) override;
void UnmapPlanes() override;
gfx::YUVColorSpace GetYUVColorSpace() const override {
return mYUVColorSpace;
}
bool EnsureD3D11Texture2D(ID3D11Device* aDevice);
bool LockInternal();
ID3D11Texture2D* GetD3D11Texture2D(uint8_t aChannelIndex) {
return mTextures[aChannelIndex];
}
private:
virtual ~RenderDXGIYCbCrTextureHost();
@ -161,13 +109,6 @@ class RenderDXGIYCbCrTextureHost final : public RenderTextureHostSWGL {
// The gl handles for Y, Cb and Cr data.
GLuint mTextureHandles[3];
// Temporary state between MapPlane and UnmapPlanes.
RefPtr<ID3D11DeviceContext> mDeviceContext;
RefPtr<ID3D11Texture2D> mCpuTexture[3];
gfx::YUVColorSpace mYUVColorSpace;
gfx::ColorDepth mColorDepth;
gfx::ColorRange mColorRange;
gfx::IntSize mSizeY;
gfx::IntSize mSizeCbCr;

Просмотреть файл

@ -145,8 +145,7 @@ gfx::YUVColorSpace RenderMacIOSurfaceTextureHost::GetYUVColorSpace() const {
return mSurface->GetYUVColorSpace();
}
bool RenderMacIOSurfaceTextureHost::MapPlane(RenderCompositor* aCompositor,
uint8_t aChannelIndex,
bool RenderMacIOSurfaceTextureHost::MapPlane(uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) {
if (!aChannelIndex) {
mSurface->Lock();

Просмотреть файл

@ -41,8 +41,7 @@ class RenderMacIOSurfaceTextureHost final : public RenderTextureHostSWGL {
gfx::SurfaceFormat GetFormat() const override;
gfx::ColorDepth GetColorDepth() const override;
gfx::YUVColorSpace GetYUVColorSpace() const override;
bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) override;
bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) override;
void UnmapPlanes() override;
private:

Просмотреть файл

@ -34,8 +34,7 @@ gfx::ColorDepth RenderSharedSurfaceTextureHostSWGL::GetColorDepth() const {
return gfx::ColorDepth::COLOR_8;
}
bool RenderSharedSurfaceTextureHostSWGL::MapPlane(RenderCompositor* aCompositor,
uint8_t aChannelIndex,
bool RenderSharedSurfaceTextureHostSWGL::MapPlane(uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) {
if (NS_WARN_IF(
!mSurface->Map(gfx::DataSourceSurface::MapType::READ, &mMap))) {

Просмотреть файл

@ -32,8 +32,7 @@ class RenderSharedSurfaceTextureHostSWGL final : public RenderTextureHostSWGL {
gfx::ColorDepth GetColorDepth() const override;
bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) override;
bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) override;
void UnmapPlanes() override;

Просмотреть файл

@ -49,7 +49,6 @@ wr::WrExternalImage RenderTextureHost::Lock(uint8_t aChannelIndex,
wr::WrExternalImage RenderTextureHost::LockSWGL(uint8_t aChannelIndex,
void* aContext,
RenderCompositor* aCompositor,
wr::ImageRendering aRendering) {
return InvalidToWrExternalImage();
}

Просмотреть файл

@ -23,9 +23,7 @@ class GLContext;
namespace wr {
class RenderCompositor;
class RenderDXGITextureHost;
class RenderDXGIYCbCrTextureHost;
class RenderMacIOSurfaceTextureHost;
class RenderBufferTextureHost;
class RenderTextureHostSWGL;
@ -46,7 +44,6 @@ class RenderTextureHost {
virtual void Unlock() {}
virtual wr::WrExternalImage LockSWGL(uint8_t aChannelIndex, void* aContext,
RenderCompositor* aCompositor,
wr::ImageRendering aRendering);
virtual void UnlockSWGL() {}
@ -70,9 +67,6 @@ class RenderTextureHost {
virtual bool SyncObjectNeeded() { return false; }
virtual RenderDXGITextureHost* AsRenderDXGITextureHost() { return nullptr; }
virtual RenderDXGIYCbCrTextureHost* AsRenderDXGIYCbCrTextureHost() {
return nullptr;
}
virtual RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() {
return nullptr;

Просмотреть файл

@ -10,8 +10,7 @@
namespace mozilla {
namespace wr {
bool RenderTextureHostSWGL::UpdatePlanes(RenderCompositor* aCompositor,
wr::ImageRendering aRendering) {
bool RenderTextureHostSWGL::UpdatePlanes(wr::ImageRendering aRendering) {
wr_swgl_make_current(mContext);
size_t planeCount = GetPlaneCount();
bool filterUpdate = IsFilterUpdateNecessary(aRendering);
@ -26,7 +25,7 @@ bool RenderTextureHostSWGL::UpdatePlanes(RenderCompositor* aCompositor,
gfx::ColorDepth colorDepth = GetColorDepth();
for (size_t i = 0; i < planeCount; i++) {
PlaneInfo& plane = mPlanes[i];
if (!MapPlane(aCompositor, i, plane)) {
if (!MapPlane(i, plane)) {
if (i > 0) {
UnmapPlanes();
}
@ -95,13 +94,12 @@ bool RenderTextureHostSWGL::SetContext(void* aContext) {
}
wr::WrExternalImage RenderTextureHostSWGL::LockSWGL(
uint8_t aChannelIndex, void* aContext, RenderCompositor* aCompositor,
wr::ImageRendering aRendering) {
uint8_t aChannelIndex, void* aContext, wr::ImageRendering aRendering) {
if (!SetContext(aContext)) {
return InvalidToWrExternalImage();
}
if (!mLocked) {
if (!UpdatePlanes(aCompositor, aRendering)) {
if (!UpdatePlanes(aRendering)) {
return InvalidToWrExternalImage();
}
mLocked = true;
@ -144,7 +142,7 @@ bool RenderTextureHostSWGL::LockSWGLCompositeSurface(
return false;
}
if (!mLocked) {
if (!UpdatePlanes(nullptr, mCachedRendering)) {
if (!UpdatePlanes(mCachedRendering)) {
return false;
}
mLocked = true;

Просмотреть файл

@ -17,7 +17,6 @@ class RenderTextureHostSWGL : public RenderTextureHost {
RenderTextureHostSWGL() {}
wr::WrExternalImage LockSWGL(uint8_t aChannelIndex, void* aContext,
RenderCompositor* aCompositor,
wr::ImageRendering aRendering) override;
void UnlockSWGL() override;
@ -26,7 +25,9 @@ class RenderTextureHostSWGL : public RenderTextureHost {
virtual size_t GetPlaneCount() const = 0;
virtual gfx::SurfaceFormat GetFormat() const = 0;
virtual gfx::SurfaceFormat GetFormat() const {
return gfx::SurfaceFormat::UNKNOWN;
}
virtual gfx::ColorDepth GetColorDepth() const {
return gfx::ColorDepth::UNKNOWN;
@ -45,8 +46,7 @@ class RenderTextureHostSWGL : public RenderTextureHost {
gfx::IntSize mSize;
};
virtual bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) = 0;
virtual bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) = 0;
virtual void UnmapPlanes() = 0;
@ -64,8 +64,7 @@ class RenderTextureHostSWGL : public RenderTextureHost {
bool SetContext(void* aContext);
bool UpdatePlanes(RenderCompositor* aCompositor,
wr::ImageRendering aRendering);
bool UpdatePlanes(wr::ImageRendering aRendering);
void CleanupPlanes();

Просмотреть файл

@ -72,15 +72,6 @@ RenderDXGITextureHost* RenderTextureHostWrapper::AsRenderDXGITextureHost() {
return mTextureHost->AsRenderDXGITextureHost();
}
RenderDXGIYCbCrTextureHost*
RenderTextureHostWrapper::AsRenderDXGIYCbCrTextureHost() {
EnsureTextureHost();
if (!mTextureHost) {
return nullptr;
}
return mTextureHost->AsRenderDXGIYCbCrTextureHost();
}
RenderTextureHostSWGL* RenderTextureHostWrapper::EnsureRenderTextureHostSWGL()
const {
EnsureTextureHost();
@ -118,11 +109,10 @@ gfx::YUVColorSpace RenderTextureHostWrapper::GetYUVColorSpace() const {
return gfx::YUVColorSpace::UNKNOWN;
}
bool RenderTextureHostWrapper::MapPlane(RenderCompositor* aCompositor,
uint8_t aChannelIndex,
bool RenderTextureHostWrapper::MapPlane(uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) {
if (RenderTextureHostSWGL* swglHost = EnsureRenderTextureHostSWGL()) {
return swglHost->MapPlane(aCompositor, aChannelIndex, aPlaneInfo);
return swglHost->MapPlane(aChannelIndex, aPlaneInfo);
}
return false;
}

Просмотреть файл

@ -35,15 +35,13 @@ class RenderTextureHostWrapper final : public RenderTextureHostSWGL {
void ClearCachedResources() override;
RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() override;
RenderDXGITextureHost* AsRenderDXGITextureHost() override;
RenderDXGIYCbCrTextureHost* AsRenderDXGIYCbCrTextureHost() override;
// RenderTextureHostSWGL
size_t GetPlaneCount() const override;
gfx::SurfaceFormat GetFormat() const override;
gfx::ColorDepth GetColorDepth() const override;
gfx::YUVColorSpace GetYUVColorSpace() const override;
bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
PlaneInfo& aPlaneInfo) override;
bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) override;
void UnmapPlanes() override;
private:

Просмотреть файл

@ -71,8 +71,7 @@ wr::WrExternalImage wr_renderer_lock_external_image(
if (auto* gl = renderer->gl()) {
return texture->Lock(aChannelIndex, gl, aRendering);
} else if (auto* swgl = renderer->swgl()) {
return texture->LockSWGL(aChannelIndex, swgl, renderer->GetCompositor(),
aRendering);
return texture->LockSWGL(aChannelIndex, swgl, aRendering);
} else {
gfxCriticalNoteOnce
<< "No GL or SWGL context available to lock ExternalImage for extId:"

Просмотреть файл

@ -113,8 +113,6 @@ class RendererOGL {
RenderTextureHost* GetRenderTexture(wr::ExternalImageId aExternalImageId);
RenderCompositor* GetCompositor() { return mCompositor.get(); }
void AccumulateMemoryReport(MemoryReport* aReport);
void SetProfilerUI(const nsCString& aUI);

Просмотреть файл

@ -11,7 +11,6 @@ EXPORTS.mozilla.webrender += [
"RenderBufferTextureHost.h",
"RenderBufferTextureHostSWGL.h",
"RenderCompositor.h",
"RenderCompositorD3D11SWGL.h",
"RenderCompositorEGL.h",
"RenderCompositorOGL.h",
"RenderCompositorSWGL.h",
@ -35,7 +34,6 @@ UNIFIED_SOURCES += [
"RenderBufferTextureHost.cpp",
"RenderBufferTextureHostSWGL.cpp",
"RenderCompositor.cpp",
"RenderCompositorD3D11SWGL.cpp",
"RenderCompositorEGL.cpp",
"RenderCompositorOGL.cpp",
"RenderCompositorSWGL.cpp",
@ -120,4 +118,3 @@ include("/ipc/chromium/chromium-config.mozbuild")
FINAL_LIBRARY = "xul"
CXXFLAGS += CONFIG["TK_CFLAGS"]
CXXFLAGS += CONFIG["MOZ_CAIRO_CFLAGS"]

Просмотреть файл

@ -4657,12 +4657,6 @@
value: false
mirror: once
# Whether to use the D3D11 RenderCompositor when using WebRender software backend
- name: gfx.webrender.software.d3d11
type: bool
value: true
mirror: once
# Use vsync events generated by hardware
- name: gfx.work-around-driver-bugs
type: bool