2010-07-22 01:17:33 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-07-22 01:17:33 +04:00
|
|
|
|
|
|
|
#include "ShadowLayerParent.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "Layers.h" // for Layer, ContainerLayer
|
|
|
|
#include "nsDebug.h" // for NS_RUNTIMEABORT
|
|
|
|
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
|
2010-07-22 01:17:33 +04:00
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
#include "mozilla/layers/PaintedLayerComposite.h"
|
2014-02-20 20:40:55 +04:00
|
|
|
#include "mozilla/layers/CanvasLayerComposite.h"
|
|
|
|
#include "mozilla/layers/ColorLayerComposite.h"
|
|
|
|
#include "mozilla/layers/ImageLayerComposite.h"
|
|
|
|
#include "mozilla/layers/ContainerLayerComposite.h"
|
|
|
|
|
2010-07-22 01:17:33 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-07-20 12:48:55 +04:00
|
|
|
ShadowLayerParent::ShadowLayerParent() : mLayer(nullptr)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ShadowLayerParent::~ShadowLayerParent()
|
|
|
|
{
|
2015-07-06 06:02:26 +03:00
|
|
|
Disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowLayerParent::Disconnect()
|
|
|
|
{
|
|
|
|
if (mLayer) {
|
|
|
|
mLayer->Disconnect();
|
|
|
|
mLayer = nullptr;
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowLayerParent::Bind(Layer* layer)
|
|
|
|
{
|
2015-07-06 06:02:26 +03:00
|
|
|
if (mLayer != layer) {
|
|
|
|
Disconnect();
|
|
|
|
mLayer = layer;
|
|
|
|
}
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2011-01-06 07:54:47 +03:00
|
|
|
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.
|
2015-07-06 06:02:26 +03:00
|
|
|
Disconnect();
|
2011-01-06 07:54:47 +03:00
|
|
|
}
|
|
|
|
|
2014-02-20 20:40:55 +04:00
|
|
|
ContainerLayerComposite*
|
|
|
|
ShadowLayerParent::AsContainerLayerComposite() const
|
|
|
|
{
|
|
|
|
return mLayer && mLayer->GetType() == Layer::TYPE_CONTAINER
|
|
|
|
? static_cast<ContainerLayerComposite*>(mLayer.get())
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
CanvasLayerComposite*
|
|
|
|
ShadowLayerParent::AsCanvasLayerComposite() const
|
|
|
|
{
|
|
|
|
return mLayer && mLayer->GetType() == Layer::TYPE_CANVAS
|
|
|
|
? static_cast<CanvasLayerComposite*>(mLayer.get())
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ColorLayerComposite*
|
|
|
|
ShadowLayerParent::AsColorLayerComposite() const
|
|
|
|
{
|
|
|
|
return mLayer && mLayer->GetType() == Layer::TYPE_COLOR
|
|
|
|
? static_cast<ColorLayerComposite*>(mLayer.get())
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageLayerComposite*
|
|
|
|
ShadowLayerParent::AsImageLayerComposite() const
|
|
|
|
{
|
|
|
|
return mLayer && mLayer->GetType() == Layer::TYPE_IMAGE
|
|
|
|
? static_cast<ImageLayerComposite*>(mLayer.get())
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefLayerComposite*
|
|
|
|
ShadowLayerParent::AsRefLayerComposite() const
|
|
|
|
{
|
|
|
|
return mLayer && mLayer->GetType() == Layer::TYPE_REF
|
|
|
|
? static_cast<RefLayerComposite*>(mLayer.get())
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
PaintedLayerComposite*
|
|
|
|
ShadowLayerParent::AsPaintedLayerComposite() const
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
2014-09-26 21:07:06 +04:00
|
|
|
return mLayer && mLayer->GetType() == Layer::TYPE_PAINTED
|
2014-09-26 21:06:08 +04:00
|
|
|
? static_cast<PaintedLayerComposite*>(mLayer.get())
|
2014-02-20 20:40:55 +04:00
|
|
|
: nullptr;
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
void
|
|
|
|
ShadowLayerParent::ActorDestroy(ActorDestroyReason why)
|
2010-07-22 01:17:33 +04:00
|
|
|
{
|
2010-08-21 03:24:41 +04:00
|
|
|
switch (why) {
|
|
|
|
case AncestorDeletion:
|
|
|
|
NS_RUNTIMEABORT("shadow layer deleted out of order!");
|
|
|
|
return; // unreached
|
|
|
|
|
|
|
|
case Deletion:
|
2011-01-06 07:54:47 +03:00
|
|
|
// See comment near Destroy() above.
|
2015-07-06 06:02:26 +03:00
|
|
|
Disconnect();
|
2010-08-21 03:24:41 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AbnormalShutdown:
|
2015-07-06 06:02:26 +03:00
|
|
|
Disconnect();
|
2013-04-26 23:18:16 +04:00
|
|
|
break;
|
|
|
|
|
2010-08-21 03:24:41 +04:00
|
|
|
case NormalShutdown:
|
|
|
|
// let IPDL-generated code automatically clean up Shmems and so
|
|
|
|
// forth; our channel is disconnected anyway
|
|
|
|
break;
|
2011-03-21 19:00:00 +03:00
|
|
|
|
|
|
|
case FailedConstructor:
|
2013-04-24 22:42:40 +04:00
|
|
|
NS_RUNTIMEABORT("FailedConstructor isn't possible in PLayerTransaction");
|
2011-03-21 19:00:00 +03:00
|
|
|
return; // unreached
|
2010-08-21 03:24:41 +04:00
|
|
|
}
|
|
|
|
|
2013-07-20 12:48:55 +04:00
|
|
|
mLayer = nullptr;
|
2010-07-22 01:17:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|