Bug 991028 - Remove deprecated IPDL SurfaceDescriptor types. r=nical

This commit is contained in:
Matt Woodrow 2014-04-07 13:32:49 +12:00
Родитель b9ca218121
Коммит 605fb137f9
14 изменённых файлов: 49 добавлений и 212 удалений

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

@ -17,6 +17,7 @@
#include "AudioChannelFormat.h"
#include <mozilla/Monitor.h>
#include "mozilla/layers/GrallocTextureClient.h"
using namespace mozilla;
using namespace mozilla::gfx;
@ -256,9 +257,9 @@ void
ConvertGrallocImageToNV12(GrallocImage* aSource, uint8_t* aDestination)
{
// Get graphic buffer.
SurfaceDescriptor handle = aSource->GetSurfaceDescriptor();
SurfaceDescriptorGralloc gralloc = handle.get_SurfaceDescriptorGralloc();
sp<GraphicBuffer> graphicBuffer = GrallocBufferActor::GetFrom(gralloc);
GrallocTextureClientOGL* client =
static_cast<GrallocTextureClientOGL*>(aSource->GetTextureClient(nullptr));
sp<GraphicBuffer> graphicBuffer = client->GetGraphicBuffer();
int pixelFormat = graphicBuffer->getPixelFormat();
// Only support NV21 (from camera) or YV12 (from HW decoder output) for now.

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

@ -6,6 +6,7 @@
#include "Layers.h"
#include "ImageTypes.h"
#include "ImageContainer.h"
#include "mozilla/layers/GrallocTextureClient.h"
#include "nsMemory.h"
#include "mtransport/runnable_utils.h"
@ -653,9 +654,9 @@ MediaEngineWebRTCVideoSource::OnTakePictureComplete(uint8_t* aData, uint32_t aLe
void
MediaEngineWebRTCVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight) {
layers::GrallocImage *nativeImage = static_cast<layers::GrallocImage*>(aImage);
layers::SurfaceDescriptor handle = nativeImage->GetSurfaceDescriptor();
layers::SurfaceDescriptorGralloc grallocHandle = handle.get_SurfaceDescriptorGralloc();
android::sp<android::GraphicBuffer> graphicBuffer = layers::GrallocBufferActor::GetFrom(grallocHandle);
layers::GrallocTextureClientOGL* client =
static_cast<layers::GrallocTextureClientOGL*>(nativeImage->GetTextureClient(nullptr));
android::sp<android::GraphicBuffer> graphicBuffer = client->GetGraphicBuffer();
void *pMem = nullptr;
uint32_t size = aWidth * aHeight * 3 / 2;

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

@ -146,7 +146,6 @@ TextureHost::Create(const SurfaceDescriptor& aDesc,
case SurfaceDescriptor::TSurfaceDescriptorMemory:
return CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
case SurfaceDescriptor::TSharedTextureDescriptor:
case SurfaceDescriptor::TSurfaceDescriptorGralloc:
case SurfaceDescriptor::TNewSurfaceDescriptorGralloc:
case SurfaceDescriptor::TSurfaceStreamDescriptor:
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);

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

@ -105,16 +105,6 @@ public:
virtual void UpdatePictureRect(CompositableClient* aCompositable,
const nsIntRect& aRect) = 0;
/**
* The specified layer is destroying its buffers.
* |aBackBufferToDestroy| is deallocated when this transaction is
* posted to the parent. During the parent-side transaction, the
* shadow is told to destroy its front buffer. This can happen when
* a new front/back buffer pair have been created because of a layer
* resize, e.g.
*/
virtual void DestroyedThebesBuffer(const SurfaceDescriptor& aBackBufferToDestroy) = 0;
/**
* Tell the CompositableHost on the compositor side to remove the texture.
* This function does not delete the TextureHost corresponding to the

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

@ -63,14 +63,14 @@ static inline uint8_t*
GetAddressFromDescriptor(const SurfaceDescriptor& aDescriptor, size_t& aSize)
{
MOZ_ASSERT(IsSurfaceDescriptorValid(aDescriptor));
MOZ_ASSERT(aDescriptor.type() == SurfaceDescriptor::TShmem ||
aDescriptor.type() == SurfaceDescriptor::TMemoryImage);
if (aDescriptor.type() == SurfaceDescriptor::TShmem) {
Shmem shmem(aDescriptor.get_Shmem());
MOZ_ASSERT(aDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorShmem ||
aDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorMemory);
if (aDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorShmem) {
Shmem shmem(aDescriptor.get_SurfaceDescriptorShmem().data());
aSize = shmem.Size<uint8_t>();
return shmem.get<uint8_t>();
} else {
const MemoryImage& image = aDescriptor.get_MemoryImage();
const SurfaceDescriptorMemory& image = aDescriptor.get_SurfaceDescriptorMemory();
aSize = std::numeric_limits<size_t>::max();
return reinterpret_cast<uint8_t*>(image.data());
}
@ -94,27 +94,6 @@ GetSurfaceForDescriptor(const SurfaceDescriptor& aDescriptor)
return image.GetAsSurface();
}
bool
ISurfaceAllocator::AllocSharedImageSurface(const gfx::IntSize& aSize,
gfxContentType aContent,
gfxSharedImageSurface** aBuffer)
{
mozilla::ipc::SharedMemory::SharedMemoryType shmemType = OptimalShmemType();
gfxImageFormat format = gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent);
nsRefPtr<gfxSharedImageSurface> back =
gfxSharedImageSurface::CreateUnsafe(this,
gfx::ThebesIntSize(aSize),
format,
shmemType);
if (!back)
return false;
*aBuffer = nullptr;
back.swap(*aBuffer);
return true;
}
bool
ISurfaceAllocator::AllocSurfaceDescriptor(const gfx::IntSize& aSize,
gfxContentType aContent,
@ -129,11 +108,11 @@ ISurfaceAllocator::AllocSurfaceDescriptorWithCaps(const gfx::IntSize& aSize,
uint32_t aCaps,
SurfaceDescriptor* aBuffer)
{
if (XRE_GetProcessType() == GeckoProcessType_Default) {
gfxImageFormat format =
gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent);
int32_t stride = gfxASurface::FormatStrideForWidth(format, aSize.width);
uint8_t *data = new (std::nothrow) uint8_t[stride * aSize.height];
gfx::SurfaceFormat format =
gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aContent);
size_t size = ImageDataSerializer::ComputeMinBufferSize(aSize, format);
if (gfxPlatform::GetPlatform()->PreferMemoryOverShmem()) {
uint8_t *data = new (std::nothrow) uint8_t[size];
if (!data) {
return false;
}
@ -141,30 +120,32 @@ ISurfaceAllocator::AllocSurfaceDescriptorWithCaps(const gfx::IntSize& aSize,
#ifdef XP_MACOSX
// Workaround a bug in Quartz where drawing an a8 surface to another a8
// surface with OPERATOR_SOURCE still requires the destination to be clear.
if (format == gfxImageFormat::A8) {
memset(data, 0, stride * aSize.height);
if (format == SurfaceFormat::A8) {
memset(data, 0, size);
}
#endif
*aBuffer = MemoryImage((uintptr_t)data, aSize, stride, format);
return true;
}
*aBuffer = SurfaceDescriptorMemory((uintptr_t)data, format);
} else {
nsRefPtr<gfxSharedImageSurface> buffer;
if (!AllocSharedImageSurface(aSize, aContent,
getter_AddRefs(buffer))) {
return false;
}
mozilla::ipc::SharedMemory::SharedMemoryType shmemType = OptimalShmemType();
mozilla::ipc::Shmem shmem;
if (!AllocUnsafeShmem(size, shmemType, &shmem)) {
return false;
}
*aBuffer = buffer->GetShmem();
*aBuffer = SurfaceDescriptorShmem(shmem, format);
}
uint8_t* data = GetAddressFromDescriptor(*aBuffer, size);
ImageDataSerializer serializer(data, size);
serializer.InitializeBufferInfo(aSize, format);
return true;
}
/* static */ bool
ISurfaceAllocator::IsShmem(SurfaceDescriptor* aSurface)
{
return aSurface && (aSurface->type() == SurfaceDescriptor::TShmem ||
aSurface->type() == SurfaceDescriptor::TYCbCrImage ||
aSurface->type() == SurfaceDescriptor::TRGBImage);
return aSurface && (aSurface->type() == SurfaceDescriptor::TSurfaceDescriptorShmem);
}
void
@ -178,22 +159,12 @@ ISurfaceAllocator::DestroySharedSurface(SurfaceDescriptor* aSurface)
return;
}
switch (aSurface->type()) {
case SurfaceDescriptor::TShmem:
DeallocShmem(aSurface->get_Shmem());
case SurfaceDescriptor::TSurfaceDescriptorShmem:
DeallocShmem(aSurface->get_SurfaceDescriptorShmem().data());
break;
case SurfaceDescriptor::TYCbCrImage:
DeallocShmem(aSurface->get_YCbCrImage().data());
break;
case SurfaceDescriptor::TRGBImage:
DeallocShmem(aSurface->get_RGBImage().data());
break;
case SurfaceDescriptor::TSurfaceDescriptorD3D9:
case SurfaceDescriptor::TSurfaceDescriptorDIB:
case SurfaceDescriptor::TSurfaceDescriptorD3D10:
break;
case SurfaceDescriptor::TMemoryImage:
GfxMemoryImageReporter::WillFree((uint8_t*)aSurface->get_MemoryImage().data());
delete [] (uint8_t*)aSurface->get_MemoryImage().data();
case SurfaceDescriptor::TSurfaceDescriptorMemory:
GfxMemoryImageReporter::WillFree((uint8_t*)aSurface->get_SurfaceDescriptorMemory().data());
delete [] (uint8_t*)aSurface->get_SurfaceDescriptorMemory().data();
break;
case SurfaceDescriptor::Tnull_t:
case SurfaceDescriptor::T__None:

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

@ -137,9 +137,6 @@ public:
virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) = 0;
// was AllocBuffer
virtual bool AllocSharedImageSurface(const gfx::IntSize& aSize,
gfxContentType aContent,
gfxSharedImageSurface** aBuffer);
virtual bool AllocSurfaceDescriptor(const gfx::IntSize& aSize,
gfxContentType aContent,
SurfaceDescriptor* aBuffer);

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

@ -276,11 +276,6 @@ public:
const nsIntRegion& aUpdatedRegion) MOZ_OVERRIDE {
NS_RUNTIMEABORT("should not be called");
}
virtual void DestroyedThebesBuffer(const SurfaceDescriptor& aBackBufferToDestroy) MOZ_OVERRIDE
{
NS_RUNTIMEABORT("should not be called");
}
// ISurfaceAllocator

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

