2010-08-20 16:24:41 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-08-20 16:24:41 -07:00
|
|
|
|
2013-04-24 11:42:40 -07:00
|
|
|
#include "LayerTransactionChild.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/layers/CompositableClient.h" // for CompositableChild
|
|
|
|
#include "mozilla/layers/PCompositableChild.h" // for PCompositableChild
|
|
|
|
#include "mozilla/layers/PLayerChild.h" // for PLayerChild
|
2014-05-05 18:56:40 -07:00
|
|
|
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
|
|
|
#include "nsDebug.h" // for NS_RUNTIMEABORT, etc
|
|
|
|
#include "nsTArray.h" // for nsTArray
|
2013-12-11 17:44:44 -08:00
|
|
|
#include "mozilla/layers/TextureClient.h"
|
2010-08-20 16:24:41 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-08-11 16:17:23 -07:00
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
void
|
2013-04-24 11:42:40 -07:00
|
|
|
LayerTransactionChild::Destroy()
|
2010-08-20 16:24:41 -07:00
|
|
|
{
|
2014-05-07 06:23:14 -07:00
|
|
|
if (!IPCOpen() || mDestroyed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// mDestroyed is used to prevent calling Send__delete__() twice.
|
|
|
|
// When this function is called from CompositorChild::Destroy(),
|
|
|
|
// under Send__delete__() call, this function is called from
|
|
|
|
// ShadowLayerForwarder's destructor.
|
|
|
|
// When it happens, IPCOpen() is still true.
|
|
|
|
// See bug 1004191.
|
|
|
|
mDestroyed = true;
|
2010-08-20 16:24:41 -07:00
|
|
|
NS_ABORT_IF_FALSE(0 == ManagedPLayerChild().Length(),
|
|
|
|
"layers should have been cleaned up by now");
|
2013-04-24 11:42:40 -07:00
|
|
|
PLayerTransactionChild::Send__delete__(this);
|
2010-08-20 16:24:41 -07:00
|
|
|
}
|
|
|
|
|
2012-07-12 05:51:58 -07:00
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
PLayerChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
LayerTransactionChild::AllocPLayerChild()
|
2010-08-20 16:24:41 -07:00
|
|
|
{
|
|
|
|
// we always use the "power-user" ctor
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
return nullptr;
|
2010-08-20 16:24:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
LayerTransactionChild::DeallocPLayerChild(PLayerChild* actor)
|
2010-08-20 16:24:41 -07:00
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
PCompositableChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
LayerTransactionChild::AllocPCompositableChild(const TextureInfo& aInfo)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
2014-04-24 11:13:59 -07:00
|
|
|
return CompositableClient::CreateIPDLActor();
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
LayerTransactionChild::DeallocPCompositableChild(PCompositableChild* actor)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
2014-04-24 11:13:59 -07:00
|
|
|
return CompositableClient::DestroyIPDLActor(actor);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
2014-05-05 18:56:40 -07:00
|
|
|
bool
|
2014-06-08 06:18:53 -07:00
|
|
|
LayerTransactionChild::RecvParentAsyncMessages(const InfallibleTArray<AsyncParentMessageData>& aMessages)
|
2014-05-05 18:56:40 -07:00
|
|
|
{
|
2014-05-14 15:40:15 -07:00
|
|
|
for (AsyncParentMessageArray::index_type i = 0; i < aMessages.Length(); ++i) {
|
|
|
|
const AsyncParentMessageData& message = aMessages[i];
|
|
|
|
|
|
|
|
switch (message.type()) {
|
|
|
|
case AsyncParentMessageData::TOpDeliverFence: {
|
|
|
|
const OpDeliverFence& op = message.get_OpDeliverFence();
|
|
|
|
FenceHandle fence = op.fence();
|
|
|
|
PTextureChild* child = op.textureChild();
|
|
|
|
|
|
|
|
RefPtr<TextureClient> texture = TextureClient::AsTextureClient(child);
|
|
|
|
if (texture) {
|
|
|
|
texture->SetReleaseFenceHandle(fence);
|
|
|
|
}
|
|
|
|
if (mForwarder) {
|
|
|
|
mForwarder->HoldTransactionsToRespond(op.transactionId());
|
|
|
|
} else {
|
|
|
|
// Send back a response.
|
|
|
|
InfallibleTArray<AsyncChildMessageData> replies;
|
|
|
|
replies.AppendElement(OpReplyDeliverFence(op.transactionId()));
|
|
|
|
SendChildAsyncMessages(replies);
|
|
|
|
}
|
|
|
|
break;
|
2014-05-05 18:56:40 -07:00
|
|
|
}
|
2014-06-08 06:18:53 -07:00
|
|
|
case AsyncParentMessageData::TOpReplyDeliverFence: {
|
|
|
|
const OpReplyDeliverFence& op = message.get_OpReplyDeliverFence();
|
|
|
|
TransactionCompleteted(op.transactionId());
|
|
|
|
break;
|
|
|
|
}
|
2014-05-14 15:40:15 -07:00
|
|
|
default:
|
|
|
|
NS_ERROR("unknown AsyncParentMessageData type");
|
|
|
|
return false;
|
2014-05-05 18:56:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-08 06:18:53 -07:00
|
|
|
void
|
|
|
|
LayerTransactionChild::SendFenceHandle(AsyncTransactionTracker* aTracker,
|
|
|
|
PTextureChild* aTexture,
|
|
|
|
const FenceHandle& aFence)
|
|
|
|
{
|
|
|
|
HoldUntilComplete(aTracker);
|
|
|
|
InfallibleTArray<AsyncChildMessageData> messages;
|
|
|
|
messages.AppendElement(OpDeliverFenceFromChild(aTracker->GetId(),
|
|
|
|
nullptr, aTexture,
|
|
|
|
FenceHandleFromChild(aFence)));
|
|
|
|
SendChildAsyncMessages(messages);
|
|
|
|
}
|
|
|
|
|
2013-04-12 13:25:04 -07:00
|
|
|
void
|
2013-04-24 11:42:40 -07:00
|
|
|
LayerTransactionChild::ActorDestroy(ActorDestroyReason why)
|
2013-04-12 13:25:04 -07:00
|
|
|
{
|
2014-06-08 06:18:53 -07:00
|
|
|
DestroyAsyncTransactionTrackersHolder();
|
2013-10-10 09:44:03 -07:00
|
|
|
#ifdef MOZ_B2G
|
|
|
|
// Due to poor lifetime management of gralloc (and possibly shmems) we will
|
|
|
|
// crash at some point in the future when we get destroyed due to abnormal
|
|
|
|
// shutdown. Its better just to crash here. On desktop though, we have a chance
|
|
|
|
// of recovering.
|
2013-04-12 13:25:04 -07:00
|
|
|
if (why == AbnormalShutdown) {
|
2013-04-24 11:42:40 -07:00
|
|
|
NS_RUNTIMEABORT("ActorDestroy by IPC channel failure at LayerTransactionChild");
|
2013-04-12 13:25:04 -07:00
|
|
|
}
|
2013-10-10 09:44:03 -07:00
|
|
|
#endif
|
2013-04-12 13:25:04 -07:00
|
|
|
}
|
|
|
|
|
2013-12-11 17:44:44 -08:00
|
|
|
PTextureChild*
|
2014-01-21 14:06:18 -08:00
|
|
|
LayerTransactionChild::AllocPTextureChild(const SurfaceDescriptor&,
|
|
|
|
const TextureFlags&)
|
2013-12-11 17:44:44 -08:00
|
|
|
{
|
|
|
|
return TextureClient::CreateIPDLActor();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
LayerTransactionChild::DeallocPTextureChild(PTextureChild* actor)
|
|
|
|
{
|
|
|
|
return TextureClient::DestroyIPDLActor(actor);
|
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:41 -07:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|