зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1652894 - add SWGL RenderTextureHosts. r=mattwoodrow
Differential Revision: https://phabricator.services.mozilla.com/D86340
This commit is contained in:
Родитель
af31727ba7
Коммит
6b4a081f33
|
@ -21,6 +21,7 @@
|
|||
# include "mozilla/layers/D3D11YCbCrImage.h"
|
||||
#elif XP_MACOSX
|
||||
# include "MacIOSurfaceImage.h"
|
||||
# include "mozilla/gfx/gfxVars.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -351,8 +352,10 @@ already_AddRefed<VideoData> VideoData::CreateAndCopyData(
|
|||
}
|
||||
}
|
||||
#elif XP_MACOSX
|
||||
if (aAllocator && aAllocator->GetCompositorBackendType() ==
|
||||
layers::LayersBackend::LAYERS_WR) {
|
||||
if (aAllocator &&
|
||||
aAllocator->GetCompositorBackendType() ==
|
||||
layers::LayersBackend::LAYERS_WR &&
|
||||
!gfxVars::UseSoftwareWebRender()) {
|
||||
RefPtr<layers::MacIOSurfaceImage> ioImage =
|
||||
new layers::MacIOSurfaceImage(nullptr);
|
||||
PlanarYCbCrData data = ConstructPlanarYCbCrData(aInfo, aBuffer, aPicture);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "mozilla/StaticPrefs_layers.h"
|
||||
#include "mozilla/StaticPrefs_gfx.h"
|
||||
#include "mozilla/webrender/RenderBufferTextureHost.h"
|
||||
#include "mozilla/webrender/RenderBufferTextureHostSWGL.h"
|
||||
#include "mozilla/webrender/RenderExternalTextureHost.h"
|
||||
#include "mozilla/webrender/RenderThread.h"
|
||||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
|
@ -676,6 +677,9 @@ void BufferTextureHost::CreateRenderTexture(
|
|||
if (UseExternalTextures()) {
|
||||
texture =
|
||||
new wr::RenderExternalTextureHost(GetBuffer(), GetBufferDescriptor());
|
||||
} else if (gfx::gfxVars::UseSoftwareWebRender()) {
|
||||
texture =
|
||||
new wr::RenderBufferTextureHostSWGL(GetBuffer(), GetBufferDescriptor());
|
||||
} else {
|
||||
texture =
|
||||
new wr::RenderBufferTextureHost(GetBuffer(), GetBufferDescriptor());
|
||||
|
@ -701,7 +705,7 @@ void BufferTextureHost::PushResourceUpdates(
|
|||
: &wr::TransactionBuilder::UpdateExternalImage;
|
||||
|
||||
auto imageType =
|
||||
UseExternalTextures()
|
||||
UseExternalTextures() || gfx::gfxVars::UseSoftwareWebRender()
|
||||
? wr::ExternalImageType::TextureHandle(wr::TextureTarget::Rect)
|
||||
: wr::ExternalImageType::Buffer();
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/layers/SourceSurfaceSharedData.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "mozilla/webrender/RenderSharedSurfaceTextureHost.h"
|
||||
#include "mozilla/webrender/RenderSharedSurfaceTextureHostSWGL.h"
|
||||
#include "mozilla/webrender/RenderThread.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -129,8 +130,12 @@ void SharedSurfacesParent::AddSameProcess(const wr::ExternalImageId& aId,
|
|||
uint64_t id = wr::AsUint64(aId);
|
||||
MOZ_ASSERT(!sInstance->mSurfaces.Contains(id));
|
||||
|
||||
RefPtr<wr::RenderSharedSurfaceTextureHost> texture =
|
||||
new wr::RenderSharedSurfaceTextureHost(surface);
|
||||
RefPtr<wr::RenderTextureHost> texture;
|
||||
if (gfx::gfxVars::UseSoftwareWebRender()) {
|
||||
texture = new wr::RenderSharedSurfaceTextureHostSWGL(surface);
|
||||
} else {
|
||||
texture = new wr::RenderSharedSurfaceTextureHost(surface);
|
||||
}
|
||||
wr::RenderThread::Get()->RegisterExternalImage(id, texture.forget());
|
||||
|
||||
surface->AddConsumer();
|
||||
|
@ -187,8 +192,12 @@ void SharedSurfacesParent::Add(const wr::ExternalImageId& aId,
|
|||
uint64_t id = wr::AsUint64(aId);
|
||||
MOZ_ASSERT(!sInstance->mSurfaces.Contains(id));
|
||||
|
||||
RefPtr<wr::RenderSharedSurfaceTextureHost> texture =
|
||||
new wr::RenderSharedSurfaceTextureHost(surface);
|
||||
RefPtr<wr::RenderTextureHost> texture;
|
||||
if (gfx::gfxVars::UseSoftwareWebRender()) {
|
||||
texture = new wr::RenderSharedSurfaceTextureHostSWGL(surface);
|
||||
} else {
|
||||
texture = new wr::RenderSharedSurfaceTextureHost(surface);
|
||||
}
|
||||
wr::RenderThread::Get()->RegisterExternalImage(id, texture.forget());
|
||||
|
||||
surface->AddConsumer();
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MacIOSurfaceTextureHostOGL.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/gfx/MacIOSurface.h"
|
||||
#include "mozilla/webrender/RenderMacIOSurfaceTextureHostOGL.h"
|
||||
#include "mozilla/webrender/RenderMacIOSurfaceTextureHostSWGL.h"
|
||||
#include "mozilla/webrender/RenderThread.h"
|
||||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
#include "GLContextCGL.h"
|
||||
|
@ -132,8 +134,12 @@ gfx::ColorRange MacIOSurfaceTextureHostOGL::GetColorRange() const {
|
|||
|
||||
void MacIOSurfaceTextureHostOGL::CreateRenderTexture(
|
||||
const wr::ExternalImageId& aExternalImageId) {
|
||||
RefPtr<wr::RenderTextureHost> texture =
|
||||
new wr::RenderMacIOSurfaceTextureHostOGL(GetMacIOSurface());
|
||||
RefPtr<wr::RenderTextureHost> texture;
|
||||
if (gfx::gfxVars::UseSoftwareWebRender()) {
|
||||
texture = new wr::RenderMacIOSurfaceTextureHostSWGL(GetMacIOSurface());
|
||||
} else {
|
||||
texture = new wr::RenderMacIOSurfaceTextureHostOGL(GetMacIOSurface());
|
||||
}
|
||||
|
||||
wr::RenderThread::Get()->RegisterExternalImage(wr::AsUint64(aExternalImageId),
|
||||
texture.forget());
|
||||
|
|
|
@ -693,10 +693,13 @@ bool WebRenderBridgeParent::AddSharedExternalImage(
|
|||
|
||||
mSharedSurfaceIds.insert(std::make_pair(key, aExtId));
|
||||
|
||||
auto imageType =
|
||||
gfx::gfxVars::UseSoftwareWebRender()
|
||||
? wr::ExternalImageType::TextureHandle(wr::TextureTarget::Rect)
|
||||
: wr::ExternalImageType::Buffer();
|
||||
wr::ImageDescriptor descriptor(dSurf->GetSize(), dSurf->Stride(),
|
||||
dSurf->GetFormat());
|
||||
aResources.AddExternalImage(aKey, descriptor, aExtId,
|
||||
wr::ExternalImageType::Buffer(), 0);
|
||||
aResources.AddExternalImage(aKey, descriptor, aExtId, imageType, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -804,11 +807,14 @@ bool WebRenderBridgeParent::UpdateSharedExternalImage(
|
|||
it->second = aExtId;
|
||||
}
|
||||
|
||||
auto imageType =
|
||||
gfx::gfxVars::UseSoftwareWebRender()
|
||||
? wr::ExternalImageType::TextureHandle(wr::TextureTarget::Rect)
|
||||
: wr::ExternalImageType::Buffer();
|
||||
wr::ImageDescriptor descriptor(dSurf->GetSize(), dSurf->Stride(),
|
||||
dSurf->GetFormat());
|
||||
aResources.UpdateExternalImageWithDirtyRect(
|
||||
aKey, descriptor, aExtId, wr::ExternalImageType::Buffer(),
|
||||
wr::ToDeviceIntRect(aDirtyRect), 0);
|
||||
aKey, descriptor, aExtId, imageType, wr::ToDeviceIntRect(aDirtyRect), 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/* -*- 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 "RenderBufferTextureHostSWGL.h"
|
||||
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
#include "mozilla/layers/ImageDataSerializer.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
RenderBufferTextureHostSWGL::RenderBufferTextureHostSWGL(
|
||||
uint8_t* aBuffer, const layers::BufferDescriptor& aDescriptor)
|
||||
: mBuffer(aBuffer), mDescriptor(aDescriptor) {
|
||||
MOZ_COUNT_CTOR_INHERITED(RenderBufferTextureHostSWGL, RenderTextureHostSWGL);
|
||||
|
||||
switch (mDescriptor.type()) {
|
||||
case layers::BufferDescriptor::TYCbCrDescriptor:
|
||||
case layers::BufferDescriptor::TRGBDescriptor:
|
||||
MOZ_RELEASE_ASSERT(mBuffer != nullptr);
|
||||
break;
|
||||
default:
|
||||
gfxCriticalError() << "Bad buffer host descriptor "
|
||||
<< (int)mDescriptor.type();
|
||||
MOZ_CRASH("GFX: Bad descriptor");
|
||||
}
|
||||
}
|
||||
|
||||
RenderBufferTextureHostSWGL::~RenderBufferTextureHostSWGL() {
|
||||
MOZ_COUNT_DTOR_INHERITED(RenderBufferTextureHostSWGL, RenderTextureHostSWGL);
|
||||
}
|
||||
|
||||
size_t RenderBufferTextureHostSWGL::GetPlaneCount() {
|
||||
switch (mDescriptor.type()) {
|
||||
case layers::BufferDescriptor::TYCbCrDescriptor:
|
||||
return 3;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderBufferTextureHostSWGL::MapPlane(uint8_t aChannelIndex,
|
||||
PlaneInfo& aPlaneInfo) {
|
||||
switch (mDescriptor.type()) {
|
||||
case layers::BufferDescriptor::TYCbCrDescriptor: {
|
||||
const layers::YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
|
||||
aPlaneInfo.mFormat = gfx::SurfaceFormat::YUV;
|
||||
switch (aChannelIndex) {
|
||||
case 0:
|
||||
aPlaneInfo.mData =
|
||||
layers::ImageDataSerializer::GetYChannel(mBuffer, desc);
|
||||
aPlaneInfo.mStride = desc.yStride();
|
||||
aPlaneInfo.mSize = desc.ySize();
|
||||
break;
|
||||
case 1:
|
||||
aPlaneInfo.mData =
|
||||
layers::ImageDataSerializer::GetCbChannel(mBuffer, desc);
|
||||
aPlaneInfo.mStride = desc.cbCrStride();
|
||||
aPlaneInfo.mSize = desc.cbCrSize();
|
||||
break;
|
||||
case 2:
|
||||
aPlaneInfo.mData =
|
||||
layers::ImageDataSerializer::GetCrChannel(mBuffer, desc);
|
||||
aPlaneInfo.mStride = desc.cbCrStride();
|
||||
aPlaneInfo.mSize = desc.cbCrSize();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
const layers::RGBDescriptor& desc = mDescriptor.get_RGBDescriptor();
|
||||
aPlaneInfo.mFormat = desc.format();
|
||||
aPlaneInfo.mData = mBuffer;
|
||||
aPlaneInfo.mStride = layers::ImageDataSerializer::GetRGBStride(desc);
|
||||
aPlaneInfo.mSize = desc.size();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderBufferTextureHostSWGL::UnmapPlanes() {}
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,36 @@
|
|||
/* -*- 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_RENDERBUFFERTEXTUREHOSTSWGL_H
|
||||
#define MOZILLA_GFX_RENDERBUFFERTEXTUREHOSTSWGL_H
|
||||
|
||||
#include "RenderTextureHostSWGL.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
class RenderBufferTextureHostSWGL final : public RenderTextureHostSWGL {
|
||||
public:
|
||||
RenderBufferTextureHostSWGL(uint8_t* aBuffer,
|
||||
const layers::BufferDescriptor& aDescriptor);
|
||||
|
||||
size_t GetPlaneCount() override;
|
||||
|
||||
bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) override;
|
||||
|
||||
void UnmapPlanes() override;
|
||||
|
||||
private:
|
||||
virtual ~RenderBufferTextureHostSWGL();
|
||||
|
||||
uint8_t* mBuffer;
|
||||
layers::BufferDescriptor mDescriptor;
|
||||
};
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZILLA_GFX_RENDERBUFFERTEXTUREHOSTSWGL_H
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- 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 "RenderMacIOSurfaceTextureHostSWGL.h"
|
||||
|
||||
#include "MacIOSurfaceHelpers.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
RenderMacIOSurfaceTextureHostSWGL::RenderMacIOSurfaceTextureHostSWGL(
|
||||
MacIOSurface* aSurface)
|
||||
: mSurface(aSurface) {
|
||||
MOZ_COUNT_CTOR_INHERITED(RenderMacIOSurfaceTextureHostSWGL,
|
||||
RenderTextureHostSWGL);
|
||||
MOZ_RELEASE_ASSERT(mSurface);
|
||||
}
|
||||
|
||||
RenderMacIOSurfaceTextureHostSWGL::~RenderMacIOSurfaceTextureHostSWGL() {
|
||||
MOZ_COUNT_DTOR_INHERITED(RenderMacIOSurfaceTextureHostSWGL,
|
||||
RenderTextureHostSWGL);
|
||||
}
|
||||
|
||||
size_t RenderMacIOSurfaceTextureHostSWGL::GetPlaneCount() {
|
||||
size_t planeCount = mSurface->GetPlaneCount();
|
||||
return planeCount > 0 ? planeCount : 1;
|
||||
}
|
||||
|
||||
bool RenderMacIOSurfaceTextureHostSWGL::MapPlane(uint8_t aChannelIndex,
|
||||
PlaneInfo& aPlaneInfo) {
|
||||
if (!aChannelIndex) {
|
||||
mSurface->Lock();
|
||||
}
|
||||
aPlaneInfo.mFormat = mSurface->GetFormat();
|
||||
aPlaneInfo.mData = mSurface->GetBaseAddressOfPlane(aChannelIndex);
|
||||
aPlaneInfo.mStride = mSurface->GetBytesPerRow(aChannelIndex);
|
||||
aPlaneInfo.mSize =
|
||||
gfx::IntSize(mSurface->GetDevicePixelWidth(aChannelIndex),
|
||||
mSurface->GetDevicePixelHeight(aChannelIndex));
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderMacIOSurfaceTextureHostSWGL::UnmapPlanes() { mSurface->Unlock(); }
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,35 @@
|
|||
/* -*- 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_RENDERMACIOSURFACETEXTUREHOSTSWGL_H
|
||||
#define MOZILLA_GFX_RENDERMACIOSURFACETEXTUREHOSTSWGL_H
|
||||
|
||||
#include "mozilla/gfx/MacIOSurface.h"
|
||||
#include "RenderTextureHostSWGL.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
class RenderMacIOSurfaceTextureHostSWGL final : public RenderTextureHostSWGL {
|
||||
public:
|
||||
explicit RenderMacIOSurfaceTextureHostSWGL(MacIOSurface* aSurface);
|
||||
|
||||
size_t GetPlaneCount() override;
|
||||
|
||||
bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) override;
|
||||
|
||||
void UnmapPlanes() override;
|
||||
|
||||
private:
|
||||
virtual ~RenderMacIOSurfaceTextureHostSWGL();
|
||||
|
||||
RefPtr<MacIOSurface> mSurface;
|
||||
};
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZILLA_GFX_RENDERMACIOSURFACETEXTUREHOSTSWGL_H
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- 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 "RenderSharedSurfaceTextureHostSWGL.h"
|
||||
|
||||
#include "mozilla/layers/SourceSurfaceSharedData.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
RenderSharedSurfaceTextureHostSWGL::RenderSharedSurfaceTextureHostSWGL(
|
||||
gfx::SourceSurfaceSharedDataWrapper* aSurface)
|
||||
: mSurface(aSurface) {
|
||||
MOZ_COUNT_CTOR_INHERITED(RenderSharedSurfaceTextureHostSWGL,
|
||||
RenderTextureHostSWGL);
|
||||
MOZ_ASSERT(aSurface);
|
||||
}
|
||||
|
||||
RenderSharedSurfaceTextureHostSWGL::~RenderSharedSurfaceTextureHostSWGL() {
|
||||
MOZ_COUNT_DTOR_INHERITED(RenderSharedSurfaceTextureHostSWGL,
|
||||
RenderTextureHostSWGL);
|
||||
}
|
||||
|
||||
size_t RenderSharedSurfaceTextureHostSWGL::GetPlaneCount() { return 1; }
|
||||
|
||||
bool RenderSharedSurfaceTextureHostSWGL::MapPlane(uint8_t aChannelIndex,
|
||||
PlaneInfo& aPlaneInfo) {
|
||||
if (NS_WARN_IF(
|
||||
!mSurface->Map(gfx::DataSourceSurface::MapType::READ_WRITE, &mMap))) {
|
||||
return false;
|
||||
}
|
||||
aPlaneInfo.mData = mMap.mData;
|
||||
aPlaneInfo.mStride = mMap.mStride;
|
||||
aPlaneInfo.mSize = mSurface->GetSize();
|
||||
aPlaneInfo.mFormat = mSurface->GetFormat();
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderSharedSurfaceTextureHostSWGL::UnmapPlanes() { mSurface->Unmap(); }
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- 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_RENDERSHAREDSURFACETEXTUREHOSTSWGL_H
|
||||
#define MOZILLA_GFX_RENDERSHAREDSURFACETEXTUREHOSTSWGL_H
|
||||
|
||||
#include "RenderTextureHostSWGL.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
class SourceSurfaceSharedDataWrapper;
|
||||
}
|
||||
|
||||
namespace wr {
|
||||
|
||||
/**
|
||||
* This class allows for surfaces managed by SharedSurfacesParent to be inserted
|
||||
* into the render texture cache by wrapping an existing surface wrapper. These
|
||||
* surfaces are backed by BGRA/X shared memory buffers.
|
||||
*/
|
||||
class RenderSharedSurfaceTextureHostSWGL final : public RenderTextureHostSWGL {
|
||||
public:
|
||||
explicit RenderSharedSurfaceTextureHostSWGL(
|
||||
gfx::SourceSurfaceSharedDataWrapper* aSurface);
|
||||
|
||||
size_t GetPlaneCount() override;
|
||||
|
||||
bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) override;
|
||||
|
||||
void UnmapPlanes() override;
|
||||
|
||||
private:
|
||||
virtual ~RenderSharedSurfaceTextureHostSWGL();
|
||||
|
||||
RefPtr<gfx::SourceSurfaceSharedDataWrapper> mSurface;
|
||||
gfx::DataSourceSurface::MappedSurface mMap;
|
||||
};
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZILLA_GFX_RENDERSHAREDSURFACETEXTUREHOSTSWGL_H
|
|
@ -41,5 +41,17 @@ bool RenderTextureHost::IsFilterUpdateNecessary(wr::ImageRendering aRendering) {
|
|||
return mCachedRendering != aRendering;
|
||||
}
|
||||
|
||||
wr::WrExternalImage RenderTextureHost::Lock(uint8_t aChannelIndex,
|
||||
gl::GLContext* aGL,
|
||||
wr::ImageRendering aRendering) {
|
||||
return InvalidToWrExternalImage();
|
||||
}
|
||||
|
||||
wr::WrExternalImage RenderTextureHost::LockSWGL(uint8_t aChannelIndex,
|
||||
void* aContext,
|
||||
wr::ImageRendering aRendering) {
|
||||
return InvalidToWrExternalImage();
|
||||
}
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/layers/LayersSurfaces.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/webrender/webrender_ffi.h" // for wr::ImageRendering
|
||||
#include "mozilla/webrender/WebRenderTypes.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -38,8 +39,15 @@ class RenderTextureHost {
|
|||
RenderTextureHost();
|
||||
|
||||
virtual wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL,
|
||||
wr::ImageRendering aRendering) = 0;
|
||||
virtual void Unlock() = 0;
|
||||
wr::ImageRendering aRendering);
|
||||
|
||||
virtual void Unlock() {}
|
||||
|
||||
virtual wr::WrExternalImage LockSWGL(uint8_t aChannelIndex, void* aContext,
|
||||
wr::ImageRendering aRendering);
|
||||
|
||||
virtual void UnlockSWGL() {}
|
||||
|
||||
virtual void ClearCachedResources() {}
|
||||
|
||||
// Called asynchronouly when corresponding TextureHost's mCompositableCount
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/* -*- 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 "RenderTextureHostSWGL.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
bool RenderTextureHostSWGL::UpdatePlanes(wr::ImageRendering aRendering) {
|
||||
wr_swgl_make_current(mContext);
|
||||
size_t planeCount = GetPlaneCount();
|
||||
bool filterUpdate = IsFilterUpdateNecessary(aRendering);
|
||||
if (mPlanes.size() < planeCount) {
|
||||
mPlanes.reserve(planeCount);
|
||||
while (mPlanes.size() < planeCount) {
|
||||
mPlanes.push_back(PlaneInfo(wr_swgl_gen_texture(mContext)));
|
||||
}
|
||||
filterUpdate = true;
|
||||
}
|
||||
for (size_t i = 0; i < planeCount; i++) {
|
||||
PlaneInfo& plane = mPlanes[i];
|
||||
if (!MapPlane(i, plane)) {
|
||||
if (i > 0) {
|
||||
UnmapPlanes();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
GLenum format = 0;
|
||||
switch (plane.mFormat) {
|
||||
case gfx::SurfaceFormat::B8G8R8A8:
|
||||
case gfx::SurfaceFormat::B8G8R8X8:
|
||||
format = LOCAL_GL_RGBA8;
|
||||
break;
|
||||
case gfx::SurfaceFormat::YUV:
|
||||
format = LOCAL_GL_R8;
|
||||
break;
|
||||
case gfx::SurfaceFormat::NV12:
|
||||
format = planeCount == 2 && i > 0 ? LOCAL_GL_RG8 : LOCAL_GL_R8;
|
||||
break;
|
||||
default:
|
||||
MOZ_RELEASE_ASSERT(false, "Unhandled external image format");
|
||||
break;
|
||||
}
|
||||
wr_swgl_set_texture_buffer(mContext, plane.mTexture, format,
|
||||
plane.mSize.width, plane.mSize.height,
|
||||
plane.mStride, plane.mData, 0, 0);
|
||||
}
|
||||
if (filterUpdate) {
|
||||
mCachedRendering = aRendering;
|
||||
GLenum filter = aRendering == wr::ImageRendering::Pixelated
|
||||
? LOCAL_GL_NEAREST
|
||||
: LOCAL_GL_LINEAR;
|
||||
for (const auto& plane : mPlanes) {
|
||||
wr_swgl_set_texture_parameter(mContext, plane.mTexture,
|
||||
LOCAL_GL_TEXTURE_MIN_FILTER, filter);
|
||||
wr_swgl_set_texture_parameter(mContext, plane.mTexture,
|
||||
LOCAL_GL_TEXTURE_MAG_FILTER, filter);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
wr::WrExternalImage RenderTextureHostSWGL::LockSWGL(
|
||||
uint8_t aChannelIndex, void* aContext, wr::ImageRendering aRendering) {
|
||||
if (mContext != aContext) {
|
||||
CleanupPlanes();
|
||||
mContext = aContext;
|
||||
wr_swgl_reference_context(mContext);
|
||||
}
|
||||
if (!mContext) {
|
||||
return InvalidToWrExternalImage();
|
||||
}
|
||||
if (!mLocked) {
|
||||
if (!UpdatePlanes(aRendering)) {
|
||||
return InvalidToWrExternalImage();
|
||||
}
|
||||
mLocked = true;
|
||||
}
|
||||
if (aChannelIndex >= mPlanes.size()) {
|
||||
return InvalidToWrExternalImage();
|
||||
}
|
||||
const PlaneInfo& plane = mPlanes[aChannelIndex];
|
||||
return NativeTextureToWrExternalImage(plane.mTexture, 0, 0, plane.mSize.width,
|
||||
plane.mSize.height);
|
||||
}
|
||||
|
||||
void RenderTextureHostSWGL::UnlockSWGL() {
|
||||
if (mLocked) {
|
||||
mLocked = false;
|
||||
UnmapPlanes();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTextureHostSWGL::CleanupPlanes() {
|
||||
if (!mContext) {
|
||||
return;
|
||||
}
|
||||
if (!mPlanes.empty()) {
|
||||
wr_swgl_make_current(mContext);
|
||||
for (const auto& plane : mPlanes) {
|
||||
wr_swgl_delete_texture(mContext, plane.mTexture);
|
||||
}
|
||||
mPlanes.clear();
|
||||
}
|
||||
wr_swgl_destroy_context(mContext);
|
||||
mContext = nullptr;
|
||||
}
|
||||
|
||||
RenderTextureHostSWGL::~RenderTextureHostSWGL() { CleanupPlanes(); }
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- 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_RENDERTEXTUREHOSTSWGL_H
|
||||
#define MOZILLA_GFX_RENDERTEXTUREHOSTSWGL_H
|
||||
|
||||
#include "RenderTextureHost.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
class RenderTextureHostSWGL : public RenderTextureHost {
|
||||
public:
|
||||
RenderTextureHostSWGL() {}
|
||||
|
||||
wr::WrExternalImage LockSWGL(uint8_t aChannelIndex, void* aContext,
|
||||
wr::ImageRendering aRendering) override;
|
||||
|
||||
void UnlockSWGL() override;
|
||||
|
||||
virtual size_t GetPlaneCount() = 0;
|
||||
|
||||
struct PlaneInfo {
|
||||
explicit PlaneInfo(GLuint aTexture) : mTexture(aTexture) {}
|
||||
|
||||
GLuint mTexture = 0;
|
||||
void* mData = nullptr;
|
||||
int32_t mStride = 0;
|
||||
gfx::IntSize mSize;
|
||||
gfx::SurfaceFormat mFormat = gfx::SurfaceFormat::UNKNOWN;
|
||||
};
|
||||
|
||||
virtual bool MapPlane(uint8_t aChannelIndex, PlaneInfo& aPlaneInfo) = 0;
|
||||
|
||||
virtual void UnmapPlanes() = 0;
|
||||
|
||||
protected:
|
||||
bool mLocked = false;
|
||||
void* mContext = nullptr;
|
||||
std::vector<PlaneInfo> mPlanes;
|
||||
|
||||
bool UpdatePlanes(wr::ImageRendering aRendering);
|
||||
|
||||
void CleanupPlanes();
|
||||
|
||||
virtual ~RenderTextureHostSWGL();
|
||||
};
|
||||
|
||||
} // namespace wr
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZILLA_GFX_RENDERTEXTUREHOSTSWGL_H
|
|
@ -25,6 +25,7 @@
|
|||
#include "mozilla/widget/CompositorWidget.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
# include "GLContextEGL.h"
|
||||
# include "GLLibraryEGL.h"
|
||||
# include "mozilla/widget/WinCompositorWindowThread.h"
|
||||
# include "mozilla/gfx/DeviceManagerDx.h"
|
||||
|
|
|
@ -33,7 +33,16 @@ wr::WrExternalImage wr_renderer_lock_external_image(
|
|||
<< AsUint64(aId);
|
||||
return InvalidToWrExternalImage();
|
||||
}
|
||||
return texture->Lock(aChannelIndex, renderer->gl(), aRendering);
|
||||
if (auto* gl = renderer->gl()) {
|
||||
return texture->Lock(aChannelIndex, gl, aRendering);
|
||||
} else if (auto* swgl = renderer->swgl()) {
|
||||
return texture->LockSWGL(aChannelIndex, swgl, aRendering);
|
||||
} else {
|
||||
gfxCriticalNoteOnce
|
||||
<< "No GL or SWGL context available to lock ExternalImage for extId:"
|
||||
<< AsUint64(aId);
|
||||
return InvalidToWrExternalImage();
|
||||
}
|
||||
}
|
||||
|
||||
void wr_renderer_unlock_external_image(void* aObj, wr::ExternalImageId aId,
|
||||
|
@ -44,7 +53,11 @@ void wr_renderer_unlock_external_image(void* aObj, wr::ExternalImageId aId,
|
|||
if (!texture) {
|
||||
return;
|
||||
}
|
||||
texture->Unlock();
|
||||
if (renderer->gl()) {
|
||||
texture->Unlock();
|
||||
} else if (renderer->swgl()) {
|
||||
texture->UnlockSWGL();
|
||||
}
|
||||
}
|
||||
|
||||
RendererOGL::RendererOGL(RefPtr<RenderThread>&& aThread,
|
||||
|
@ -240,6 +253,8 @@ layers::SyncObjectHost* RendererOGL::GetSyncObject() const {
|
|||
|
||||
gl::GLContext* RendererOGL::gl() const { return mCompositor->gl(); }
|
||||
|
||||
void* RendererOGL::swgl() const { return mCompositor->swgl(); }
|
||||
|
||||
void RendererOGL::SetFrameStartTime(const TimeStamp& aTime) {
|
||||
if (mFrameStartTime) {
|
||||
// frame start time is already set. This could happen when multiple
|
||||
|
|
|
@ -109,6 +109,8 @@ class RendererOGL {
|
|||
|
||||
gl::GLContext* gl() const;
|
||||
|
||||
void* swgl() const;
|
||||
|
||||
bool EnsureAsyncScreenshot();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -9,6 +9,7 @@ with Files('**'):
|
|||
|
||||
EXPORTS.mozilla.webrender += [
|
||||
'RenderBufferTextureHost.h',
|
||||
'RenderBufferTextureHostSWGL.h',
|
||||
'RenderCompositor.h',
|
||||
'RenderCompositorEGL.h',
|
||||
'RenderCompositorOGL.h',
|
||||
|
@ -18,8 +19,10 @@ EXPORTS.mozilla.webrender += [
|
|||
'RendererScreenshotGrabber.h',
|
||||
'RenderExternalTextureHost.h',
|
||||
'RenderSharedSurfaceTextureHost.h',
|
||||
'RenderSharedSurfaceTextureHostSWGL.h',
|
||||
'RenderTextureHost.h',
|
||||
'RenderTextureHostOGL.h',
|
||||
'RenderTextureHostSWGL.h',
|
||||
'RenderTextureHostWrapper.h',
|
||||
'RenderThread.h',
|
||||
'webrender_ffi.h',
|
||||
|
@ -30,6 +33,7 @@ EXPORTS.mozilla.webrender += [
|
|||
UNIFIED_SOURCES += [
|
||||
'Moz2DImageRenderer.cpp',
|
||||
'RenderBufferTextureHost.cpp',
|
||||
'RenderBufferTextureHostSWGL.cpp',
|
||||
'RenderCompositor.cpp',
|
||||
'RenderCompositorEGL.cpp',
|
||||
'RenderCompositorOGL.cpp',
|
||||
|
@ -39,8 +43,10 @@ UNIFIED_SOURCES += [
|
|||
'RendererScreenshotGrabber.cpp',
|
||||
'RenderExternalTextureHost.cpp',
|
||||
'RenderSharedSurfaceTextureHost.cpp',
|
||||
'RenderSharedSurfaceTextureHostSWGL.cpp',
|
||||
'RenderTextureHost.cpp',
|
||||
'RenderTextureHostOGL.cpp',
|
||||
'RenderTextureHostSWGL.cpp',
|
||||
'RenderTextureHostWrapper.cpp',
|
||||
'RenderThread.cpp',
|
||||
'WebRenderAPI.cpp',
|
||||
|
@ -51,10 +57,12 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
|||
EXPORTS.mozilla.webrender += [
|
||||
'RenderCompositorNative.h',
|
||||
'RenderMacIOSurfaceTextureHostOGL.h',
|
||||
'RenderMacIOSurfaceTextureHostSWGL.h',
|
||||
]
|
||||
UNIFIED_SOURCES += [
|
||||
'RenderCompositorNative.cpp',
|
||||
'RenderMacIOSurfaceTextureHostOGL.cpp',
|
||||
'RenderMacIOSurfaceTextureHostSWGL.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
|
|
|
@ -317,8 +317,8 @@ impl Context {
|
|||
pub fn reference(&self) {
|
||||
unsafe {
|
||||
ReferenceContext(self.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn destroy(&self) {
|
||||
unsafe {
|
||||
|
|
Загрузка…
Ссылка в новой задаче