@ -66,63 +66,11 @@ struct NewSurfaceDescriptorGralloc {
IntSize size;
};
// XXX - soon to be removed
struct SurfaceDescriptorGralloc {
PGrallocBuffer buffer;
/**
* android::GraphicBuffer has a size information. But there are cases
* that GraphicBuffer's size and actual video's size are different.
* Extra size member is necessary. See Bug 850566.
*/
IntSize size;
/**
* We can have one source producing gralloc buffers and sharing them
* with another source that may also produce its own gralloc buffers.
* This happens for camera preview buffers sent to video code. When
* that happens, the producer can mark the buffer as "external" to
* prevent its consumer from mistakenly freeing the buffer.
*/
bool external;
/**
* This gralloc buffer will be treated as if the RB bytes are swapped.
* This is useful for rendering using Cairo/Thebes, because there is no
* BGRX Android pixel format, and so we have to do byte swapping.
*
* For example, if the GraphicBuffer has an Android pixel format of
* PIXEL_FORMAT_RGBA_8888 and isRBSwapped is true, when it is sampled
* (for example, with GL), a BGRA shader should be used.
*/
bool isRBSwapped;
};
struct SurfaceStreamDescriptor {
SurfaceStreamHandle handle;
bool yflip;
};
// XXX - can be removed as soon as DeprecatedImageClientSingle is removed
struct YCbCrImage {
Shmem data;
uint64_t owner;
};
// XXX remove RGBImage (see bug 847914)
struct RGBImage {
Shmem data;
nsIntRect picture;
gfxImageFormat rgbFormat;
uint64_t owner;
};
struct MemoryImage {
uintptr_t data;
IntSize size;
uint32_t stride;
gfxImageFormat format;
};
/**
* Used for shmem-backed YCbCr and (flavors of) RGBA textures
*/
@ -150,11 +98,6 @@ union SurfaceDescriptor {
SurfaceStreamDescriptor;
SurfaceDescriptorMacIOSurface;
NewSurfaceDescriptorGralloc;
YCbCrImage; // XXX - deprecated
SurfaceDescriptorGralloc; // XXX - deprecated
Shmem; // XXX - deprecated
RGBImage; // XXX - deprecated
MemoryImage; // XXX - deprecated
null_t;
};

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

