Backed out changeset d078b56f0fa6 (bug 1388020) for OS X crashtest failures. r=backout

This commit is contained in:
Andrew Osmond 2018-02-06 22:18:29 -05:00
Родитель 595dccd4e7
Коммит 5a683f0a80
10 изменённых файлов: 49 добавлений и 100 удалений

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

@ -761,7 +761,7 @@ protected:
friend void TestTextureClientSurface(TextureClient*, gfxImageSurface*);
friend void TestTextureClientYCbCr(TextureClient*, PlanarYCbCrData&);
friend already_AddRefed<TextureHost> CreateTextureHostWithBackend(
TextureClient*, ISurfaceAllocator*, LayersBackend&);
TextureClient*, LayersBackend&);
#ifdef GFX_DEBUG_TRACK_CLIENTS_IN_POOL
public:

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

@ -116,9 +116,15 @@ TextureHost::CreateIPDLActor(HostIPCAllocator* aAllocator,
uint64_t aSerial,
const wr::MaybeExternalImageId& aExternalImageId)
{
if (aSharedData.type() == SurfaceDescriptor::TSurfaceDescriptorBuffer &&
aSharedData.get_SurfaceDescriptorBuffer().data().type() == MemoryOrShmem::Tuintptr_t &&
!aAllocator->IsSameProcess())
{
NS_ERROR("A client process is trying to peek at our address space using a MemoryTexture!");
return nullptr;
}
TextureParent* actor = new TextureParent(aAllocator, aSerial, aExternalImageId);
if (!actor->Init(aSharedData, aLayersBackend, aFlags)) {
actor->ActorDestroy(ipc::IProtocol::ActorDestroyReason::FailedConstructor);
delete actor;
return nullptr;
}
@ -226,11 +232,6 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
#ifdef MOZ_X11
case SurfaceDescriptor::TSurfaceDescriptorX11: {
if (!aDeallocator->IsSameProcess()) {
NS_ERROR("A client process is trying to peek at our address space using a X11Texture!");
return nullptr;
}
const SurfaceDescriptorX11& desc = aDesc.get_SurfaceDescriptorX11();
result = MakeAndAddRef<X11TextureHost>(aFlags, desc);
break;
@ -247,7 +248,7 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
MOZ_CRASH("GFX: Unsupported Surface type host");
}
if (result && WrapWithWebRenderTextureHost(aDeallocator, aBackend, aFlags)) {
if (WrapWithWebRenderTextureHost(aDeallocator, aBackend, aFlags)) {
MOZ_ASSERT(aExternalImageId.isSome());
result = new WebRenderTextureHost(aDesc, aFlags, result, aExternalImageId.ref());
}
@ -268,42 +269,13 @@ CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
const MemoryOrShmem& data = bufferDesc.data();
switch (data.type()) {
case MemoryOrShmem::TShmem: {
const ipc::Shmem& shmem = data.get_Shmem();
const BufferDescriptor& desc = bufferDesc.desc();
size_t bufSize = shmem.Size<char>();
size_t reqSize = SIZE_MAX;
switch (desc.type()) {
case BufferDescriptor::TYCbCrDescriptor: {
const YCbCrDescriptor& ycbcr = desc.get_YCbCrDescriptor();
reqSize =
ImageDataSerializer::ComputeYCbCrBufferSize(ycbcr.ySize(), ycbcr.yStride(),
ycbcr.cbCrSize(), ycbcr.cbCrStride());
break;
}
case BufferDescriptor::TRGBDescriptor: {
const RGBDescriptor& rgb = desc.get_RGBDescriptor();
reqSize = ImageDataSerializer::ComputeRGBBufferSize(rgb.size(), rgb.format());
break;
}
default:
gfxCriticalError() << "Bad buffer host descriptor " << (int)desc.type();
MOZ_CRASH("GFX: Bad descriptor");
}
if (bufSize < reqSize) {
NS_ERROR("A client process gave a shmem too small to fit for its escriptor!");
return nullptr;
}
result = new ShmemTextureHost(shmem, desc, aDeallocator, aFlags);
result = new ShmemTextureHost(data.get_Shmem(),
bufferDesc.desc(),
aDeallocator,
aFlags);
break;
}
case MemoryOrShmem::Tuintptr_t: {
if (!aDeallocator->IsSameProcess()) {
NS_ERROR("A client process is trying to peek at our address space using a MemoryTexture!");
return nullptr;
}
result = new MemoryTextureHost(reinterpret_cast<uint8_t*>(data.get_uintptr_t()),
bufferDesc.desc(),
aFlags);
@ -321,11 +293,6 @@ CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
}
#ifdef XP_WIN
case SurfaceDescriptor::TSurfaceDescriptorDIB: {
if (!aDeallocator->IsSameProcess()) {
NS_ERROR("A client process is trying to peek at our address space using a DIBTexture!");
return nullptr;
}
result = new DIBTextureHost(aFlags, aDesc);
break;
}

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

@ -23,9 +23,10 @@ X11TextureHost::X11TextureHost(TextureFlags aFlags,
const SurfaceDescriptorX11& aDescriptor)
: TextureHost(aFlags)
{
mSurface = aDescriptor.OpenForeign();
RefPtr<gfxXlibSurface> surface = aDescriptor.OpenForeign();
mSurface = surface.get();
if (mSurface && !(aFlags & TextureFlags::DEALLOCATE_CLIENT)) {
if (!(aFlags & TextureFlags::DEALLOCATE_CLIENT)) {
mSurface->TakePixmap();
}
}
@ -33,7 +34,7 @@ X11TextureHost::X11TextureHost(TextureFlags aFlags,
bool
X11TextureHost::Lock()
{
if (!mCompositor || !mSurface) {
if (!mCompositor) {
return false;
}
@ -74,9 +75,6 @@ X11TextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
SurfaceFormat
X11TextureHost::GetFormat() const
{
if (!mSurface) {
return SurfaceFormat::UNKNOWN;
}
gfxContentType type = mSurface->GetContentType();
#ifdef GL_PROVIDER_GLX
if (mCompositor->GetBackendType() == LayersBackend::LAYERS_OPENGL) {
@ -89,9 +87,6 @@ X11TextureHost::GetFormat() const
IntSize
X11TextureHost::GetSize() const
{
if (!mSurface) {
return IntSize();
}
return mSurface->GetSize();
}

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

@ -763,6 +763,10 @@ CreateTextureHostD3D11(const SurfaceDescriptor& aDesc,
{
RefPtr<TextureHost> result;
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorBuffer: {
result = CreateBackendIndependentTextureHost(aDesc, aDeallocator, aBackend, aFlags);
break;
}
case SurfaceDescriptor::TSurfaceDescriptorD3D10: {
result = new DXGITextureHostD3D11(aFlags,
aDesc.get_SurfaceDescriptorD3D10());
@ -774,7 +778,7 @@ CreateTextureHostD3D11(const SurfaceDescriptor& aDesc,
break;
}
default: {
MOZ_ASSERT_UNREACHABLE("Unsupported SurfaceDescriptor type");
NS_WARNING("Unsupported SurfaceDescriptor type");
}
}
return result.forget();

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

@ -32,8 +32,6 @@ MacIOSurfaceTextureHostOGL::~MacIOSurfaceTextureHostOGL()
GLTextureSource*
MacIOSurfaceTextureHostOGL::CreateTextureSourceForPlane(size_t aPlane)
{
MOZ_ASSERT(mSurface);
GLuint textureHandle;
gl::GLContext* gl = mProvider->GetGLContext();
gl->fGenTextures(1, &textureHandle);
@ -96,17 +94,11 @@ MacIOSurfaceTextureHostOGL::SetTextureSourceProvider(TextureSourceProvider* aPro
gfx::SurfaceFormat
MacIOSurfaceTextureHostOGL::GetFormat() const {
if (!mSurface) {
return gfx::SurfaceFormat::UNKNOWN;
}
return mSurface->GetFormat();
}
gfx::SurfaceFormat
MacIOSurfaceTextureHostOGL::GetReadFormat() const {
if (!mSurface) {
return gfx::SurfaceFormat::UNKNOWN;
}
return mSurface->GetReadFormat();
}

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

@ -26,6 +26,10 @@
#include "mozilla/layers/MacIOSurfaceTextureHostOGL.h"
#endif
#ifdef GL_PROVIDER_GLX
#include "mozilla/layers/X11TextureHost.h"
#endif
using namespace mozilla::gl;
using namespace mozilla::gfx;
@ -42,6 +46,14 @@ CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
{
RefPtr<TextureHost> result;
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorBuffer: {
result = CreateBackendIndependentTextureHost(aDesc,
aDeallocator,
aBackend,
aFlags);
break;
}
#ifdef MOZ_WIDGET_ANDROID
case SurfaceDescriptor::TSurfaceTextureDescriptor: {
const SurfaceTextureDescriptor& desc = aDesc.get_SurfaceTextureDescriptor();
@ -76,6 +88,14 @@ CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
}
#endif
#ifdef GL_PROVIDER_GLX
case SurfaceDescriptor::TSurfaceDescriptorX11: {
const auto& desc = aDesc.get_SurfaceDescriptorX11();
result = new X11TextureHost(aFlags, desc);
break;
}
#endif
case SurfaceDescriptor::TSurfaceDescriptorSharedGLTexture: {
const auto& desc = aDesc.get_SurfaceDescriptorSharedGLTexture();
result = new GLTextureHost(aFlags, desc.texture(),
@ -85,10 +105,7 @@ CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
desc.hasAlpha());
break;
}
default: {
MOZ_ASSERT_UNREACHABLE("Unsupported SurfaceDescriptor type");
break;
}
default: return nullptr;
}
return result.forget();
}

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

@ -8,22 +8,6 @@
#include "Layers.h"
#include "nsTArray.h"
#include "mozilla/layers/ISurfaceAllocator.h"
namespace mozilla {
namespace layers {
class TestSurfaceAllocator final : public ISurfaceAllocator
{
public:
TestSurfaceAllocator() {}
~TestSurfaceAllocator() override {}
bool IsSameProcess() const override { return true; }
};
} // layers
} // mozilla
/* Create layer tree from a simple layer tree description syntax.
* Each index is either the first letter of the layer type or

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

@ -14,7 +14,6 @@
#include "mozilla/layers/TextureClient.h"
#include "mozilla/layers/TextureHost.h"
#include "mozilla/RefPtr.h"
#include "TestLayers.h"
#include "TextureHelper.h"
using mozilla::gfx::Feature;
@ -23,7 +22,6 @@ using mozilla::layers::BasicCompositor;
using mozilla::layers::Compositor;
using mozilla::layers::CompositorOptions;
using mozilla::layers::LayersBackend;
using mozilla::layers::TestSurfaceAllocator;
using mozilla::layers::TextureClient;
using mozilla::layers::TextureHost;
using mozilla::widget::CompositorWidget;
@ -33,9 +31,8 @@ using mozilla::widget::InProcessCompositorWidget;
* This function will create the possible TextureClient and TextureHost pairs
* according to the given backend.
*/
static void
void
CreateTextureWithBackend(LayersBackend& aLayersBackend,
ISurfaceAllocator* aDeallocator,
nsTArray<RefPtr<TextureClient>>& aTextureClients,
nsTArray<RefPtr<TextureHost>>& aTextureHosts)
{
@ -46,8 +43,7 @@ CreateTextureWithBackend(LayersBackend& aLayersBackend,
for (uint32_t i = 0; i < aTextureClients.Length(); i++) {
aTextureHosts.AppendElement(
CreateTextureHostWithBackend(aTextureClients[i], aDeallocator,
aLayersBackend));
CreateTextureHostWithBackend(aTextureClients[i], aLayersBackend));
}
}
@ -119,15 +115,13 @@ CheckCompatibilityWithBasicCompositor(LayersBackend aBackends,
TEST(Gfx, TestTextureCompatibility)
{
nsTArray<LayersBackend> backendHints;
RefPtr<TestSurfaceAllocator> deallocator = new TestSurfaceAllocator();
GetPlatformBackends(backendHints);
for (uint32_t i = 0; i < backendHints.Length(); i++) {
nsTArray<RefPtr<TextureClient>> textureClients;
nsTArray<RefPtr<TextureHost>> textureHosts;
CreateTextureWithBackend(backendHints[i], deallocator,
textureClients, textureHosts);
CreateTextureWithBackend(backendHints[i], textureClients, textureHosts);
CheckCompatibilityWithBasicCompositor(backendHints[i], textureHosts);
}
}

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

@ -5,7 +5,6 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "TestLayers.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Tools.h"
@ -148,8 +147,7 @@ void TestTextureClientSurface(TextureClient* texture, gfxImageSurface* surface)
ASSERT_NE(descriptor.type(), SurfaceDescriptor::Tnull_t);
// host deserialization
RefPtr<TestSurfaceAllocator> deallocator = new TestSurfaceAllocator();
RefPtr<TextureHost> host = CreateBackendIndependentTextureHost(descriptor, deallocator,
RefPtr<TextureHost> host = CreateBackendIndependentTextureHost(descriptor, nullptr,
LayersBackend::LAYERS_NONE,
texture->GetFlags());
@ -195,8 +193,7 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
ASSERT_EQ(ycbcrDesc.stereoMode(), ycbcrData.mStereoMode);
// host deserialization
RefPtr<TestSurfaceAllocator> deallocator = new TestSurfaceAllocator();
RefPtr<TextureHost> textureHost = CreateBackendIndependentTextureHost(descriptor, deallocator,
RefPtr<TextureHost> textureHost = CreateBackendIndependentTextureHost(descriptor, nullptr,
LayersBackend::LAYERS_NONE,
client->GetFlags());

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

@ -140,7 +140,6 @@ CreateTextureClientWithBackend(LayersBackend aLayersBackend)
*/
already_AddRefed<TextureHost>
CreateTextureHostWithBackend(TextureClient* aClient,
ISurfaceAllocator* aDeallocator,
LayersBackend& aLayersBackend)
{
if (!aClient) {
@ -154,7 +153,7 @@ CreateTextureHostWithBackend(TextureClient* aClient,
aClient->ToSurfaceDescriptor(descriptor);
wr::MaybeExternalImageId id = Nothing();
return TextureHost::Create(descriptor, aDeallocator, aLayersBackend,
return TextureHost::Create(descriptor, nullptr, aLayersBackend,
aClient->GetFlags(), id);
}