gfx/layers/ipc/LayerTransactionChild.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * vim: sw=2 ts=8 et :
michael@0 3 */
michael@0 4 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 7
michael@0 8 #include "LayerTransactionChild.h"
michael@0 9 #include "mozilla/layers/CompositableClient.h" // for CompositableChild
michael@0 10 #include "mozilla/layers/LayersSurfaces.h" // for PGrallocBufferChild
michael@0 11 #include "mozilla/layers/PCompositableChild.h" // for PCompositableChild
michael@0 12 #include "mozilla/layers/PLayerChild.h" // for PLayerChild
michael@0 13 #include "mozilla/mozalloc.h" // for operator delete, etc
michael@0 14 #include "nsDebug.h" // for NS_RUNTIMEABORT, etc
michael@0 15 #include "nsTArray.h" // for nsTArray
michael@0 16 #include "mozilla/layers/TextureClient.h"
michael@0 17
michael@0 18 namespace mozilla {
michael@0 19 namespace layers {
michael@0 20
michael@0 21 class PGrallocBufferChild;
michael@0 22
michael@0 23 void
michael@0 24 LayerTransactionChild::Destroy()
michael@0 25 {
michael@0 26 NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(),
michael@0 27 "layers should have been cleaned up by now");
michael@0 28 PLayerTransactionChild::Send__delete__(this);
michael@0 29 // WARNING: |this| has gone to the great heap in the sky
michael@0 30 }
michael@0 31
michael@0 32 PGrallocBufferChild*
michael@0 33 LayerTransactionChild::AllocPGrallocBufferChild(const IntSize&,
michael@0 34 const uint32_t&,
michael@0 35 const uint32_t&,
michael@0 36 MaybeMagicGrallocBufferHandle*)
michael@0 37 {
michael@0 38 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
michael@0 39 return GrallocBufferActor::Create();
michael@0 40 #else
michael@0 41 NS_RUNTIMEABORT("No gralloc buffers for you");
michael@0 42 return nullptr;
michael@0 43 #endif
michael@0 44 }
michael@0 45
michael@0 46 bool
michael@0 47 LayerTransactionChild::DeallocPGrallocBufferChild(PGrallocBufferChild* actor)
michael@0 48 {
michael@0 49 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
michael@0 50 delete actor;
michael@0 51 return true;
michael@0 52 #else
michael@0 53 NS_RUNTIMEABORT("Um, how did we get here?");
michael@0 54 return false;
michael@0 55 #endif
michael@0 56 }
michael@0 57
michael@0 58 PLayerChild*
michael@0 59 LayerTransactionChild::AllocPLayerChild()
michael@0 60 {
michael@0 61 // we always use the "power-user" ctor
michael@0 62 NS_RUNTIMEABORT("not reached");
michael@0 63 return nullptr;
michael@0 64 }
michael@0 65
michael@0 66 bool
michael@0 67 LayerTransactionChild::DeallocPLayerChild(PLayerChild* actor)
michael@0 68 {
michael@0 69 delete actor;
michael@0 70 return true;
michael@0 71 }
michael@0 72
michael@0 73 PCompositableChild*
michael@0 74 LayerTransactionChild::AllocPCompositableChild(const TextureInfo& aInfo)
michael@0 75 {
michael@0 76 return CompositableClient::CreateIPDLActor();
michael@0 77 }
michael@0 78
michael@0 79 bool
michael@0 80 LayerTransactionChild::DeallocPCompositableChild(PCompositableChild* actor)
michael@0 81 {
michael@0 82 return CompositableClient::DestroyIPDLActor(actor);
michael@0 83 }
michael@0 84
michael@0 85 void
michael@0 86 LayerTransactionChild::ActorDestroy(ActorDestroyReason why)
michael@0 87 {
michael@0 88 #ifdef MOZ_B2G
michael@0 89 // Due to poor lifetime management of gralloc (and possibly shmems) we will
michael@0 90 // crash at some point in the future when we get destroyed due to abnormal
michael@0 91 // shutdown. Its better just to crash here. On desktop though, we have a chance
michael@0 92 // of recovering.
michael@0 93 if (why == AbnormalShutdown) {
michael@0 94 NS_RUNTIMEABORT("ActorDestroy by IPC channel failure at LayerTransactionChild");
michael@0 95 }
michael@0 96 #endif
michael@0 97 }
michael@0 98
michael@0 99 PTextureChild*
michael@0 100 LayerTransactionChild::AllocPTextureChild(const SurfaceDescriptor&,
michael@0 101 const TextureFlags&)
michael@0 102 {
michael@0 103 return TextureClient::CreateIPDLActor();
michael@0 104 }
michael@0 105
michael@0 106 bool
michael@0 107 LayerTransactionChild::DeallocPTextureChild(PTextureChild* actor)
michael@0 108 {
michael@0 109 return TextureClient::DestroyIPDLActor(actor);
michael@0 110 }
michael@0 111
michael@0 112 } // namespace layers
michael@0 113 } // namespace mozilla

mercurial