Backed out changesets fce6b2c04bab and db5a4ed50de4 (bug 947045) and changeset bef65fd678a4 (bug 950235) for IPC test crashes on a CLOSED TREE.

This commit is contained in:
Ryan VanderMeulen 2014-02-05 15:45:03 -05:00
parent 5c70dff09e
commit 4ffb4c29de
8 changed files with 14 additions and 453 deletions

View File

@ -1,149 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// * 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 "mozilla/layers/TextureClientX11.h"
#include "mozilla/layers/CompositableClient.h"
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/ISurfaceAllocator.h"
#include "mozilla/layers/ShadowLayerUtilsX11.h"
#include "mozilla/gfx/2D.h"
#include "gfxXlibSurface.h"
#include "gfx2DGlue.h"
#include "mozilla/X11Util.h"
#include <X11/Xlib.h>
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::layers;
TextureClientX11::TextureClientX11(SurfaceFormat aFormat, TextureFlags aFlags)
: mFormat(aFormat),
mTextureFlags(aFlags)
{
MOZ_COUNT_CTOR(TextureClientX11);
}
TextureClientX11::~TextureClientX11()
{
MOZ_COUNT_DTOR(TextureClientX11);
}
bool
TextureClientX11::IsAllocated() const
{
return !!mSurface;
}
bool
TextureClientX11::Lock(OpenMode aMode)
{
// XXX - Turn this into a fatal assertion as soon as Bug 952507 is fixed
NS_WARN_IF_FALSE(!mLocked, "The TextureClient is already Locked!");
mLocked = true;
return IsValid() && IsAllocated();
}
void
TextureClientX11::Unlock()
{
// XXX - Turn this into a fatal assertion as soon as Bug 952507 is fixed
NS_WARN_IF_FALSE(mLocked, "The TextureClient is already Unlocked!");
mLocked = false;
if (mSurface) {
FinishX(DefaultXDisplay());
}
}
bool
TextureClientX11::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
{
MOZ_ASSERT(IsValid());
if (!mSurface) {
return false;
}
aOutDescriptor = SurfaceDescriptorX11(mSurface);
return true;
}
TextureClientData*
TextureClientX11::DropTextureData()
{
MOZ_ASSERT(!(mFlags & TEXTURE_DEALLOCATE_CLIENT));
return nullptr;
}
bool
TextureClientX11::UpdateSurface(gfxASurface* aSurface)
{
MOZ_ASSERT(IsValid());
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
RefPtr<DrawTarget> dt = GetAsDrawTarget();
if (!dt) {
return false;
}
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, aSurface);
dt->CopySurface(source, IntRect(IntPoint(), GetSize()), IntPoint());
} else {
if (!mSurface) {
return false;
}
nsRefPtr<gfxContext> ctx = new gfxContext(mSurface.get());
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
ctx->DrawSurface(aSurface, mSurface->GetSize());
}
return true;
}
already_AddRefed<gfxASurface>
TextureClientX11::GetAsSurface()
{
MOZ_ASSERT(IsValid());
if (!mSurface) {
return nullptr;
}
nsRefPtr<gfxASurface> temp = mSurface.get();
return temp.forget();
}
bool
TextureClientX11::AllocateForSurface(IntSize aSize, TextureAllocationFlags aTextureFlags)
{
MOZ_ASSERT(IsValid());
//MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This TextureClient cannot use YCbCr data");
gfxContentType contentType = ContentForFormat(mFormat);
gfxIntSize size = ThebesIntSize(aSize);
nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, contentType);
if (!surface || surface->GetType() != gfxSurfaceType::Xlib) {
NS_ERROR("creating Xlib surface failed!");
return false;
}
mSize = aSize;
mSurface = static_cast<gfxXlibSurface*>(surface.get());
// The host is always responsible for freeing the pixmap.
mSurface->ReleasePixmap();
return true;
}
TemporaryRef<DrawTarget>
TextureClientX11::GetAsDrawTarget()
{
MOZ_ASSERT(IsValid());
if (!mSurface) {
return nullptr;
}
IntSize size = ToIntSize(mSurface->GetSize());
return Factory::CreateDrawTargetForCairoSurface(mSurface->CairoSurface(), size);
}

View File

