Bug 623255: Ensure LayerOGL::Destroy is called for "orphaned" shadow OGL layers before the GLContext is deleted. r=vlad a=b

This commit is contained in:
Chris Jones 2011-01-05 22:54:47 -06:00
parent 49a79e3913
commit ff1aab8620
15 changed files with 87 additions and 5 deletions

View File

@ -1067,10 +1067,7 @@ nsFrameLoader::DestroyChild()
#ifdef MOZ_IPC
if (mRemoteBrowser) {
mRemoteBrowser->SetOwnerElement(nsnull);
// If this fails, it's most likely due to a content-process crash,
// and auto-cleanup will kick in. Otherwise, the child side will
// destroy itself and send back __delete__().
unused << mRemoteBrowser->SendDestroy();
mRemoteBrowser->Destroy();
mRemoteBrowser = nsnull;
}
#endif

View File

@ -110,6 +110,21 @@ TabParent::SetOwnerElement(nsIDOMElement* aElement)
}
}
void
TabParent::Destroy()
{
// If this fails, it's most likely due to a content-process crash,
// and auto-cleanup will kick in. Otherwise, the child side will
// destroy itself and send back __delete__().
unused << SendDestroy();
for (size_t i = 0; i < ManagedPRenderFrameParent().Length(); ++i) {
RenderFrameParent* rfp =
static_cast<RenderFrameParent*>(ManagedPRenderFrameParent()[i]);
rfp->Destroy();
}
}
void
TabParent::ActorDestroy(ActorDestroyReason why)
{

View File

@ -80,6 +80,8 @@ public:
mBrowserDOMWindow = aBrowserDOMWindow;
}
void Destroy();
virtual bool RecvMoveFocus(const bool& aForward);
virtual bool RecvEvent(const RemoteDOMEvent& aEvent);

View File

@ -61,6 +61,18 @@ ShadowLayerParent::Bind(Layer* layer)
mLayer = layer;
}
void
ShadowLayerParent::Destroy()
{
// It's possible for Destroy() to come in just after this has been
// created, but just before the transaction in which Bind() would
// have been called. In that case, we'll ignore shadow-layers
// transactions from there on and never get a layer here.
if (mLayer) {
mLayer->Disconnect();
}
}
ContainerLayer*
ShadowLayerParent::AsContainer() const
{
@ -76,7 +88,10 @@ ShadowLayerParent::ActorDestroy(ActorDestroyReason why)
return; // unreached
case Deletion:
mLayer->Disconnect();
// See comment near Destroy() above.
if (mLayer) {
mLayer->Disconnect();
}
break;
case AbnormalShutdown:

View File

@ -59,6 +59,7 @@ public:
virtual ~ShadowLayerParent();
void Bind(Layer* layer);
void Destroy();
Layer* AsLayer() const { return mLayer; }
ContainerLayer* AsContainer() const;

View File

@ -132,6 +132,16 @@ ShadowLayersParent::~ShadowLayersParent()
MOZ_COUNT_DTOR(ShadowLayersParent);
}
void
ShadowLayersParent::Destroy()
{
for (size_t i = 0; i < ManagedPLayerParent().Length(); ++i) {
ShadowLayerParent* slp =
static_cast<ShadowLayerParent*>(ManagedPLayerParent()[i]);
slp->Destroy();
}
}
bool
ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
InfallibleTArray<EditReply>* reply)

View File

@ -64,6 +64,8 @@ public:
ShadowLayersParent(ShadowLayerManager* aManager);
~ShadowLayersParent();
void Destroy();
ShadowLayerManager* layer_manager() const { return mLayerManager; }
ContainerLayer* GetRoot() const { return mRoot; }

View File

@ -301,6 +301,12 @@ ShadowCanvasLayerOGL::DestroyFrontBuffer()
}
}
void
ShadowCanvasLayerOGL::Disconnect()
{
Destroy();
}
void
ShadowCanvasLayerOGL::Destroy()
{

View File

@ -113,6 +113,8 @@ public:
virtual void DestroyFrontBuffer();
virtual void Disconnect();
// LayerOGL impl
void Destroy();
Layer* GetLayer();

View File

@ -751,6 +751,12 @@ ShadowImageLayerOGL::DestroyFrontBuffer()
}
}
void
ShadowImageLayerOGL::Disconnect()
{
Destroy();
}
void
ShadowImageLayerOGL::Destroy()
{

View File

@ -259,6 +259,8 @@ public:
virtual void DestroyFrontBuffer();
virtual void Disconnect();
// LayerOGL impl
virtual void Destroy();

View File

@ -709,6 +709,12 @@ ShadowThebesLayerOGL::DestroyFrontBuffer()
mBuffer = nsnull;
}
void
ShadowThebesLayerOGL::Disconnect()
{
Destroy();
}
void
ShadowThebesLayerOGL::Destroy()
{

View File

@ -105,6 +105,8 @@ public:
OptionalThebesBuffer* aReadOnlyFront, nsIntRegion* aFrontUpdatedRegion);
virtual void DestroyFrontBuffer();
virtual void Disconnect();
// LayerOGL impl
void Destroy();
Layer* GetLayer();

View File

@ -181,6 +181,20 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader)
RenderFrameParent::~RenderFrameParent()
{}
void
RenderFrameParent::Destroy()
{
size_t numChildren = ManagedPLayersParent().Length();
NS_ABORT_IF_FALSE(0 == numChildren || 1 == numChildren,
"render frame must only have 0 or 1 layer manager");
if (numChildren) {
ShadowLayersParent* layers =
static_cast<ShadowLayersParent*>(ManagedPLayersParent()[0]);
layers->Destroy();
}
}
void
RenderFrameParent::ShadowLayersUpdated()
{

View File

@ -68,6 +68,8 @@ public:
RenderFrameParent(nsFrameLoader* aFrameLoader);
virtual ~RenderFrameParent();
void Destroy();
void ShadowLayersUpdated();
already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,