@ -379,18 +379,6 @@ ShadowLayerForwarder::DeallocGrallocBuffer(PGrallocBufferChild* aChild)
//-----------------------------------------------------------------------------
// Both processes
/*static*/ sp<GraphicBuffer>
GrallocBufferActor::GetFrom(const SurfaceDescriptorGralloc& aDescriptor)
{
GrallocBufferActor* gba = nullptr;
if (PGrallocBufferChild* child = aDescriptor.bufferChild()) {
gba = static_cast<GrallocBufferActor*>(child);
} else if (PGrallocBufferParent* parent = aDescriptor.bufferParent()) {
gba = static_cast<GrallocBufferActor*>(parent);
}
return gba->mGraphicBuffer;
}
android::GraphicBuffer*
GrallocBufferActor::GetGraphicBuffer()
{

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

@ -24,7 +24,6 @@ namespace mozilla {
namespace layers {
class MaybeMagicGrallocBufferHandle;
class SurfaceDescriptorGralloc;
class TextureHost;
/**
@ -77,9 +76,6 @@ public:
static PGrallocBufferChild*
Create();
static android::sp<GraphicBuffer>
GetFrom(const SurfaceDescriptorGralloc& aDescriptor);
// used only for hacky fix in gecko 23 for bug 862324
// see bug 865908 about fixing this.
void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;

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

@ -119,21 +119,10 @@ public:
NS_ABORT_IF_FALSE(!Finished(), "forgot BeginTransaction?");
mMutants.insert(aLayer);
}
void AddBufferToDestroy(gfxSharedImageSurface* aBuffer)
{
return AddBufferToDestroy(aBuffer->GetShmem());
}
void AddBufferToDestroy(const SurfaceDescriptor& aBuffer)
{
NS_ABORT_IF_FALSE(!Finished(), "forgot BeginTransaction?");
mDyingBuffers.AppendElement(aBuffer);
}
void End()
{
mCset.clear();
mPaints.clear();
mDyingBuffers.Clear();
mMutants.clear();
mOpen = false;
mSwapRequired = false;
@ -150,7 +139,6 @@ public:
EditVector mCset;
EditVector mPaints;
BufferArray mDyingBuffers;
ShadowableLayerSet mMutants;
nsIntRect mTargetBounds;
ScreenRotation mTargetRotation;
@ -247,12 +235,6 @@ ShadowLayerForwarder::CreatedRefLayer(ShadowableLayer* aRef)
CreatedLayer<OpCreateRefLayer>(mTxn, aRef);
}
void
ShadowLayerForwarder::DestroyedThebesBuffer(const SurfaceDescriptor& aBackBufferToDestroy)
{
mTxn->AddBufferToDestroy(aBackBufferToDestroy);
}
void
ShadowLayerForwarder::Mutated(ShadowableLayer* aMutant)
{
@ -315,11 +297,11 @@ ShadowLayerForwarder::CheckSurfaceDescriptor(const SurfaceDescriptor* aDescripto
return;
}
if (aDescriptor->type() == SurfaceDescriptor::TShmem) {
const mozilla::ipc::Shmem& shmem = aDescriptor->get_Shmem();
shmem.AssertInvariants();
if (aDescriptor->type() == SurfaceDescriptor::TSurfaceDescriptorShmem) {
const SurfaceDescriptorShmem& shmem = aDescriptor->get_SurfaceDescriptorShmem();
shmem.data().AssertInvariants();
MOZ_ASSERT(mShadowManager &&
mShadowManager->IsTrackingSharedMemory(shmem.mSegment));
mShadowManager->IsTrackingSharedMemory(shmem.data().mSegment));
}
}
#endif
@ -455,10 +437,6 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
MOZ_LAYERS_LOG(("[LayersForwarder] destroying buffers..."));
for (uint32_t i = 0; i < mTxn->mDyingBuffers.Length(); ++i) {
DestroySharedSurface(&mTxn->mDyingBuffers[i]);
}
MOZ_LAYERS_LOG(("[LayersForwarder] building transaction..."));
// We purposely add attribute-change ops to the final changeset

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

@ -198,16 +198,6 @@ public:
void CreatedCanvasLayer(ShadowableLayer* aCanvas);
void CreatedRefLayer(ShadowableLayer* aRef);
/**
* The specified layer is destroying its buffers.
* |aBackBufferToDestroy| is deallocated when this transaction is
* posted to the parent. During the parent-side transaction, the
* shadow is told to destroy its front buffer. This can happen when
* a new front/back buffer pair have been created because of a layer
* resize, e.g.
*/
virtual void DestroyedThebesBuffer(const SurfaceDescriptor& aBackBufferToDestroy) MOZ_OVERRIDE;
/**
* At least one attribute of |aMutant| has changed, and |aMutant|
* needs to sync to its shadow layer. This initial implementation

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

@ -36,12 +36,7 @@ public:
virtual void DeallocateSharedData(ISurfaceAllocator* allocator) MOZ_OVERRIDE
{
// We just need to wrap the actor in a SurfaceDescriptor because that's what
// ISurfaceAllocator uses as input, we don't care about the other parameters.
SurfaceDescriptor sd = SurfaceDescriptorGralloc(nullptr, mGrallocActor,
IntSize(0, 0),
false, false);
allocator->DestroySharedSurface(&sd);
allocator->DeallocGrallocBuffer(mGrallocActor);
mGrallocActor = nullptr;
}
@ -85,16 +80,8 @@ GrallocTextureClientOGL::~GrallocTextureClientOGL()
{
MOZ_COUNT_DTOR(GrallocTextureClientOGL);
if (ShouldDeallocateInDestructor()) {
// If the buffer has never been shared we must deallocate it or it would
// leak.
// We just need to wrap the actor in a SurfaceDescriptor because that's what
// ISurfaceAllocator uses as input, we don't care about the other parameters.
SurfaceDescriptor sd = SurfaceDescriptorGralloc(nullptr, mGrallocActor,
IntSize(0, 0),
false, false);
ISurfaceAllocator* allocator = GetAllocator();
allocator->DestroySharedSurface(&sd);
allocator->DeallocGrallocBuffer(mGrallocActor);
}
}

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

@ -25,6 +25,7 @@
#include "VideoUtils.h"
#ifdef MOZ_WIDGET_GONK
#include "GrallocImages.h"
#include "mozilla/layers/GrallocTextureClient.h"
#endif
#endif
@ -1112,10 +1113,10 @@ void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk(
#ifdef MOZ_WIDGET_GONK
if (format == ImageFormat::GRALLOC_PLANAR_YCBCR) {
layers::GrallocImage *nativeImage = static_cast<layers::GrallocImage*>(img);
layers::SurfaceDescriptor handle = nativeImage->GetSurfaceDescriptor();
layers::SurfaceDescriptorGralloc grallocHandle = handle.get_SurfaceDescriptorGralloc();
layers::GrallocTextureClientOGL* client =
static_cast<layers::GrallocTextureClientOGL*>(nativeImage->GetTextureClient(nullptr));
android::sp<android::GraphicBuffer> graphicBuffer = layers::GrallocBufferActor::GetFrom(grallocHandle);
android::sp<android::GraphicBuffer> graphicBuffer = client->GetGraphicBuffer();
void *basePtr;
graphicBuffer->lock(android::GraphicBuffer::USAGE_SW_READ_MASK, &basePtr);
conduit->SendVideoFrame(static_cast<unsigned char*>(basePtr),