@ -1,68 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// * 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_TEXTURECLIENT_X11_H
#define MOZILLA_GFX_TEXTURECLIENT_X11_H
#include "mozilla/layers/TextureClient.h"
#include "ISurfaceAllocator.h" // For IsSurfaceDescriptorValid
#include "mozilla/layers/ShadowLayerUtilsX11.h"
namespace mozilla {
namespace layers {
/**
* A TextureClient implementation based on Xlib.
*/
class TextureClientX11
: public TextureClient,
public TextureClientSurface,
public TextureClientDrawTarget
{
public:
TextureClientX11(gfx::SurfaceFormat format, TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
~TextureClientX11();
// TextureClient
TextureClientSurface* AsTextureClientSurface() MOZ_OVERRIDE { return this; }
TextureClientDrawTarget* AsTextureClientDrawTarget() MOZ_OVERRIDE { return this; }
bool IsAllocated() const MOZ_OVERRIDE;
bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
TextureClientData* DropTextureData() MOZ_OVERRIDE;
gfx::IntSize GetSize() const {
return mSize;
}
bool Lock(OpenMode aMode) MOZ_OVERRIDE;
void Unlock() MOZ_OVERRIDE;
bool IsLocked() const MOZ_OVERRIDE { return mLocked; }
// TextureClientSurface
bool UpdateSurface(gfxASurface* aSurface) MOZ_OVERRIDE;
already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags flags) MOZ_OVERRIDE;
// TextureClientDrawTarget
TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() MOZ_OVERRIDE;
gfx::SurfaceFormat GetFormat() const {
return mFormat;
}
private:
gfx::SurfaceFormat mFormat;
TextureFlags mTextureFlags;
gfx::IntSize mSize;
RefPtr<gfxXlibSurface> mSurface;
bool mLocked;
};
} // namespace layers
} // namespace mozilla
#endif

View File

@ -4,9 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "TextureHostBasic.h"
#ifdef MOZ_X11
#include "TextureHostX11.h"
#endif
#include "MacIOSurfaceTextureHostBasic.h"
using namespace mozilla::gl;
@ -28,13 +25,6 @@ CreateTextureHostBasic(const SurfaceDescriptor& aDesc,
return result;
}
#endif
#ifdef MOZ_X11
if (aDesc.type() == SurfaceDescriptor::TSurfaceDescriptorX11) {
const SurfaceDescriptorX11& desc = aDesc.get_SurfaceDescriptorX11();
RefPtr<TextureHost> result = new TextureHostX11(aFlags, desc);
return result;
}
#endif
return CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
}

View File

@ -1,111 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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 "TextureHostX11.h"
#include "mozilla/layers/BasicCompositor.h"
#include "gfxXlibSurface.h"
#include "gfx2DGlue.h"
using namespace mozilla;
using namespace mozilla::layers;
using namespace mozilla::gfx;
static inline SurfaceFormat
ContentTypeToSurfaceFormat(gfxContentType type)
{
switch (type) {
case gfxContentType::COLOR:
return SurfaceFormat::B8G8R8X8;
case gfxContentType::ALPHA:
return SurfaceFormat::A8;
case gfxContentType::COLOR_ALPHA:
return SurfaceFormat::B8G8R8A8;
default:
return SurfaceFormat::UNKNOWN;
}
}
TextureSourceX11::TextureSourceX11(BasicCompositor* aCompositor, gfxXlibSurface* aSurface)
: mCompositor(aCompositor),
mSurface(aSurface)
{
}
IntSize
TextureSourceX11::GetSize() const
{
return ToIntSize(mSurface->GetSize());
}
SurfaceFormat
TextureSourceX11::GetFormat() const
{
return ContentTypeToSurfaceFormat(mSurface->GetContentType());
}
SourceSurface*
TextureSourceX11::GetSurface()
{
if (!mSourceSurface) {
mSourceSurface =
Factory::CreateSourceSurfaceForCairoSurface(mSurface->CairoSurface(), GetFormat());
}
return mSourceSurface;
}
void
TextureSourceX11::SetCompositor(Compositor* aCompositor)
{
BasicCompositor* compositor = static_cast<BasicCompositor*>(aCompositor);
mCompositor = compositor;
}
TextureHostX11::TextureHostX11(TextureFlags aFlags,
const SurfaceDescriptorX11& aDescriptor)
: TextureHost(aFlags)
{
nsRefPtr<gfxXlibSurface> surface = aDescriptor.OpenForeign();
mSurface = surface.get();
// The host always frees the pixmap.
MOZ_ASSERT(!(aFlags & TEXTURE_DEALLOCATE_CLIENT));
mSurface->TakePixmap();
}
bool
TextureHostX11::Lock()
{
if (!mCompositor) {
return false;
}
if (!mTextureSource) {
mTextureSource = new TextureSourceX11(mCompositor, mSurface);
}
return true;
}
void
TextureHostX11::SetCompositor(Compositor* aCompositor)
{
BasicCompositor* compositor = static_cast<BasicCompositor*>(aCompositor);
mCompositor = compositor;
if (mTextureSource) {
mTextureSource->SetCompositor(compositor);
}
}
SurfaceFormat
TextureHostX11::GetFormat() const
{
return ContentTypeToSurfaceFormat(mSurface->GetContentType());
}
IntSize
TextureHostX11::GetSize() const
{
return ToIntSize(mSurface->GetSize());
}

