Bumping manifests a=b2g-bump
[gecko.git] / gfx / layers / ipc / ShadowLayerParent.cpp
blob628bb09620cb2c98f07323cef4d437f1245ff113
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=8 et :
3 */
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"
19 namespace mozilla {
20 namespace layers {
22 ShadowLayerParent::ShadowLayerParent() : mLayer(nullptr)
26 ShadowLayerParent::~ShadowLayerParent()
30 void
31 ShadowLayerParent::Bind(Layer* layer)
33 mLayer = layer;
36 void
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.
43 if (mLayer) {
44 mLayer->Disconnect();
48 ContainerLayerComposite*
49 ShadowLayerParent::AsContainerLayerComposite() const
51 return mLayer && mLayer->GetType() == Layer::TYPE_CONTAINER
52 ? static_cast<ContainerLayerComposite*>(mLayer.get())
53 : nullptr;
56 CanvasLayerComposite*
57 ShadowLayerParent::AsCanvasLayerComposite() const
59 return mLayer && mLayer->GetType() == Layer::TYPE_CANVAS
60 ? static_cast<CanvasLayerComposite*>(mLayer.get())
61 : nullptr;
64 ColorLayerComposite*
65 ShadowLayerParent::AsColorLayerComposite() const
67 return mLayer && mLayer->GetType() == Layer::TYPE_COLOR
68 ? static_cast<ColorLayerComposite*>(mLayer.get())
69 : nullptr;
72 ImageLayerComposite*
73 ShadowLayerParent::AsImageLayerComposite() const
75 return mLayer && mLayer->GetType() == Layer::TYPE_IMAGE
76 ? static_cast<ImageLayerComposite*>(mLayer.get())
77 : nullptr;
80 RefLayerComposite*
81 ShadowLayerParent::AsRefLayerComposite() const
83 return mLayer && mLayer->GetType() == Layer::TYPE_REF
84 ? static_cast<RefLayerComposite*>(mLayer.get())
85 : nullptr;
88 ThebesLayerComposite*
89 ShadowLayerParent::AsThebesLayerComposite() const
91 return mLayer && mLayer->GetType() == Layer::TYPE_THEBES
92 ? static_cast<ThebesLayerComposite*>(mLayer.get())
93 : nullptr;
96 void
97 ShadowLayerParent::ActorDestroy(ActorDestroyReason why)
99 switch (why) {
100 case AncestorDeletion:
101 NS_RUNTIMEABORT("shadow layer deleted out of order!");
102 return; // unreached
104 case Deletion:
105 // See comment near Destroy() above.
106 if (mLayer) {
107 mLayer->Disconnect();
109 break;
111 case AbnormalShutdown:
112 if (mLayer) {
113 mLayer->Disconnect();
115 break;
117 case NormalShutdown:
118 // let IPDL-generated code automatically clean up Shmems and so
119 // forth; our channel is disconnected anyway
120 break;
122 case FailedConstructor:
123 NS_RUNTIMEABORT("FailedConstructor isn't possible in PLayerTransaction");
124 return; // unreached
127 mLayer = nullptr;
130 } // namespace layers
131 } // namespace mozilla