2014-03-21 15:20:25 -07:00
|
|
|
/* vim: set ts=2 sw=2 et tw=80: */
|
2012-07-13 12:38:09 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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/. */
|
|
|
|
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "ImageBridgeParent.h"
|
|
|
|
#include <stdint.h> // for uint64_t, uint32_t
|
|
|
|
#include "CompositableHost.h" // for CompositableParent, Create
|
|
|
|
#include "base/message_loop.h" // for MessageLoop
|
|
|
|
#include "base/process.h" // for ProcessHandle
|
|
|
|
#include "base/process_util.h" // for OpenProcessHandle
|
|
|
|
#include "base/task.h" // for CancelableTask, DeleteTask, etc
|
|
|
|
#include "base/tracked.h" // for FROM_HERE
|
2014-04-30 18:52:00 -07:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2013-09-27 18:42:08 -07:00
|
|
|
#include "mozilla/ipc/MessageChannel.h" // for MessageChannel, etc
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/ipc/ProtocolUtils.h"
|
|
|
|
#include "mozilla/ipc/Transport.h" // for Transport
|
|
|
|
#include "mozilla/layers/CompositableTransactionParent.h"
|
|
|
|
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
|
2013-04-27 23:46:30 -07:00
|
|
|
#include "mozilla/layers/LayerManagerComposite.h"
|
2013-09-06 08:41:00 -07:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for EditReply
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/layers/LayersSurfaces.h" // for PGrallocBufferParent
|
|
|
|
#include "mozilla/layers/PCompositableParent.h"
|
|
|
|
#include "mozilla/layers/PImageBridgeParent.h"
|
2013-10-01 20:05:35 -07:00
|
|
|
#include "mozilla/layers/Compositor.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/mozalloc.h" // for operator new, etc
|
2014-05-05 18:56:40 -07:00
|
|
|
#include "mozilla/unused.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
|
|
#include "nsDebug.h" // for NS_RUNTIMEABORT, etc
|
|
|
|
#include "nsISupportsImpl.h" // for ImageBridgeParent::Release, etc
|
|
|
|
#include "nsTArray.h" // for nsTArray, nsTArray_Impl
|
|
|
|
#include "nsTArrayForwardDeclare.h" // for InfallibleTArray
|
|
|
|
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
|
2013-12-11 17:44:44 -08:00
|
|
|
#include "mozilla/layers/TextureHost.h"
|
2014-03-21 15:20:25 -07:00
|
|
|
#include "nsThreadUtils.h"
|
2012-08-29 05:24:48 -07:00
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2014-05-22 03:11:45 -07:00
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2014-05-24 09:14:45 -07:00
|
|
|
std::map<base::ProcessId, ImageBridgeParent*> ImageBridgeParent::sImageBridges;
|
|
|
|
|
|
|
|
ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
|
|
|
|
Transport* aTransport,
|
|
|
|
ProcessId aChildProcessId)
|
2013-02-19 11:27:49 -08:00
|
|
|
: mMessageLoop(aLoop)
|
|
|
|
, mTransport(aTransport)
|
2014-05-24 09:14:45 -07:00
|
|
|
, mChildProcessId(aChildProcessId)
|
2012-07-13 12:38:09 -07:00
|
|
|
{
|
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
|
|
|
// creates the map only if it has not been created already, so it is safe
|
|
|
|
// with several bridges
|
|
|
|
CompositableMap::Create();
|
2014-05-24 09:14:45 -07:00
|
|
|
sImageBridges[aChildProcessId] = this;
|
2012-07-13 12:38:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ImageBridgeParent::~ImageBridgeParent()
|
|
|
|
{
|
2013-02-19 11:27:49 -08:00
|
|
|
if (mTransport) {
|
|
|
|
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
|
|
|
|
new DeleteTask<Transport>(mTransport));
|
|
|
|
}
|
2014-05-24 09:14:45 -07:00
|
|
|
sImageBridges.erase(mChildProcessId);
|
2013-02-19 11:27:49 -08:00
|
|
|
}
|
|
|
|
|
2014-03-07 13:34:04 -08:00
|
|
|
LayersBackend
|
|
|
|
ImageBridgeParent::GetCompositorBackendType() const
|
|
|
|
{
|
|
|
|
return Compositor::GetBackend();
|
|
|
|
}
|
|
|
|
|
2013-02-19 11:27:49 -08:00
|
|
|
void
|
|
|
|
ImageBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
MessageLoop::current()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(this, &ImageBridgeParent::DeferredDestroy));
|
2012-07-13 12:38:09 -07:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
ImageBridgeParent::RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply)
|
|
|
|
{
|
2013-10-01 20:05:35 -07:00
|
|
|
// If we don't actually have a compositor, then don't bother
|
|
|
|
// creating any textures.
|
2014-01-23 10:26:41 -08:00
|
|
|
if (Compositor::GetBackend() == LayersBackend::LAYERS_NONE) {
|
2013-10-01 20:05:35 -07:00
|
|
|
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
|
|
|
EditReplyVector replyv;
|
|
|
|
for (EditArray::index_type i = 0; i < aEdits.Length(); ++i) {
|
2014-03-10 15:12:49 -07:00
|
|
|
if (!ReceiveCompositableUpdate(aEdits[i], replyv)) {
|
|
|
|
return false;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
aReply->SetCapacity(replyv.size());
|
|
|
|
if (replyv.size() > 0) {
|
|
|
|
aReply->AppendElements(&replyv.front(), replyv.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure that any pending operations involving back and front
|
|
|
|
// buffers have completed, so that neither process stomps on the
|
|
|
|
// other's buffer contents.
|
2013-04-25 15:25:33 -07:00
|
|
|
LayerManagerComposite::PlatformSyncBeforeReplyUpdate();
|
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 true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeParent::RecvUpdateNoSwap(const EditArray& aEdits)
|
|
|
|
{
|
|
|
|
InfallibleTArray<EditReply> noReplies;
|
|
|
|
bool success = RecvUpdate(aEdits, &noReplies);
|
|
|
|
NS_ABORT_IF_FALSE(noReplies.Length() == 0, "RecvUpdateNoSwap requires a sync Update to carry Edits");
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:24:48 -07:00
|
|
|
static void
|
|
|
|
ConnectImageBridgeInParentProcess(ImageBridgeParent* aBridge,
|
|
|
|
Transport* aTransport,
|
2014-04-17 04:53:36 -07:00
|
|
|
base::ProcessHandle aOtherProcess)
|
2012-08-29 05:24:48 -07:00
|
|
|
{
|
2013-09-27 18:42:08 -07:00
|
|
|
aBridge->Open(aTransport, aOtherProcess, XRE_GetIOMessageLoop(), ipc::ParentSide);
|
2012-08-29 05:24:48 -07:00
|
|
|
}
|
|
|
|
|
2013-09-25 21:19:09 -07:00
|
|
|
/*static*/ PImageBridgeParent*
|
2014-05-24 09:14:45 -07:00
|
|
|
ImageBridgeParent::Create(Transport* aTransport, ProcessId aChildProcessId)
|
2012-08-29 05:24:48 -07:00
|
|
|
{
|
2014-04-17 04:53:36 -07:00
|
|
|
base::ProcessHandle processHandle;
|
2014-05-24 09:14:45 -07:00
|
|
|
if (!base::OpenProcessHandle(aChildProcessId, &processHandle)) {
|
2013-09-25 21:19:09 -07:00
|
|
|
return nullptr;
|
2012-08-29 05:24:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageLoop* loop = CompositorParent::CompositorLoop();
|
2014-05-24 09:14:45 -07:00
|
|
|
nsRefPtr<ImageBridgeParent> bridge = new ImageBridgeParent(loop, aTransport, aChildProcessId);
|
2013-02-19 11:27:49 -08:00
|
|
|
bridge->mSelfRef = bridge;
|
2012-08-29 05:24:48 -07:00
|
|
|
loop->PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(ConnectImageBridgeInParentProcess,
|
2013-02-19 11:27:49 -08:00
|
|
|
bridge.get(), aTransport, processHandle));
|
2013-09-25 21:19:09 -07:00
|
|
|
return bridge.get();
|
2012-08-29 05:24:48 -07:00
|
|
|
}
|
|
|
|
|
2014-05-07 02:06:19 -07:00
|
|
|
bool ImageBridgeParent::RecvWillStop()
|
2012-07-13 12:38:09 -07:00
|
|
|
{
|
2013-12-11 17:44:49 -08:00
|
|
|
// If there is any texture still alive we have to force it to deallocate the
|
|
|
|
// device data (GL textures, etc.) now because shortly after SenStop() returns
|
|
|
|
// on the child side the widget will be destroyed along with it's associated
|
|
|
|
// GL context.
|
|
|
|
InfallibleTArray<PTextureParent*> textures;
|
|
|
|
ManagedPTextureParent(textures);
|
|
|
|
for (unsigned int i = 0; i < textures.Length(); ++i) {
|
|
|
|
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(textures[i]);
|
|
|
|
tex->DeallocateDeviceData();
|
|
|
|
}
|
2012-07-13 12:38:09 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-07 02:06:19 -07:00
|
|
|
bool ImageBridgeParent::RecvStop()
|
|
|
|
{
|
|
|
|
// Nothing to do. This message just serves as synchronization between the
|
|
|
|
// child and parent threads during shutdown.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint64_t GenImageContainerID() {
|
|
|
|
static uint64_t sNextImageID = 1;
|
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
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
++sNextImageID;
|
|
|
|
return sNextImageID;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
PCompositableParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
ImageBridgeParent::AllocPCompositableParent(const TextureInfo& aInfo,
|
|
|
|
uint64_t* aID)
|
2012-07-13 12:38:09 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t id = GenImageContainerID();
|
2012-07-13 12:38:09 -07:00
|
|
|
*aID = id;
|
2014-04-25 08:15:58 -07:00
|
|
|
return CompositableHost::CreateIPDLActor(this, aInfo, id);
|
2012-07-13 12:38:09 -07:00
|
|
|
}
|
|
|
|
|
2013-07-08 08:48:39 -07:00
|
|
|
bool ImageBridgeParent::DeallocPCompositableParent(PCompositableParent* aActor)
|
2012-07-13 12:38:09 -07:00
|
|
|
{
|
2014-04-25 08:15:58 -07:00
|
|
|
return CompositableHost::DestroyIPDLActor(aActor);
|
2012-07-13 12:38:09 -07:00
|
|
|
}
|
|
|
|
|
2013-12-11 17:44:44 -08:00
|
|
|
PTextureParent*
|
2014-01-21 14:06:18 -08:00
|
|
|
ImageBridgeParent::AllocPTextureParent(const SurfaceDescriptor& aSharedData,
|
|
|
|
const TextureFlags& aFlags)
|
2013-12-11 17:44:44 -08:00
|
|
|
{
|
2014-01-21 14:06:18 -08:00
|
|
|
return TextureHost::CreateIPDLActor(this, aSharedData, aFlags);
|
2013-12-11 17:44:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeParent::DeallocPTextureParent(PTextureParent* actor)
|
|
|
|
{
|
|
|
|
return TextureHost::DestroyIPDLActor(actor);
|
|
|
|
}
|
|
|
|
|
2014-05-05 18:56:40 -07:00
|
|
|
void
|
|
|
|
ImageBridgeParent::SendFenceHandle(AsyncTransactionTracker* aTracker,
|
|
|
|
PTextureParent* aTexture,
|
|
|
|
const FenceHandle& aFence)
|
|
|
|
{
|
|
|
|
HoldUntilComplete(aTracker);
|
2014-05-14 15:40:15 -07:00
|
|
|
InfallibleTArray<AsyncParentMessageData> messages;
|
|
|
|
messages.AppendElement(OpDeliverFence(aTracker->GetId(),
|
2014-05-05 18:56:40 -07:00
|
|
|
aTexture, nullptr,
|
|
|
|
aFence));
|
2014-05-14 15:40:15 -07:00
|
|
|
mozilla::unused << SendParentAsyncMessage(messages);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ImageBridgeParent::SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage)
|
|
|
|
{
|
|
|
|
mozilla::unused << SendParentAsyncMessage(aMessage);
|
2014-05-05 18:56:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageBridgeParent::RecvChildAsyncMessages(const InfallibleTArray<AsyncChildMessageData>& aMessages)
|
|
|
|
{
|
|
|
|
for (AsyncChildMessageArray::index_type i = 0; i < aMessages.Length(); ++i) {
|
|
|
|
const AsyncChildMessageData& message = aMessages[i];
|
|
|
|
|
|
|
|
switch (message.type()) {
|
|
|
|
case AsyncChildMessageData::TOpReplyDeliverFence: {
|
|
|
|
const OpReplyDeliverFence& op = message.get_OpReplyDeliverFence();
|
|
|
|
TransactionCompleteted(op.transactionId());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_ERROR("unknown AsyncChildMessageData type");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
MessageLoop * ImageBridgeParent::GetMessageLoop() {
|
|
|
|
return mMessageLoop;
|
|
|
|
}
|
|
|
|
|
2014-03-21 15:20:25 -07:00
|
|
|
class ReleaseRunnable : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ReleaseRunnable(ImageBridgeParent* aRef)
|
|
|
|
: mRef(aRef)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
mRef->Release();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ImageBridgeParent* mRef;
|
|
|
|
};
|
|
|
|
|
2013-02-19 11:27:49 -08:00
|
|
|
void
|
|
|
|
ImageBridgeParent::DeferredDestroy()
|
|
|
|
{
|
2014-03-21 15:20:25 -07:00
|
|
|
ImageBridgeParent* self;
|
|
|
|
mSelfRef.forget(&self);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRunnable> runnable = new ReleaseRunnable(self);
|
|
|
|
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(runnable)));
|
2013-02-19 11:27:49 -08:00
|
|
|
}
|
2012-07-13 12:38:09 -07:00
|
|
|
|
2014-05-24 09:14:45 -07:00
|
|
|
ImageBridgeParent*
|
|
|
|
ImageBridgeParent::GetInstance(ProcessId aId)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(sImageBridges.count(aId) == 1, "ImageBridgeParent for the process");
|
|
|
|
return sImageBridges[aId];
|
|
|
|
}
|
|
|
|
|
2013-06-03 03:14:37 -07:00
|
|
|
IToplevelProtocol*
|
|
|
|
ImageBridgeParent::CloneToplevel(const InfallibleTArray<ProtocolFdMapping>& aFds,
|
|
|
|
base::ProcessHandle aPeerProcess,
|
|
|
|
mozilla::ipc::ProtocolCloneContext* aCtx)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < aFds.Length(); i++) {
|
2013-10-17 20:42:59 -07:00
|
|
|
if (aFds[i].protocolId() == unsigned(GetProtocolId())) {
|
2013-06-03 03:14:37 -07:00
|
|
|
Transport* transport = OpenDescriptor(aFds[i].fd(),
|
|
|
|
Transport::MODE_SERVER);
|
|
|
|
PImageBridgeParent* bridge = Create(transport, base::GetProcId(aPeerProcess));
|
|
|
|
bridge->CloneManagees(this, aCtx);
|
|
|
|
bridge->IToplevelProtocol::SetTransport(transport);
|
|
|
|
return bridge;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-02-25 05:12:49 -08:00
|
|
|
bool ImageBridgeParent::IsSameProcess() const
|
|
|
|
{
|
|
|
|
return OtherProcess() == ipc::kInvalidProcessHandle;
|
|
|
|
}
|
|
|
|
|
2014-05-12 07:39:25 -07:00
|
|
|
void
|
|
|
|
ImageBridgeParent::ReplyRemoveTexture(const OpReplyRemoveTexture& aReply)
|
|
|
|
{
|
2014-05-14 15:40:15 -07:00
|
|
|
InfallibleTArray<AsyncParentMessageData> messages;
|
|
|
|
messages.AppendElement(aReply);
|
|
|
|
mozilla::unused << SendParentAsyncMessage(messages);
|
2014-05-12 07:39:25 -07:00
|
|
|
}
|
|
|
|
|
2014-05-24 09:14:45 -07:00
|
|
|
/*static*/ void
|
|
|
|
ImageBridgeParent::ReplyRemoveTexture(base::ProcessId aChildProcessId,
|
|
|
|
const OpReplyRemoveTexture& aReply)
|
|
|
|
{
|
|
|
|
ImageBridgeParent* imageBridge = ImageBridgeParent::GetInstance(aChildProcessId);
|
|
|
|
if (!imageBridge) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
imageBridge->ReplyRemoveTexture(aReply);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ImageBridgeParent::SendFenceHandleToTrackerIfPresent(uint64_t aDestHolderId,
|
|
|
|
uint64_t aTransactionId,
|
|
|
|
PTextureParent* aTexture)
|
|
|
|
{
|
|
|
|
RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
|
|
|
|
if (!texture) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FenceHandle fence = texture->GetAndResetReleaseFenceHandle();
|
|
|
|
if (!fence.IsValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<FenceDeliveryTracker> tracker = new FenceDeliveryTracker(fence);
|
|
|
|
HoldUntilComplete(tracker);
|
|
|
|
InfallibleTArray<AsyncParentMessageData> messages;
|
|
|
|
messages.AppendElement(OpDeliverFenceToTracker(tracker->GetId(),
|
|
|
|
aDestHolderId,
|
|
|
|
aTransactionId,
|
|
|
|
fence));
|
|
|
|
mozilla::unused << SendParentAsyncMessage(messages);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ImageBridgeParent::SendFenceHandleToTrackerIfPresent(base::ProcessId aChildProcessId,
|
|
|
|
uint64_t aDestHolderId,
|
|
|
|
uint64_t aTransactionId,
|
|
|
|
PTextureParent* aTexture)
|
|
|
|
{
|
|
|
|
ImageBridgeParent* imageBridge = ImageBridgeParent::GetInstance(aChildProcessId);
|
|
|
|
if (!imageBridge) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
imageBridge->SendFenceHandleToTrackerIfPresent(aDestHolderId,
|
|
|
|
aTransactionId,
|
|
|
|
aTexture);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-13 12:38:09 -07:00
|
|
|
} // layers
|
|
|
|
} // mozilla
|