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()
{
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;
}

View File

@ -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:

View File

@ -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,6 +66,16 @@ CompositorParent::AnswerInit()
return true;
}
bool
CompositorParent::AnswerStop()
{
if (mLayerManager) {
delete mLayerManager;
mLayerManager = NULL;
}
return true;
}
void
CompositorParent::Composite()
{

View File

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

View File

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

View File

@ -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);

View File

@ -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;
}
}
}

View File

@ -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;