michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=8 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "LayerTransactionChild.h" michael@0: #include "mozilla/layers/CompositableClient.h" // for CompositableChild michael@0: #include "mozilla/layers/LayersSurfaces.h" // for PGrallocBufferChild michael@0: #include "mozilla/layers/PCompositableChild.h" // for PCompositableChild michael@0: #include "mozilla/layers/PLayerChild.h" // for PLayerChild michael@0: #include "mozilla/mozalloc.h" // for operator delete, etc michael@0: #include "nsDebug.h" // for NS_RUNTIMEABORT, etc michael@0: #include "nsTArray.h" // for nsTArray michael@0: #include "mozilla/layers/TextureClient.h" michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class PGrallocBufferChild; michael@0: michael@0: void michael@0: LayerTransactionChild::Destroy() michael@0: { michael@0: NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(), michael@0: "layers should have been cleaned up by now"); michael@0: PLayerTransactionChild::Send__delete__(this); michael@0: // WARNING: |this| has gone to the great heap in the sky michael@0: } michael@0: michael@0: PGrallocBufferChild* michael@0: LayerTransactionChild::AllocPGrallocBufferChild(const IntSize&, michael@0: const uint32_t&, michael@0: const uint32_t&, michael@0: MaybeMagicGrallocBufferHandle*) michael@0: { michael@0: #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC michael@0: return GrallocBufferActor::Create(); michael@0: #else michael@0: NS_RUNTIMEABORT("No gralloc buffers for you"); michael@0: return nullptr; michael@0: #endif michael@0: } michael@0: michael@0: bool michael@0: LayerTransactionChild::DeallocPGrallocBufferChild(PGrallocBufferChild* actor) michael@0: { michael@0: #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC michael@0: delete actor; michael@0: return true; michael@0: #else michael@0: NS_RUNTIMEABORT("Um, how did we get here?"); michael@0: return false; michael@0: #endif michael@0: } michael@0: michael@0: PLayerChild* michael@0: LayerTransactionChild::AllocPLayerChild() michael@0: { michael@0: // we always use the "power-user" ctor michael@0: NS_RUNTIMEABORT("not reached"); michael@0: return nullptr; michael@0: } michael@0: michael@0: bool michael@0: LayerTransactionChild::DeallocPLayerChild(PLayerChild* actor) michael@0: { michael@0: delete actor; michael@0: return true; michael@0: } michael@0: michael@0: PCompositableChild* michael@0: LayerTransactionChild::AllocPCompositableChild(const TextureInfo& aInfo) michael@0: { michael@0: return CompositableClient::CreateIPDLActor(); michael@0: } michael@0: michael@0: bool michael@0: LayerTransactionChild::DeallocPCompositableChild(PCompositableChild* actor) michael@0: { michael@0: return CompositableClient::DestroyIPDLActor(actor); michael@0: } michael@0: michael@0: void michael@0: LayerTransactionChild::ActorDestroy(ActorDestroyReason why) michael@0: { michael@0: #ifdef MOZ_B2G michael@0: // Due to poor lifetime management of gralloc (and possibly shmems) we will michael@0: // crash at some point in the future when we get destroyed due to abnormal michael@0: // shutdown. Its better just to crash here. On desktop though, we have a chance michael@0: // of recovering. michael@0: if (why == AbnormalShutdown) { michael@0: NS_RUNTIMEABORT("ActorDestroy by IPC channel failure at LayerTransactionChild"); michael@0: } michael@0: #endif michael@0: } michael@0: michael@0: PTextureChild* michael@0: LayerTransactionChild::AllocPTextureChild(const SurfaceDescriptor&, michael@0: const TextureFlags&) michael@0: { michael@0: return TextureClient::CreateIPDLActor(); michael@0: } michael@0: michael@0: bool michael@0: LayerTransactionChild::DeallocPTextureChild(PTextureChild* actor) michael@0: { michael@0: return TextureClient::DestroyIPDLActor(actor); michael@0: } michael@0: michael@0: } // namespace layers michael@0: } // namespace mozilla