зеркало из https://github.com/mozilla/gecko-dev.git
More clean up. Shutdown down a window no longer crashes
This commit is contained in:
Родитель
c56a73d173
Коммит
c2da08e686
|
@ -59,9 +59,16 @@ CompositorChild::CompositorChild(Thread *aCompositorThread, LayerManager *aLayer
|
|||
|
||||
CompositorChild::~CompositorChild()
|
||||
{
|
||||
printf("del\n");
|
||||
MOZ_COUNT_DTOR(CompositorChild);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorChild::Destroy()
|
||||
{
|
||||
CallStop();
|
||||
}
|
||||
|
||||
CompositorChild*
|
||||
CompositorChild::CreateCompositor(LayerManager *aLayerManager)
|
||||
{
|
||||
|
@ -105,6 +112,7 @@ CompositorChild::AllocPLayers(const LayersBackend &backend, const WidgetDescript
|
|||
bool
|
||||
CompositorChild::DeallocPLayers(PLayersChild* actor)
|
||||
{
|
||||
printf("actor destroy\n");
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -56,10 +56,12 @@ class LayerManager;
|
|||
|
||||
class CompositorChild : public PCompositorChild
|
||||
{
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(CompositorChild)
|
||||
public:
|
||||
virtual ~CompositorChild();
|
||||
|
||||
void Destroy();
|
||||
|
||||
static CompositorChild* CreateCompositor(LayerManager *aLayerManager);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace mozilla {
|
|||
namespace layers {
|
||||
|
||||
CompositorParent::CompositorParent()
|
||||
: mLayerManager(NULL)
|
||||
{
|
||||
|
||||
MOZ_COUNT_CTOR(CompositorParent);
|
||||
|
@ -52,6 +53,7 @@ CompositorParent::CompositorParent()
|
|||
|
||||
CompositorParent::~CompositorParent()
|
||||
{
|
||||
printf("delete parent\n");
|
||||
delete mLayerManager;
|
||||
MOZ_COUNT_DTOR(CompositorParent);
|
||||
}
|
||||
|
@ -64,11 +66,21 @@ CompositorParent::AnswerInit()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorParent::AnswerStop()
|
||||
{
|
||||
if (mLayerManager) {
|
||||
delete mLayerManager;
|
||||
mLayerManager = NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::Composite()
|
||||
{
|
||||
CancelableTask *composeTask = NewRunnableMethod(this, &CompositorParent::Composite);
|
||||
MessageLoop::current()->PostTask(FROM_HERE, composeTask);
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE, composeTask, 100);
|
||||
|
||||
if (!mLayerManager)
|
||||
return;
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
virtual ~CompositorParent();
|
||||
|
||||
bool AnswerInit();
|
||||
bool AnswerStop();
|
||||
|
||||
virtual mozilla::layout::RenderFrameParent* GetRenderFrameParent() { return NULL; }
|
||||
virtual CompositorParent* GetCompositorParent() { return this; }
|
||||
|
|
|
@ -75,6 +75,8 @@ rpc protocol PCompositor
|
|||
parent:
|
||||
|
||||
rpc Init();
|
||||
rpc Stop();
|
||||
|
||||
async PLayers(LayersBackend backend, WidgetDescriptor widgetDescriptor);
|
||||
|
||||
child:
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace layers {
|
|||
void
|
||||
ShadowLayersChild::Destroy()
|
||||
{
|
||||
printf("Destroy shadow layers\n");
|
||||
NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(),
|
||||
"layers should have been cleaned up by now");
|
||||
PLayersChild::Send__delete__(this);
|
||||
|
|
|
@ -141,8 +141,13 @@ nsBaseWidget::~nsBaseWidget()
|
|||
static_cast<BasicLayerManager*>(mLayerManager.get())->ClearRetainerWidget();
|
||||
}
|
||||
|
||||
if (mCompositor) {
|
||||
mCompositor->Destroy();
|
||||
}
|
||||
|
||||
if (mLayerManager) {
|
||||
mLayerManager->Destroy();
|
||||
mLayerManager = NULL;
|
||||
}
|
||||
|
||||
#ifdef NOISY_WIDGET_LEAKS
|
||||
|
@ -846,14 +851,14 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
|
|||
Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
|
||||
if (useCompositor) {
|
||||
LayerManager* lm = CreateBasicLayerManager();
|
||||
CompositorChild *compositorChild = CompositorChild::CreateCompositor(lm);
|
||||
mCompositor = CompositorChild::CreateCompositor(lm);
|
||||
|
||||
if (compositorChild) {
|
||||
if (mCompositor) {
|
||||
// e10s uses the parameter to pass in the shadow manager from the TabChild
|
||||
// so we don't expect to see it there since this doesn't support e10s.
|
||||
NS_ASSERTION(aShadowManager == NULL, "Async Compositor not supported with e10s");
|
||||
WidgetDescriptor desc = ViewWidget((uintptr_t)dynamic_cast<nsIWidget*>(this));
|
||||
PLayersChild* shadowManager = compositorChild->SendPLayersConstructor(
|
||||
PLayersChild* shadowManager = mCompositor->SendPLayersConstructor(
|
||||
LayerManager::LAYERS_OPENGL,
|
||||
desc);
|
||||
|
||||
|
@ -861,14 +866,14 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
|
|||
ShadowLayerForwarder* lf = lm->AsShadowForwarder();
|
||||
if (!lf) {
|
||||
delete lm;
|
||||
delete compositorChild;
|
||||
mCompositor = NULL;
|
||||
}
|
||||
lf->SetShadowManager(shadowManager);
|
||||
|
||||
mLayerManager = lm;
|
||||
} else {
|
||||
NS_WARNING("fail to construct LayersChild");
|
||||
delete compositorChild;
|
||||
mCompositor = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,14 @@ class nsIContent;
|
|||
class nsAutoRollup;
|
||||
class gfxContext;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
class CompositorChild;
|
||||
}
|
||||
}
|
||||
|
||||
using mozilla::layers::CompositorChild;
|
||||
|
||||
/**
|
||||
* Common widget implementation used as base class for native
|
||||
* or crossplatform implementations of Widgets.
|
||||
|
@ -269,6 +277,7 @@ protected:
|
|||
nsDeviceContext* mContext;
|
||||
nsRefPtr<LayerManager> mLayerManager;
|
||||
nsRefPtr<LayerManager> mBasicLayerManager;
|
||||
nsRefPtr<CompositorChild> mCompositor;
|
||||
nscolor mBackground;
|
||||
nscolor mForeground;
|
||||
nsCursor mCursor;
|
||||
|
|
Загрузка…
Ссылка в новой задаче