View File

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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_TEXTUREHOSTX11__H
#define MOZILLA_GFX_TEXTUREHOSTX11__H
#include "mozilla/layers/TextureHostBasic.h"
#include "mozilla/gfx/2D.h"
namespace mozilla {
namespace layers {
class BasicCompositor;
// TextureSource for Xlib-backed surfaces.
class TextureSourceX11
: public TextureSourceBasic,
public NewTextureSource
{
public:
TextureSourceX11(BasicCompositor* aCompositor, gfxXlibSurface* aSurface);
virtual TextureSourceX11* AsSourceBasic() MOZ_OVERRIDE { return this; }
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
virtual gfx::SourceSurface* GetSurface() MOZ_OVERRIDE;
virtual void DeallocateDeviceData() MOZ_OVERRIDE { }
virtual void SetCompositor(Compositor* aCompositor);
protected:
BasicCompositor* mCompositor;
RefPtr<gfxXlibSurface> mSurface;
RefPtr<gfx::SourceSurface> mSourceSurface;
};
// TextureSource for Xlib-backed TextureSources.
class TextureHostX11 : public TextureHost
{
public:
TextureHostX11(TextureFlags aFlags,
const SurfaceDescriptorX11& aDescriptor);
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
virtual bool Lock() MOZ_OVERRIDE;
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
{
return mTextureSource;
}
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
{
return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
}
#ifdef MOZ_LAYERS_HAVE_LOG
virtual const char* Name() { return "TextureHostX11"; }
#endif
protected:
BasicCompositor* mCompositor;
RefPtr<TextureSourceX11> mTextureSource;
RefPtr<gfxXlibSurface> mSurface;
};
} // namespace layers
} // namespace mozilla
#endif // MOZILLA_GFX_TEXTUREHOSTX11__H

View File

@ -17,9 +17,6 @@
#include "gfxWindowsPlatform.h"
#include "gfx2DGlue.h"
#endif
#ifdef MOZ_X11
#include "mozilla/layers/TextureClientX11.h"
#endif
using namespace mozilla::gfx;
@ -215,17 +212,6 @@ CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
}
}
#endif
#ifdef MOZ_X11
LayersBackend parentBackend = GetForwarder()->GetCompositorBackendType();
if (parentBackend == LayersBackend::LAYERS_BASIC &&
gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType() == gfxSurfaceType::Xlib &&
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK))
{
result = new TextureClientX11(aFormat, aTextureFlags);
}
#endif
// Can't do any better than a buffer texture client.
if (!result) {
result = CreateBufferTextureClient(aFormat, aTextureFlags);

View File

@ -167,34 +167,27 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
{
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorShmem:
case SurfaceDescriptor::TSurfaceDescriptorMemory:
return CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
case SurfaceDescriptor::TSharedTextureDescriptor:
case SurfaceDescriptor::TSurfaceDescriptorGralloc:
case SurfaceDescriptor::TNewSurfaceDescriptorGralloc:
case SurfaceDescriptor::TSurfaceStreamDescriptor:
switch (Compositor::GetBackend()) {
case LayersBackend::LAYERS_OPENGL:
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface:
if (Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) {
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
} else {
return CreateTextureHostBasic(aDesc, aDeallocator, aFlags);
}
#ifdef MOZ_X11
case SurfaceDescriptor::TSurfaceDescriptorX11:
case LayersBackend::LAYERS_BASIC:
return CreateTextureHostBasic(aDesc, aDeallocator, aFlags);
#ifdef MOZ_WIDGET_GONK
case LayersBackend::LAYERS_NONE:
// Power on video reqests to allocate TextureHost,
// when Compositor is still not present. This is a very hacky workaround.
// See Bug 944420.
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
#endif
#ifdef XP_WIN
case SurfaceDescriptor::TSurfaceDescriptorD3D9:
case SurfaceDescriptor::TSurfaceDescriptorDIB:
return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags);
case SurfaceDescriptor::TSurfaceDescriptorD3D10:
case LayersBackend::LAYERS_D3D11:
return CreateTextureHostD3D11(aDesc, aDeallocator, aFlags);
case LayersBackend::LAYERS_D3D9:
return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags);
#endif
default:
MOZ_CRASH("Unsupported Surface type");
MOZ_CRASH("Couldn't create texture host");
return nullptr;
}
}

View File

@ -157,13 +157,9 @@ EXPORTS.mozilla.layers += [
if CONFIG['MOZ_X11']:
EXPORTS.mozilla.layers += [
'basic/TextureClientX11.h',
'basic/TextureHostX11.h',
'ipc/ShadowLayerUtilsX11.h',
]
SOURCES += [
'basic/TextureClientX11.cpp',
'basic/TextureHostX11.cpp',
'ipc/ShadowLayerUtilsX11.cpp'
]