1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "ShadowLayerParent.h"
9 #include "Layers.h" // for Layer, ContainerLayer
10 #include "nsDebug.h" // for NS_RUNTIMEABORT
11 #include "nsISupportsImpl.h" // for Layer::AddRef, etc
13 #include "mozilla/layers/ThebesLayerComposite.h"
14 #include "mozilla/layers/CanvasLayerComposite.h"
15 #include "mozilla/layers/ColorLayerComposite.h"
16 #include "mozilla/layers/ImageLayerComposite.h"
17 #include "mozilla/layers/ContainerLayerComposite.h"
22 ShadowLayerParent::ShadowLayerParent() : mLayer(nullptr)
26 ShadowLayerParent::~ShadowLayerParent()
31 ShadowLayerParent::Bind(Layer
* layer
)
37 ShadowLayerParent::Destroy()
39 // It's possible for Destroy() to come in just after this has been
40 // created, but just before the transaction in which Bind() would
41 // have been called. In that case, we'll ignore shadow-layers
42 // transactions from there on and never get a layer here.
48 ContainerLayerComposite
*
49 ShadowLayerParent::AsContainerLayerComposite() const
51 return mLayer
&& mLayer
->GetType() == Layer::TYPE_CONTAINER
52 ? static_cast<ContainerLayerComposite
*>(mLayer
.get())
57 ShadowLayerParent::AsCanvasLayerComposite() const
59 return mLayer
&& mLayer
->GetType() == Layer::TYPE_CANVAS
60 ? static_cast<CanvasLayerComposite
*>(mLayer
.get())
65 ShadowLayerParent::AsColorLayerComposite() const
67 return mLayer
&& mLayer
->GetType() == Layer::TYPE_COLOR
68 ? static_cast<ColorLayerComposite
*>(mLayer
.get())
73 ShadowLayerParent::AsImageLayerComposite() const
75 return mLayer
&& mLayer
->GetType() == Layer::TYPE_IMAGE
76 ? static_cast<ImageLayerComposite
*>(mLayer
.get())
81 ShadowLayerParent::AsRefLayerComposite() const
83 return mLayer
&& mLayer
->GetType() == Layer::TYPE_REF
84 ? static_cast<RefLayerComposite
*>(mLayer
.get())
89 ShadowLayerParent::AsThebesLayerComposite() const
91 return mLayer
&& mLayer
->GetType() == Layer::TYPE_THEBES
92 ? static_cast<ThebesLayerComposite
*>(mLayer
.get())
97 ShadowLayerParent::ActorDestroy(ActorDestroyReason why
)
100 case AncestorDeletion
:
101 NS_RUNTIMEABORT("shadow layer deleted out of order!");
105 // See comment near Destroy() above.
107 mLayer
->Disconnect();
111 case AbnormalShutdown
:
113 mLayer
->Disconnect();
118 // let IPDL-generated code automatically clean up Shmems and so
119 // forth; our channel is disconnected anyway
122 case FailedConstructor
:
123 NS_RUNTIMEABORT("FailedConstructor isn't possible in PLayerTransaction");
130 } // namespace layers
131 } // namespace mozilla