зеркало из https://github.com/mozilla/gecko-dev.git
Bug 687372 - ImageLayerOGL should not destroy surface given as argument. r=cjones
--HG-- extra : rebase_source : 00d0c49f320c0969570917a321b8a95a3357a943
This commit is contained in:
Родитель
5cecc378f2
Коммит
12f1dcd5d4
|
@ -2359,9 +2359,7 @@ public:
|
|||
}
|
||||
virtual ~BasicShadowableImageLayer()
|
||||
{
|
||||
if (IsSurfaceDescriptorValid(mBackBuffer)) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBuffer);
|
||||
}
|
||||
DestroyBackBuffer();
|
||||
MOZ_COUNT_DTOR(BasicShadowableImageLayer);
|
||||
}
|
||||
|
||||
|
@ -2391,10 +2389,23 @@ public:
|
|||
|
||||
virtual void Disconnect()
|
||||
{
|
||||
mBackBufferY = mBackBufferU = mBackBufferV = nsnull;
|
||||
mBackBuffer = SurfaceDescriptor();
|
||||
BasicShadowableLayer::Disconnect();
|
||||
}
|
||||
|
||||
void DestroyBackBuffer()
|
||||
{
|
||||
if (IsSurfaceDescriptorValid(mBackBuffer)) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBuffer);
|
||||
}
|
||||
if (mBackBufferY) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBufferY);
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBufferU);
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBufferV);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
BasicShadowLayerManager* BasicManager()
|
||||
{
|
||||
|
@ -2427,50 +2438,21 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext)
|
|||
const PlanarYCbCrImage::Data *data = YCbCrImage->GetData();
|
||||
NS_ASSERTION(data, "Must be able to retrieve yuv data from image!");
|
||||
|
||||
if (mSize != data->mYSize || mCbCrSize != data->mCbCrSize) {
|
||||
|
||||
if (mBackBufferY) {
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBufferY);
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBufferU);
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(mBackBufferV);
|
||||
BasicManager()->DestroyedImageBuffer(BasicManager()->Hold(this));
|
||||
}
|
||||
if (mSize != data->mYSize || mCbCrSize != data->mCbCrSize || !mBackBufferY) {
|
||||
DestroyBackBuffer();
|
||||
mSize = data->mYSize;
|
||||
mCbCrSize = data->mCbCrSize;
|
||||
|
||||
nsRefPtr<gfxSharedImageSurface> tmpYSurface;
|
||||
nsRefPtr<gfxSharedImageSurface> tmpUSurface;
|
||||
nsRefPtr<gfxSharedImageSurface> tmpVSurface;
|
||||
|
||||
if (!BasicManager()->AllocDoubleBuffer(
|
||||
mSize,
|
||||
gfxASurface::CONTENT_ALPHA,
|
||||
getter_AddRefs(tmpYSurface), getter_AddRefs(mBackBufferY)))
|
||||
if (!BasicManager()->AllocBuffer(mSize, gfxASurface::CONTENT_ALPHA,
|
||||
getter_AddRefs(mBackBufferY)) ||
|
||||
!BasicManager()->AllocBuffer(mCbCrSize, gfxASurface::CONTENT_ALPHA,
|
||||
getter_AddRefs(mBackBufferU)) ||
|
||||
!BasicManager()->AllocBuffer(mCbCrSize, gfxASurface::CONTENT_ALPHA,
|
||||
getter_AddRefs(mBackBufferV))) {
|
||||
NS_RUNTIMEABORT("creating ImageLayer 'front buffer' failed!");
|
||||
|
||||
if (!BasicManager()->AllocDoubleBuffer(
|
||||
mCbCrSize,
|
||||
gfxASurface::CONTENT_ALPHA,
|
||||
getter_AddRefs(tmpUSurface), getter_AddRefs(mBackBufferU)))
|
||||
NS_RUNTIMEABORT("creating ImageLayer 'front buffer' failed!");
|
||||
|
||||
if (!BasicManager()->AllocDoubleBuffer(
|
||||
mCbCrSize,
|
||||
gfxASurface::CONTENT_ALPHA,
|
||||
getter_AddRefs(tmpVSurface), getter_AddRefs(mBackBufferV)))
|
||||
NS_RUNTIMEABORT("creating ImageLayer 'front buffer' failed!");
|
||||
|
||||
YUVImage yuv(tmpYSurface->GetShmem(),
|
||||
tmpUSurface->GetShmem(),
|
||||
tmpVSurface->GetShmem(),
|
||||
nsIntRect());
|
||||
|
||||
BasicManager()->CreatedImageBuffer(BasicManager()->Hold(this),
|
||||
nsIntSize(mSize.width, mSize.height),
|
||||
yuv);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < data->mYSize.height; i++) {
|
||||
memcpy(mBackBufferY->Data() + i * mBackBufferY->Stride(),
|
||||
data->mYChannel + i * data->mYStride,
|
||||
|
@ -2484,15 +2466,14 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext)
|
|||
data->mCrChannel + i * data->mCbCrStride,
|
||||
data->mCbCrSize.width);
|
||||
}
|
||||
|
||||
|
||||
YUVImage yuv(mBackBufferY->GetShmem(),
|
||||
mBackBufferU->GetShmem(),
|
||||
mBackBufferV->GetShmem(),
|
||||
data->GetPictureRect());
|
||||
|
||||
|
||||
BasicManager()->PaintedImage(BasicManager()->Hold(this),
|
||||
yuv);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2501,24 +2482,15 @@ BasicShadowableImageLayer::Paint(gfxContext* aContext)
|
|||
if (!pat || !HasShadow())
|
||||
return;
|
||||
|
||||
if (oldSize != mSize) {
|
||||
if (IsSurfaceDescriptorValid(mBackBuffer)) {
|
||||
BasicManager()->DestroyedImageBuffer(BasicManager()->Hold(this));
|
||||
BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&mBackBuffer);
|
||||
}
|
||||
if (oldSize != mSize || !IsSurfaceDescriptorValid(mBackBuffer)) {
|
||||
DestroyBackBuffer();
|
||||
|
||||
SurfaceDescriptor tmpFrontSurface;
|
||||
// XXX error handling?
|
||||
if (!BasicManager()->AllocDoubleBuffer(
|
||||
if (!BasicManager()->AllocBuffer(
|
||||
mSize,
|
||||
(GetContentFlags() & CONTENT_OPAQUE) ?
|
||||
gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA,
|
||||
&tmpFrontSurface, &mBackBuffer))
|
||||
&mBackBuffer))
|
||||
NS_RUNTIMEABORT("creating ImageLayer 'front buffer' failed!");
|
||||
|
||||
BasicManager()->CreatedImageBuffer(BasicManager()->Hold(this),
|
||||
nsIntSize(mSize.width, mSize.height),
|
||||
tmpFrontSurface);
|
||||
}
|
||||
|
||||
nsRefPtr<gfxASurface> backSurface =
|
||||
|
@ -2741,7 +2713,7 @@ public:
|
|||
mOldValidRegion.SetEmpty();
|
||||
|
||||
if (IsSurfaceDescriptorValid(mFrontBufferDescriptor)) {
|
||||
BasicManager()->ShadowLayerManager::DestroySharedSurface(&mFrontBufferDescriptor, mAllocator);
|
||||
mAllocator->DestroySharedSurface(&mFrontBufferDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2902,18 +2874,17 @@ public:
|
|||
|
||||
virtual void Disconnect()
|
||||
{
|
||||
DestroyFrontBuffer();
|
||||
mFrontBuffer = SurfaceDescriptor();
|
||||
ShadowImageLayer::Disconnect();
|
||||
}
|
||||
|
||||
virtual PRBool Init(const SharedImage& front, const nsIntSize& size);
|
||||
|
||||
virtual void Swap(const SharedImage& aNewFront, SharedImage* aNewBack);
|
||||
virtual void Swap(const SharedImage& aNewFront,
|
||||
SharedImage* aNewBack);
|
||||
|
||||
virtual void DestroyFrontBuffer()
|
||||
{
|
||||
if (IsSurfaceDescriptorValid(mFrontBuffer)) {
|
||||
BasicManager()->ShadowLayerManager::DestroySharedSurface(&mFrontBuffer, mAllocator);
|
||||
if (mAllocator && IsSurfaceDescriptorValid(mFrontBuffer)) {
|
||||
mAllocator->DestroySharedSurface(&mFrontBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2929,19 +2900,24 @@ protected:
|
|||
gfxIntSize mSize;
|
||||
};
|
||||
|
||||
PRBool
|
||||
BasicShadowImageLayer::Init(const SharedImage& front,
|
||||
const nsIntSize& size)
|
||||
{
|
||||
mFrontBuffer = front.get_SurfaceDescriptor();
|
||||
mSize = gfxIntSize(size.width, size.height);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
BasicShadowImageLayer::Swap(const SharedImage& aNewFront, SharedImage* aNewBack)
|
||||
BasicShadowImageLayer::Swap(const SharedImage& aNewFront,
|
||||
SharedImage* aNewBack)
|
||||
{
|
||||
*aNewBack = mFrontBuffer;
|
||||
nsRefPtr<gfxASurface> surface =
|
||||
BasicManager()->OpenDescriptor(aNewFront);
|
||||
// Destroy mFrontBuffer if size different
|
||||
if (surface->GetSize() != mSize) {
|
||||
DestroyFrontBuffer();
|
||||
mSize = surface->GetSize();
|
||||
}
|
||||
|
||||
// If mFrontBuffer
|
||||
if (IsSurfaceDescriptorValid(mFrontBuffer)) {
|
||||
*aNewBack = mFrontBuffer;
|
||||
} else {
|
||||
*aNewBack = null_t();
|
||||
}
|
||||
mFrontBuffer = aNewFront.get_SurfaceDescriptor();
|
||||
}
|
||||
|
||||
|
@ -3017,7 +2993,7 @@ public:
|
|||
virtual void DestroyFrontBuffer()
|
||||
{
|
||||
if (IsSurfaceDescriptorValid(mFrontSurface)) {
|
||||
BasicManager()->ShadowLayerManager::DestroySharedSurface(&mFrontSurface, mAllocator);
|
||||
mAllocator->DestroySharedSurface(&mFrontSurface);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3324,14 +3300,17 @@ BasicShadowLayerManager::ForwardTransaction()
|
|||
|
||||
if (newBack.type() == SharedImage::TSurfaceDescriptor) {
|
||||
layer->SetBackBuffer(newBack.get_SurfaceDescriptor());
|
||||
} else {
|
||||
} else if (newBack.type() == SharedImage::TYUVImage) {
|
||||
const YUVImage& yuv = newBack.get_YUVImage();
|
||||
nsRefPtr<gfxSharedImageSurface> YSurf = gfxSharedImageSurface::Open(yuv.Ydata());
|
||||
nsRefPtr<gfxSharedImageSurface> USurf = gfxSharedImageSurface::Open(yuv.Udata());
|
||||
nsRefPtr<gfxSharedImageSurface> VSurf = gfxSharedImageSurface::Open(yuv.Vdata());
|
||||
layer->SetBackBufferYUVImage(YSurf, USurf, VSurf);
|
||||
} else {
|
||||
layer->SetBackBuffer(SurfaceDescriptor());
|
||||
layer->SetBackBufferYUVImage(nsnull, nsnull, nsnull);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -610,40 +610,19 @@ ShadowImageLayerD3D9::ShadowImageLayerD3D9(LayerManagerD3D9* aManager)
|
|||
ShadowImageLayerD3D9::~ShadowImageLayerD3D9()
|
||||
{}
|
||||
|
||||
PRBool
|
||||
ShadowImageLayerD3D9::Init(const SharedImage& aFront,
|
||||
const nsIntSize& aSize)
|
||||
void
|
||||
ShadowImageLayerD3D9::Swap(const SharedImage& aNewFront,
|
||||
SharedImage* aNewBack)
|
||||
{
|
||||
if (aFront.type() == SharedImage::TSurfaceDescriptor) {
|
||||
SurfaceDescriptor desc = aFront.get_SurfaceDescriptor();
|
||||
nsRefPtr<gfxASurface> surf =
|
||||
ShadowLayerForwarder::OpenDescriptor(desc);
|
||||
|
||||
if (aNewFront.type() == SharedImage::TSurfaceDescriptor) {
|
||||
if (!mBuffer) {
|
||||
mBuffer = new ShadowBufferD3D9(this);
|
||||
}
|
||||
return !!mBuffer;
|
||||
} else {
|
||||
if (!mYCbCrImage) {
|
||||
mYCbCrImage = new PlanarYCbCrImageD3D9();
|
||||
}
|
||||
return !!mYCbCrImage;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShadowImageLayerD3D9::Swap(const SharedImage& aNewFront, SharedImage* aNewBack)
|
||||
{
|
||||
|
||||
if (aNewFront.type() == SharedImage::TSurfaceDescriptor) {
|
||||
nsRefPtr<gfxASurface> surf =
|
||||
nsRefPtr<gfxASurface> surf =
|
||||
ShadowLayerForwarder::OpenDescriptor(aNewFront.get_SurfaceDescriptor());
|
||||
|
||||
if (mBuffer) {
|
||||
mBuffer->Upload(surf, GetVisibleRegion().GetBounds());
|
||||
}
|
||||
} else {
|
||||
|
||||
mBuffer->Upload(surf, GetVisibleRegion().GetBounds());
|
||||
} else {
|
||||
const YUVImage& yuv = aNewFront.get_YUVImage();
|
||||
|
||||
nsRefPtr<gfxSharedImageSurface> surfY =
|
||||
|
@ -665,6 +644,10 @@ ShadowImageLayerD3D9::Swap(const SharedImage& aNewFront, SharedImage* aNewBack)
|
|||
data.mPicX = 0;
|
||||
data.mPicY = 0;
|
||||
|
||||
if (!mYCbCrImage) {
|
||||
mYCbCrImage = new PlanarYCbCrImageD3D9();
|
||||
}
|
||||
|
||||
mYCbCrImage->SetData(data);
|
||||
|
||||
}
|
||||
|
@ -672,12 +655,6 @@ ShadowImageLayerD3D9::Swap(const SharedImage& aNewFront, SharedImage* aNewBack)
|
|||
*aNewBack = aNewFront;
|
||||
}
|
||||
|
||||
void
|
||||
ShadowImageLayerD3D9::DestroyFrontBuffer()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void
|
||||
ShadowImageLayerD3D9::Disconnect()
|
||||
{
|
||||
|
|
|
@ -185,11 +185,8 @@ public:
|
|||
virtual ~ShadowImageLayerD3D9();
|
||||
|
||||
// ShadowImageLayer impl
|
||||
virtual PRBool Init(const SharedImage& aFront, const nsIntSize& aSize);
|
||||
|
||||
virtual void Swap(const SharedImage& aFront, SharedImage* aNewBack);
|
||||
|
||||
virtual void DestroyFrontBuffer();
|
||||
virtual void Swap(const SharedImage& aFront,
|
||||
SharedImage* aNewBack);
|
||||
|
||||
virtual void Disconnect();
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ struct YUVImage {
|
|||
union SharedImage {
|
||||
SurfaceDescriptor;
|
||||
YUVImage;
|
||||
null_t;
|
||||
};
|
||||
|
||||
struct ThebesBuffer {
|
||||
|
@ -122,13 +123,6 @@ struct OpCreateCanvasBuffer {
|
|||
};
|
||||
struct OpDestroyCanvasFrontBuffer { PLayer layer; };
|
||||
|
||||
struct OpCreateImageBuffer {
|
||||
PLayer layer;
|
||||
nsIntSize size;
|
||||
SharedImage initialFront;
|
||||
};
|
||||
struct OpDestroyImageFrontBuffer { PLayer layer; };
|
||||
|
||||
|
||||
// Change a layer's attributes
|
||||
struct CommonLayerAttributes {
|
||||
|
@ -205,10 +199,8 @@ union Edit {
|
|||
OpCreateCanvasLayer;
|
||||
OpCreateCanvasBuffer;
|
||||
OpCreateThebesBuffer;
|
||||
OpCreateImageBuffer;
|
||||
OpDestroyThebesFrontBuffer;
|
||||
OpDestroyCanvasFrontBuffer;
|
||||
OpDestroyImageFrontBuffer;
|
||||
|
||||
OpSetLayerAttributes;
|
||||
|
||||
|
|
|
@ -201,16 +201,6 @@ ShadowLayerForwarder::CreatedThebesBuffer(ShadowableLayer* aThebes,
|
|||
aFrontValidRegion));
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::CreatedImageBuffer(ShadowableLayer* aImage,
|
||||
nsIntSize aSize,
|
||||
const SharedImage& aTempFrontImage)
|
||||
{
|
||||
mTxn->AddEdit(OpCreateImageBuffer(NULL, Shadow(aImage),
|
||||
aSize,
|
||||
aTempFrontImage));
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::CreatedCanvasBuffer(ShadowableLayer* aCanvas,
|
||||
nsIntSize aSize,
|
||||
|
@ -231,12 +221,6 @@ ShadowLayerForwarder::DestroyedThebesBuffer(ShadowableLayer* aThebes,
|
|||
mTxn->AddBufferToDestroy(aBackBufferToDestroy);
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::DestroyedImageBuffer(ShadowableLayer* aImage)
|
||||
{
|
||||
mTxn->AddEdit(OpDestroyImageFrontBuffer(NULL, Shadow(aImage)));
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::DestroyedCanvasBuffer(ShadowableLayer* aCanvas)
|
||||
{
|
||||
|
@ -544,7 +528,9 @@ ShadowLayerForwarder::DestroySharedSurface(SurfaceDescriptor* aSurface)
|
|||
if (PlatformDestroySharedSurface(aSurface)) {
|
||||
return;
|
||||
}
|
||||
DestroySharedShmemSurface(aSurface, mShadowManager);
|
||||
if (aSurface->type() == SurfaceDescriptor::TShmem) {
|
||||
DestroySharedShmemSurface(aSurface, mShadowManager);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -570,7 +556,9 @@ ShadowLayerManager::DestroySharedSurface(SurfaceDescriptor* aSurface,
|
|||
if (PlatformDestroySharedSurface(aSurface)) {
|
||||
return;
|
||||
}
|
||||
DestroySharedShmemSurface(aSurface, aDeallocator);
|
||||
if (aSurface->type() == SurfaceDescriptor::TShmem) {
|
||||
DestroySharedShmemSurface(aSurface, aDeallocator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -160,12 +160,9 @@ public:
|
|||
const nsIntRect& aBufferRect,
|
||||
const SurfaceDescriptor& aInitialFrontBuffer);
|
||||
/**
|
||||
* For the next two methods, |aSize| is the size of
|
||||
* For the next method, |aSize| is the size of
|
||||
* |aInitialFrontSurface|.
|
||||
*/
|
||||
void CreatedImageBuffer(ShadowableLayer* aImage,
|
||||
nsIntSize aSize,
|
||||
const SharedImage& aInitialFrontImage);
|
||||
void CreatedCanvasBuffer(ShadowableLayer* aCanvas,
|
||||
nsIntSize aSize,
|
||||
const SurfaceDescriptor& aInitialFrontSurface,
|
||||
|
@ -181,7 +178,6 @@ public:
|
|||
*/
|
||||
void DestroyedThebesBuffer(ShadowableLayer* aThebes,
|
||||
const SurfaceDescriptor& aBackBufferToDestroy);
|
||||
void DestroyedImageBuffer(ShadowableLayer* aImage);
|
||||
void DestroyedCanvasBuffer(ShadowableLayer* aCanvas);
|
||||
|
||||
|
||||
|
@ -432,6 +428,17 @@ protected:
|
|||
PLayerChild* mShadow;
|
||||
};
|
||||
|
||||
/**
|
||||
* SurfaceDeallocator interface
|
||||
*/
|
||||
class ISurfaceDeAllocator
|
||||
{
|
||||
public:
|
||||
virtual void DestroySharedSurface(gfxSharedImageSurface* aSurface) = 0;
|
||||
virtual void DestroySharedSurface(SurfaceDescriptor* aSurface) = 0;
|
||||
protected:
|
||||
~ISurfaceDeAllocator() {};
|
||||
};
|
||||
|
||||
/**
|
||||
* A ShadowLayer is the representation of a child-context's Layer in a
|
||||
|
@ -447,14 +454,18 @@ public:
|
|||
virtual ~ShadowLayer() {}
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* Set deallocator for data recieved from IPC protocol
|
||||
* We should be able to set allocator right before swap call
|
||||
* that is why allowed multiple call with the same Allocator
|
||||
*/
|
||||
void SetAllocator(PLayersParent* aAllocator)
|
||||
virtual void SetAllocator(ISurfaceDeAllocator* aAllocator)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!mAllocator, "Stomping allocator?");
|
||||
NS_ASSERTION(!mAllocator || mAllocator == aAllocator, "Stomping allocator?");
|
||||
mAllocator = aAllocator;
|
||||
}
|
||||
|
||||
virtual void DestroyFrontBuffer() { };
|
||||
|
||||
/**
|
||||
* The following methods are
|
||||
*
|
||||
|
@ -491,7 +502,7 @@ protected:
|
|||
, mUseShadowClipRect(PR_FALSE)
|
||||
{}
|
||||
|
||||
PLayersParent* mAllocator;
|
||||
ISurfaceDeAllocator* mAllocator;
|
||||
nsIntRegion mShadowVisibleRegion;
|
||||
gfx3DMatrix mShadowTransform;
|
||||
nsIntRect mShadowClipRect;
|
||||
|
@ -617,28 +628,12 @@ class ShadowImageLayer : public ShadowLayer,
|
|||
public ImageLayer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
*
|
||||
* Initialize this with a (temporary) front surface with the given
|
||||
* size. This is expected to be followed with a Swap() in the same
|
||||
* transaction to bring in real pixels. Init() may only be called
|
||||
* once.
|
||||
*/
|
||||
virtual PRBool Init(const SharedImage& front, const nsIntSize& aSize) = 0;
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* @see ShadowCanvasLayer::Swap
|
||||
*/
|
||||
virtual void Swap(const SharedImage& aFront, SharedImage* aNewBack) = 0;
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
*
|
||||
* Destroy the current front buffer.
|
||||
*/
|
||||
virtual void DestroyFrontBuffer() = 0;
|
||||
virtual void Swap(const SharedImage& aFront,
|
||||
SharedImage* aNewBack) = 0;
|
||||
|
||||
virtual ShadowLayer* AsShadowLayer() { return this; }
|
||||
|
||||
|
|
|
@ -184,7 +184,6 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
|||
|
||||
nsRefPtr<ShadowImageLayer> layer =
|
||||
layer_manager()->CreateShadowImageLayer();
|
||||
layer->SetAllocator(this);
|
||||
AsShadowLayer(edit.get_OpCreateImageLayer())->Bind(layer);
|
||||
break;
|
||||
}
|
||||
|
@ -226,17 +225,6 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
|||
|
||||
break;
|
||||
}
|
||||
case Edit::TOpCreateImageBuffer: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] CreateImageBuffer"));
|
||||
|
||||
const OpCreateImageBuffer ocb = edit.get_OpCreateImageBuffer();
|
||||
ShadowImageLayer* image = static_cast<ShadowImageLayer*>(
|
||||
AsShadowLayer(ocb)->AsLayer());
|
||||
|
||||
image->Init(ocb.initialFront(), ocb.size());
|
||||
|
||||
break;
|
||||
}
|
||||
case Edit::TOpDestroyThebesFrontBuffer: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] DestroyThebesFrontBuffer"));
|
||||
|
||||
|
@ -261,19 +249,6 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
|||
|
||||
break;
|
||||
}
|
||||
case Edit::TOpDestroyImageFrontBuffer: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] DestroyImageFrontBuffer"));
|
||||
|
||||
const OpDestroyImageFrontBuffer& odfb =
|
||||
edit.get_OpDestroyImageFrontBuffer();
|
||||
ShadowImageLayer* image = static_cast<ShadowImageLayer*>(
|
||||
AsShadowLayer(odfb)->AsLayer());
|
||||
|
||||
image->DestroyFrontBuffer();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Attributes
|
||||
case Edit::TOpSetLayerAttributes: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] SetLayerAttributes"));
|
||||
|
@ -431,13 +406,9 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
|||
ShadowImageLayer* image =
|
||||
static_cast<ShadowImageLayer*>(shadow->AsLayer());
|
||||
|
||||
SharedImage newFront = op.newFrontBuffer();
|
||||
image->SetAllocator(this);
|
||||
SharedImage newBack;
|
||||
image->Swap(op.newFrontBuffer(), &newBack);
|
||||
if (newFront == newBack) {
|
||||
newFront = SharedImage();
|
||||
}
|
||||
|
||||
replyv.push_back(OpImageSwap(shadow, NULL,
|
||||
newBack));
|
||||
|
||||
|
@ -485,5 +456,17 @@ ShadowLayersParent::Frame()
|
|||
return static_cast<RenderFrameParent*>(Manager());
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayersParent::DestroySharedSurface(gfxSharedImageSurface* aSurface)
|
||||
{
|
||||
layer_manager()->DestroySharedSurface(aSurface, this);
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayersParent::DestroySharedSurface(SurfaceDescriptor* aSurface)
|
||||
{
|
||||
layer_manager()->DestroySharedSurface(aSurface, this);
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#define mozilla_layers_ShadowLayersParent_h
|
||||
|
||||
#include "mozilla/layers/PLayersParent.h"
|
||||
#include "ShadowLayers.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -54,7 +55,8 @@ namespace layers {
|
|||
class Layer;
|
||||
class ShadowLayerManager;
|
||||
|
||||
class ShadowLayersParent : public PLayersParent
|
||||
class ShadowLayersParent : public PLayersParent,
|
||||
public ISurfaceDeAllocator
|
||||
{
|
||||
typedef mozilla::layout::RenderFrameParent RenderFrameParent;
|
||||
typedef InfallibleTArray<Edit> EditArray;
|
||||
|
@ -70,6 +72,9 @@ public:
|
|||
|
||||
ContainerLayer* GetRoot() const { return mRoot; }
|
||||
|
||||
virtual void DestroySharedSurface(gfxSharedImageSurface* aSurface);
|
||||
virtual void DestroySharedSurface(SurfaceDescriptor* aSurface);
|
||||
|
||||
protected:
|
||||
NS_OVERRIDE virtual bool RecvUpdate(const EditArray& cset,
|
||||
EditReplyArray* reply);
|
||||
|
|
|
@ -332,7 +332,7 @@ ShadowCanvasLayerOGL::DestroyFrontBuffer()
|
|||
{
|
||||
mTexImage = nsnull;
|
||||
if (IsSurfaceDescriptorValid(mDeadweight)) {
|
||||
mOGLManager->DestroySharedSurface(&mDeadweight, mAllocator);
|
||||
mAllocator->DestroySharedSurface(&mDeadweight);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -822,37 +822,35 @@ ShadowImageLayerOGL::ShadowImageLayerOGL(LayerManagerOGL* aManager)
|
|||
, LayerOGL(aManager)
|
||||
{
|
||||
mImplData = static_cast<LayerOGL*>(this);
|
||||
}
|
||||
}
|
||||
|
||||
ShadowImageLayerOGL::~ShadowImageLayerOGL()
|
||||
{}
|
||||
|
||||
PRBool
|
||||
ShadowImageLayerOGL::Init(const SharedImage& aFront,
|
||||
const nsIntSize& aSize)
|
||||
ShadowImageLayerOGL::Init(const SharedImage& aFront)
|
||||
{
|
||||
if (aFront.type() == SharedImage::TSurfaceDescriptor) {
|
||||
SurfaceDescriptor desc = aFront.get_SurfaceDescriptor();
|
||||
nsRefPtr<gfxASurface> surf =
|
||||
nsRefPtr<gfxASurface> surf =
|
||||
ShadowLayerForwarder::OpenDescriptor(desc);
|
||||
gfxSize sz = surf->GetSize();
|
||||
mTexImage = gl()->CreateTextureImage(nsIntSize(sz.width, sz.height),
|
||||
mSize = surf->GetSize();
|
||||
mTexImage = gl()->CreateTextureImage(nsIntSize(mSize.width, mSize.height),
|
||||
surf->GetContentType(),
|
||||
LOCAL_GL_CLAMP_TO_EDGE);
|
||||
mOGLManager->DestroySharedSurface(&desc, mAllocator);
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
YUVImage yuv = aFront.get_YUVImage();
|
||||
|
||||
|
||||
nsRefPtr<gfxSharedImageSurface> surfY =
|
||||
gfxSharedImageSurface::Open(yuv.Ydata());
|
||||
nsRefPtr<gfxSharedImageSurface> surfU =
|
||||
gfxSharedImageSurface::Open(yuv.Udata());
|
||||
nsRefPtr<gfxSharedImageSurface> surfV =
|
||||
gfxSharedImageSurface::Open(yuv.Vdata());
|
||||
|
||||
mSize = gfxIntSize(surfY->GetSize().width, surfY->GetSize().height);
|
||||
gfxIntSize CbCrSize = gfxIntSize(surfU->GetSize().width, surfU->GetSize().height);
|
||||
|
||||
mSize = surfY->GetSize();
|
||||
mCbCrSize = surfU->GetSize();
|
||||
|
||||
if (!mYUVTexture[0].IsAllocated()) {
|
||||
mYUVTexture[0].Allocate(mOGLManager->glForResources());
|
||||
|
@ -867,40 +865,45 @@ ShadowImageLayerOGL::Init(const SharedImage& aFront,
|
|||
|
||||
gl()->MakeCurrent();
|
||||
InitTexture(gl(), mYUVTexture[0].GetTextureID(), LOCAL_GL_LUMINANCE, mSize);
|
||||
InitTexture(gl(), mYUVTexture[1].GetTextureID(), LOCAL_GL_LUMINANCE, CbCrSize);
|
||||
InitTexture(gl(), mYUVTexture[2].GetTextureID(), LOCAL_GL_LUMINANCE, CbCrSize);
|
||||
|
||||
mOGLManager->DestroySharedSurface(surfY, mAllocator);
|
||||
mOGLManager->DestroySharedSurface(surfU, mAllocator);
|
||||
mOGLManager->DestroySharedSurface(surfV, mAllocator);
|
||||
InitTexture(gl(), mYUVTexture[1].GetTextureID(), LOCAL_GL_LUMINANCE, mCbCrSize);
|
||||
InitTexture(gl(), mYUVTexture[2].GetTextureID(), LOCAL_GL_LUMINANCE, mCbCrSize);
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
ShadowImageLayerOGL::Swap(const SharedImage& aNewFront, SharedImage* aNewBack)
|
||||
ShadowImageLayerOGL::Swap(const SharedImage& aNewFront,
|
||||
SharedImage* aNewBack)
|
||||
{
|
||||
if (!mDestroyed) {
|
||||
if (aNewFront.type() == SharedImage::TSurfaceDescriptor) {
|
||||
nsRefPtr<gfxASurface> surf =
|
||||
nsRefPtr<gfxASurface> surf =
|
||||
ShadowLayerForwarder::OpenDescriptor(aNewFront.get_SurfaceDescriptor());
|
||||
gfxIntSize size = surf->GetSize();
|
||||
if (mSize != size || !mTexImage) {
|
||||
Init(aNewFront);
|
||||
}
|
||||
// XXX this is always just ridiculously slow
|
||||
gfxSize sz = surf->GetSize();
|
||||
nsIntRegion updateRegion(nsIntRect(0, 0, sz.width, sz.height));
|
||||
nsIntRegion updateRegion(nsIntRect(0, 0, size.width, size.height));
|
||||
mTexImage->DirectUpdate(surf, updateRegion);
|
||||
} else {
|
||||
const YUVImage& yuv = aNewFront.get_YUVImage();
|
||||
|
||||
|
||||
nsRefPtr<gfxSharedImageSurface> surfY =
|
||||
gfxSharedImageSurface::Open(yuv.Ydata());
|
||||
nsRefPtr<gfxSharedImageSurface> surfU =
|
||||
gfxSharedImageSurface::Open(yuv.Udata());
|
||||
nsRefPtr<gfxSharedImageSurface> surfV =
|
||||
gfxSharedImageSurface::Open(yuv.Vdata());
|
||||
|
||||
mPictureRect = yuv.picture();
|
||||
mSize = surfY->GetSize();
|
||||
|
||||
|
||||
gfxIntSize size = surfY->GetSize();
|
||||
gfxIntSize CbCrSize = surfU->GetSize();
|
||||
if (size != mSize || mCbCrSize != CbCrSize || !mYUVTexture[0].IsAllocated()) {
|
||||
Init(aNewFront);
|
||||
}
|
||||
|
||||
PlanarYCbCrImage::Data data;
|
||||
data.mYChannel = surfY->Data();
|
||||
data.mYStride = surfY->Stride();
|
||||
|
@ -917,12 +920,6 @@ ShadowImageLayerOGL::Swap(const SharedImage& aNewFront, SharedImage* aNewBack)
|
|||
*aNewBack = aNewFront;
|
||||
}
|
||||
|
||||
void
|
||||
ShadowImageLayerOGL::DestroyFrontBuffer()
|
||||
{
|
||||
mTexImage = nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
ShadowImageLayerOGL::Disconnect()
|
||||
{
|
||||
|
|
|
@ -253,11 +253,8 @@ public:
|
|||
virtual ~ShadowImageLayerOGL();
|
||||
|
||||
// ShadowImageLayer impl
|
||||
virtual PRBool Init(const SharedImage& aFront, const nsIntSize& aSize);
|
||||
|
||||
virtual void Swap(const SharedImage& aFront, SharedImage* aNewBack);
|
||||
|
||||
virtual void DestroyFrontBuffer();
|
||||
virtual void Swap(const SharedImage& aFront,
|
||||
SharedImage* aNewBack);
|
||||
|
||||
virtual void Disconnect();
|
||||
|
||||
|
@ -270,9 +267,12 @@ public:
|
|||
const nsIntPoint& aOffset);
|
||||
|
||||
private:
|
||||
PRBool Init(const SharedImage& aFront);
|
||||
|
||||
nsRefPtr<TextureImage> mTexImage;
|
||||
GLTexture mYUVTexture[3];
|
||||
gfxIntSize mSize;
|
||||
gfxIntSize mCbCrSize;
|
||||
nsIntRect mPictureRect;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче