This commit is contained in:
Ali Juma 2011-12-19 10:44:18 -05:00
commit b0a7f53f0f
8 changed files with 46 additions and 6 deletions

View File

@ -59,9 +59,16 @@ CompositorChild::CompositorChild(Thread *aCompositorThread, LayerManager *aLayer
CompositorChild::~CompositorChild() CompositorChild::~CompositorChild()
{ {
printf("del\n");
MOZ_COUNT_DTOR(CompositorChild); MOZ_COUNT_DTOR(CompositorChild);
} }
void
CompositorChild::Destroy()
{
CallStop();
}
CompositorChild* CompositorChild*
CompositorChild::CreateCompositor(LayerManager *aLayerManager) CompositorChild::CreateCompositor(LayerManager *aLayerManager)
{ {
@ -105,6 +112,7 @@ CompositorChild::AllocPLayers(const LayersBackend &backend, const WidgetDescript
bool bool
CompositorChild::DeallocPLayers(PLayersChild* actor) CompositorChild::DeallocPLayers(PLayersChild* actor)
{ {
printf("actor destroy\n");
delete actor; delete actor;
return true; return true;
} }

View File

@ -56,10 +56,12 @@ class LayerManager;
class CompositorChild : public PCompositorChild class CompositorChild : public PCompositorChild
{ {
NS_INLINE_DECL_REFCOUNTING(CompositorChild)
public: public:
virtual ~CompositorChild(); virtual ~CompositorChild();
void Destroy();
static CompositorChild* CreateCompositor(LayerManager *aLayerManager); static CompositorChild* CreateCompositor(LayerManager *aLayerManager);
protected: protected:

View File

@ -45,6 +45,7 @@ namespace mozilla {
namespace layers { namespace layers {
CompositorParent::CompositorParent() CompositorParent::CompositorParent()
: mLayerManager(NULL)
{ {
MOZ_COUNT_CTOR(CompositorParent); MOZ_COUNT_CTOR(CompositorParent);
@ -52,6 +53,7 @@ CompositorParent::CompositorParent()
CompositorParent::~CompositorParent() CompositorParent::~CompositorParent()
{ {
printf("delete parent\n");
delete mLayerManager; delete mLayerManager;
MOZ_COUNT_DTOR(CompositorParent); MOZ_COUNT_DTOR(CompositorParent);
} }
@ -64,6 +66,16 @@ CompositorParent::AnswerInit()
return true; return true;
} }
bool
CompositorParent::AnswerStop()
{
if (mLayerManager) {
delete mLayerManager;
mLayerManager = NULL;
}
return true;
}
void void
CompositorParent::Composite() CompositorParent::Composite()
{ {

View File

@ -58,6 +58,7 @@ public:
virtual ~CompositorParent(); virtual ~CompositorParent();
bool AnswerInit(); bool AnswerInit();
bool AnswerStop();
virtual mozilla::layout::RenderFrameParent* GetRenderFrameParent() { return NULL; } virtual mozilla::layout::RenderFrameParent* GetRenderFrameParent() { return NULL; }
virtual CompositorParent* GetCompositorParent() { return this; } virtual CompositorParent* GetCompositorParent() { return this; }

View File

@ -75,6 +75,8 @@ rpc protocol PCompositor
parent: parent:
rpc Init(); rpc Init();
rpc Stop();
async PLayers(LayersBackend backend, WidgetDescriptor widgetDescriptor); async PLayers(LayersBackend backend, WidgetDescriptor widgetDescriptor);
child: child:

View File

@ -47,6 +47,7 @@ namespace layers {
void void
ShadowLayersChild::Destroy() ShadowLayersChild::Destroy()
{ {
printf("Destroy shadow layers\n");
NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(), NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(),
"layers should have been cleaned up by now"); "layers should have been cleaned up by now");
PLayersChild::Send__delete__(this); PLayersChild::Send__delete__(this);

View File

@ -141,8 +141,13 @@ nsBaseWidget::~nsBaseWidget()
static_cast<BasicLayerManager*>(mLayerManager.get())->ClearRetainerWidget(); static_cast<BasicLayerManager*>(mLayerManager.get())->ClearRetainerWidget();
} }
if (mCompositor) {
mCompositor->Destroy();
}
if (mLayerManager) { if (mLayerManager) {
mLayerManager->Destroy(); mLayerManager->Destroy();
mLayerManager = NULL;
} }
#ifdef NOISY_WIDGET_LEAKS #ifdef NOISY_WIDGET_LEAKS
@ -846,14 +851,14 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
Preferences::GetBool("layers.offmainthreadcomposition.enabled", false); Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
if (useCompositor) { if (useCompositor) {
LayerManager* lm = CreateBasicLayerManager(); 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 // 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. // 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"); NS_ASSERTION(aShadowManager == NULL, "Async Compositor not supported with e10s");
WidgetDescriptor desc = ViewWidget((uintptr_t)dynamic_cast<nsIWidget*>(this)); WidgetDescriptor desc = ViewWidget((uintptr_t)dynamic_cast<nsIWidget*>(this));
PLayersChild* shadowManager = compositorChild->SendPLayersConstructor( PLayersChild* shadowManager = mCompositor->SendPLayersConstructor(
LayerManager::LAYERS_OPENGL, LayerManager::LAYERS_OPENGL,
desc); desc);
@ -861,14 +866,14 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
ShadowLayerForwarder* lf = lm->AsShadowForwarder(); ShadowLayerForwarder* lf = lm->AsShadowForwarder();
if (!lf) { if (!lf) {
delete lm; delete lm;
delete compositorChild; mCompositor = NULL;
} }
lf->SetShadowManager(shadowManager); lf->SetShadowManager(shadowManager);
mLayerManager = lm; mLayerManager = lm;
} else { } else {
NS_WARNING("fail to construct LayersChild"); NS_WARNING("fail to construct LayersChild");
delete compositorChild; mCompositor = NULL;
} }
} }
} }

View File

@ -51,6 +51,14 @@ class nsIContent;
class nsAutoRollup; class nsAutoRollup;
class gfxContext; class gfxContext;
namespace mozilla {
namespace layers {
class CompositorChild;
}
}
using mozilla::layers::CompositorChild;
/** /**
* Common widget implementation used as base class for native * Common widget implementation used as base class for native
* or crossplatform implementations of Widgets. * or crossplatform implementations of Widgets.
@ -269,6 +277,7 @@ protected:
nsDeviceContext* mContext; nsDeviceContext* mContext;
nsRefPtr<LayerManager> mLayerManager; nsRefPtr<LayerManager> mLayerManager;
nsRefPtr<LayerManager> mBasicLayerManager; nsRefPtr<LayerManager> mBasicLayerManager;
nsRefPtr<CompositorChild> mCompositor;
nscolor mBackground; nscolor mBackground;
nscolor mForeground; nscolor mForeground;
nsCursor mCursor; nsCursor mCursor;