1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/ipc/LayerTransactionChild.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,113 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=8 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#include "LayerTransactionChild.h" 1.12 +#include "mozilla/layers/CompositableClient.h" // for CompositableChild 1.13 +#include "mozilla/layers/LayersSurfaces.h" // for PGrallocBufferChild 1.14 +#include "mozilla/layers/PCompositableChild.h" // for PCompositableChild 1.15 +#include "mozilla/layers/PLayerChild.h" // for PLayerChild 1.16 +#include "mozilla/mozalloc.h" // for operator delete, etc 1.17 +#include "nsDebug.h" // for NS_RUNTIMEABORT, etc 1.18 +#include "nsTArray.h" // for nsTArray 1.19 +#include "mozilla/layers/TextureClient.h" 1.20 + 1.21 +namespace mozilla { 1.22 +namespace layers { 1.23 + 1.24 +class PGrallocBufferChild; 1.25 + 1.26 +void 1.27 +LayerTransactionChild::Destroy() 1.28 +{ 1.29 + NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(), 1.30 + "layers should have been cleaned up by now"); 1.31 + PLayerTransactionChild::Send__delete__(this); 1.32 + // WARNING: |this| has gone to the great heap in the sky 1.33 +} 1.34 + 1.35 +PGrallocBufferChild* 1.36 +LayerTransactionChild::AllocPGrallocBufferChild(const IntSize&, 1.37 + const uint32_t&, 1.38 + const uint32_t&, 1.39 + MaybeMagicGrallocBufferHandle*) 1.40 +{ 1.41 +#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC 1.42 + return GrallocBufferActor::Create(); 1.43 +#else 1.44 + NS_RUNTIMEABORT("No gralloc buffers for you"); 1.45 + return nullptr; 1.46 +#endif 1.47 +} 1.48 + 1.49 +bool 1.50 +LayerTransactionChild::DeallocPGrallocBufferChild(PGrallocBufferChild* actor) 1.51 +{ 1.52 +#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC 1.53 + delete actor; 1.54 + return true; 1.55 +#else 1.56 + NS_RUNTIMEABORT("Um, how did we get here?"); 1.57 + return false; 1.58 +#endif 1.59 +} 1.60 + 1.61 +PLayerChild* 1.62 +LayerTransactionChild::AllocPLayerChild() 1.63 +{ 1.64 + // we always use the "power-user" ctor 1.65 + NS_RUNTIMEABORT("not reached"); 1.66 + return nullptr; 1.67 +} 1.68 + 1.69 +bool 1.70 +LayerTransactionChild::DeallocPLayerChild(PLayerChild* actor) 1.71 +{ 1.72 + delete actor; 1.73 + return true; 1.74 +} 1.75 + 1.76 +PCompositableChild* 1.77 +LayerTransactionChild::AllocPCompositableChild(const TextureInfo& aInfo) 1.78 +{ 1.79 + return CompositableClient::CreateIPDLActor(); 1.80 +} 1.81 + 1.82 +bool 1.83 +LayerTransactionChild::DeallocPCompositableChild(PCompositableChild* actor) 1.84 +{ 1.85 + return CompositableClient::DestroyIPDLActor(actor); 1.86 +} 1.87 + 1.88 +void 1.89 +LayerTransactionChild::ActorDestroy(ActorDestroyReason why) 1.90 +{ 1.91 +#ifdef MOZ_B2G 1.92 + // Due to poor lifetime management of gralloc (and possibly shmems) we will 1.93 + // crash at some point in the future when we get destroyed due to abnormal 1.94 + // shutdown. Its better just to crash here. On desktop though, we have a chance 1.95 + // of recovering. 1.96 + if (why == AbnormalShutdown) { 1.97 + NS_RUNTIMEABORT("ActorDestroy by IPC channel failure at LayerTransactionChild"); 1.98 + } 1.99 +#endif 1.100 +} 1.101 + 1.102 +PTextureChild* 1.103 +LayerTransactionChild::AllocPTextureChild(const SurfaceDescriptor&, 1.104 + const TextureFlags&) 1.105 +{ 1.106 + return TextureClient::CreateIPDLActor(); 1.107 +} 1.108 + 1.109 +bool 1.110 +LayerTransactionChild::DeallocPTextureChild(PTextureChild* actor) 1.111 +{ 1.112 + return TextureClient::DestroyIPDLActor(actor); 1.113 +} 1.114 + 1.115 +} // namespace layers 1.116 +} // namespace mozilla