Skip to content

Commit

Permalink
Added basic implementation of EmbedliteCompositorParent for process b…
Browse files Browse the repository at this point in the history
…ackend
  • Loading branch information
tmeshkova committed Jan 5, 2015
1 parent a890591 commit deb051e
Show file tree
Hide file tree
Showing 9 changed files with 338 additions and 12 deletions.
5 changes: 2 additions & 3 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessChild.cpp
Expand Up @@ -24,7 +24,6 @@
#include "nsIWindowWatcher.h"
#include "WindowCreator.h"
#include "nsIEmbedAppService.h"
#include "EmbedLiteAppService.h"
#include "EmbedLiteViewChildIface.h"
#include "EmbedLiteJSON.h"
#include "nsIComponentRegistrar.h" // for nsIComponentRegistrar
Expand Down Expand Up @@ -158,8 +157,8 @@ EmbedLiteAppProcessChild::AllocPEmbedLiteViewChild(const uint32_t& id, const uin
PCompositorChild*
EmbedLiteAppProcessChild::AllocPCompositorChild(Transport* aTransport, ProcessId aOtherProcess)
{
LOGT("!!!!!!!!!!!!!!!!!!!!!!!!!Need to CompositorChild::Create(aTransport, aOtherProcess)");
return 0; //CompositorChild::Create(aTransport, aOtherProcess);
LOGT();
return CompositorChild::Create(aTransport, aOtherProcess);
}

} // namespace embedlite
Expand Down
Expand Up @@ -34,6 +34,7 @@
#include "mozilla/layers/ImageBridgeParent.h"

#include "EmbedLiteViewProcessParent.h"
#include "EmbedLiteCompositorProcessParent.h"

static BrowserProcessSubThread* sIOThread;

Expand Down Expand Up @@ -293,8 +294,8 @@ PCompositorParent*
EmbedLiteAppProcessParent::AllocPCompositorParent(Transport* aTransport,
ProcessId aOtherProcess)
{
LOGT("!!!!!!!!!!!!!!!!!!!!!!!Need to CompositorParent::Create(aTransport, aOtherProcess)");
return 0; //CompositorParent::Create(aTransport, aOtherProcess);
LOGT();
return EmbedLiteCompositorProcessParent::Create(aTransport, aOtherProcess);
}


Expand Down
210 changes: 210 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteCompositorProcessParent.cpp
@@ -0,0 +1,210 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */

#include "EmbedLog.h"

#include "EmbedLiteCompositorProcessParent.h"
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
#include "mozilla/layers/LayerTransactionParent.h" // for LayerTransactionParent

namespace mozilla {
namespace embedlite {

static StaticRefPtr<CompositorThreadHolder> sCompositorThreadHolder;

static void
OpenCompositor(EmbedLiteCompositorProcessParent* aCompositor,
Transport* aTransport, ProcessHandle aHandle,
MessageLoop* aIOLoop)
{
LOGT();
DebugOnly<bool> ok = aCompositor->Open(aTransport, aHandle, aIOLoop);
MOZ_ASSERT(ok);
}

/*static*/ PCompositorParent*
EmbedLiteCompositorProcessParent::Create(Transport* aTransport, ProcessId aOtherProcess)
{
LOGT();
nsRefPtr<EmbedLiteCompositorProcessParent> cpcp =
new EmbedLiteCompositorProcessParent(aTransport, aOtherProcess);
ProcessHandle handle;
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
// XXX need to kill |aOtherProcess|, it's boned
return nullptr;
}

cpcp->mSelfRef = cpcp;
CompositorParent::CompositorLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(OpenCompositor, cpcp.get(),
aTransport, handle, XRE_GetIOMessageLoop()));
// The return value is just compared to null for success checking,
// we're not sharing a ref.
return cpcp.get();
}

EmbedLiteCompositorProcessParent::EmbedLiteCompositorProcessParent(Transport* aTransport, ProcessId aOtherProcess)
: mTransport(aTransport)
, mChildProcessId(aOtherProcess)
, mCompositorThreadHolder(sCompositorThreadHolder)
, mNotifyAfterRemotePaint(false)
{
LOGT();
MOZ_ASSERT(NS_IsMainThread());
}

bool
EmbedLiteCompositorProcessParent::RecvGetTileSize(int32_t* aWidth, int32_t* aHeight)
{
LOGT();
*aWidth = 256;
*aHeight = 256;
return true;
}

bool
EmbedLiteCompositorProcessParent::RecvRequestNotifyAfterRemotePaint()
{
LOGT();
mNotifyAfterRemotePaint = true;
return true;
}

void
EmbedLiteCompositorProcessParent::ActorDestroy(ActorDestroyReason aWhy)
{
LOGT();
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedLiteCompositorProcessParent::DeferredDestroy));
}

PLayerTransactionParent*
EmbedLiteCompositorProcessParent::AllocPLayerTransactionParent(const nsTArray<LayersBackend>&,
const uint64_t& aId,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
bool *aSuccess)
{
LOGT("Implement me");
MOZ_ASSERT(aId != 0);

return nullptr;
}

bool
EmbedLiteCompositorProcessParent::DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers)
{
LOGT("Implement me");

return true;
}

bool
EmbedLiteCompositorProcessParent::RecvNotifyChildCreated(const uint64_t& child)
{
LOGT("Implement me");

return false;
}

void
EmbedLiteCompositorProcessParent::ShadowLayersUpdated(
LayerTransactionParent* aLayerTree,
const uint64_t& aTransactionId,
const TargetConfig& aTargetConfig,
bool aIsFirstPaint,
bool aScheduleComposite,
uint32_t aPaintSequenceNumber,
bool aIsRepeatTransaction)
{
LOGT("Implement me");
uint64_t id = aLayerTree->GetId();

MOZ_ASSERT(id != 0);
}

void
EmbedLiteCompositorProcessParent::DidComposite(uint64_t aId)
{
LOGT("Implement me");
}

void
EmbedLiteCompositorProcessParent::ForceComposite(LayerTransactionParent* aLayerTree)
{
LOGT("Implement me");
uint64_t id = aLayerTree->GetId();
MOZ_ASSERT(id != 0);
}

bool
EmbedLiteCompositorProcessParent::SetTestSampleTime(
LayerTransactionParent* aLayerTree, const TimeStamp& aTime)
{
LOGT("Implement me");
uint64_t id = aLayerTree->GetId();
MOZ_ASSERT(id != 0);

return false;
}

void
EmbedLiteCompositorProcessParent::LeaveTestMode(LayerTransactionParent* aLayerTree)
{
LOGT("Implement me");

uint64_t id = aLayerTree->GetId();
MOZ_ASSERT(id != 0);
}

void
EmbedLiteCompositorProcessParent::GetAPZTestData(const LayerTransactionParent* aLayerTree,
APZTestData* aOutData)
{
LOGT("Implement me");
uint64_t id = aLayerTree->GetId();
MOZ_ASSERT(id != 0);
}


AsyncCompositionManager*
EmbedLiteCompositorProcessParent::GetCompositionManager(LayerTransactionParent* aLayerTree)
{
LOGT("Implement me");
uint64_t id = aLayerTree->GetId();
MOZ_ASSERT(id != 0);

return nullptr;
}

void
EmbedLiteCompositorProcessParent::DeferredDestroy()
{
LOGT("Implement me");
}

EmbedLiteCompositorProcessParent::~EmbedLiteCompositorProcessParent()
{
LOGT();
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(XRE_GetIOMessageLoop());
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new DeleteTask<Transport>(mTransport));
}

IToplevelProtocol*
EmbedLiteCompositorProcessParent::CloneToplevel(const InfallibleTArray<mozilla::ipc::ProtocolFdMapping>& aFds,
base::ProcessHandle aPeerProcess,
mozilla::ipc::ProtocolCloneContext* aCtx)
{
LOGT("Implement me");

return nullptr;
}

} // namespace embedlite
} // namespace mozilla

114 changes: 114 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteCompositorProcessParent.h
@@ -0,0 +1,114 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */

#ifndef mozilla_layers_EmbedLiteCompositorProcessParent_h
#define mozilla_layers_EmbedLiteCompositorProcessParent_h

#define COMPOSITOR_PERFORMANCE_WARNING

#include "mozilla/layers/CompositorParent.h"
#include "mozilla/layers/CompositorChild.h"
#include "Layers.h"
#include "EmbedLiteViewThreadParent.h"

namespace mozilla {
namespace embedlite {

class EmbedLiteCompositorProcessParent MOZ_FINAL : public mozilla::layers::PCompositorParent,
public mozilla::layers::ShadowLayersManager
{
friend class CompositorParent;

NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(EmbedLiteCompositorProcessParent)
public:
EmbedLiteCompositorProcessParent(Transport* aTransport, ProcessId aOtherProcess);

// IToplevelProtocol::CloneToplevel()
virtual IToplevelProtocol*
CloneToplevel(const InfallibleTArray<mozilla::ipc::ProtocolFdMapping>& aFds,
base::ProcessHandle aPeerProcess,
mozilla::ipc::ProtocolCloneContext* aCtx) MOZ_OVERRIDE;

virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;

// FIXME/bug 774388: work out what shutdown protocol we need.
virtual bool RecvRequestOverfill() MOZ_OVERRIDE { return true; }
virtual bool RecvWillStop() MOZ_OVERRIDE { return true; }
virtual bool RecvStop() MOZ_OVERRIDE { return true; }
virtual bool RecvPause() MOZ_OVERRIDE { return true; }
virtual bool RecvResume() MOZ_OVERRIDE { return true; }
virtual bool RecvNotifyChildCreated(const uint64_t& child) MOZ_OVERRIDE;
virtual bool RecvAdoptChild(const uint64_t& child) MOZ_OVERRIDE { return false; }
virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
const nsIntRect& aRect)
{ return true; }
virtual bool RecvFlushRendering() MOZ_OVERRIDE { return true; }
virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) { return true; }
virtual bool RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) MOZ_OVERRIDE { return true; }
virtual bool RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray<float>* intervals) MOZ_OVERRIDE { return true; }
virtual bool RecvGetTileSize(int32_t* aWidth, int32_t* aHeight) MOZ_OVERRIDE;

/**
* Tells this CompositorParent to send a message when the compositor has received the transaction.
*/
virtual bool RecvRequestNotifyAfterRemotePaint() MOZ_OVERRIDE;

virtual PLayerTransactionParent*
AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints,
const uint64_t& aId,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
bool *aSuccess) MOZ_OVERRIDE;

virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) MOZ_OVERRIDE;

virtual void ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
const uint64_t& aTransactionId,
const TargetConfig& aTargetConfig,
bool aIsFirstPaint,
bool aScheduleComposite,
uint32_t aPaintSequenceNumber,
bool aIsRepeatTransaction) MOZ_OVERRIDE;
virtual void ForceComposite(LayerTransactionParent* aLayerTree) MOZ_OVERRIDE;
virtual bool SetTestSampleTime(LayerTransactionParent* aLayerTree,
const TimeStamp& aTime) MOZ_OVERRIDE;
virtual void LeaveTestMode(LayerTransactionParent* aLayerTree) MOZ_OVERRIDE;
virtual void GetAPZTestData(const LayerTransactionParent* aLayerTree,
APZTestData* aOutData) MOZ_OVERRIDE;

virtual AsyncCompositionManager* GetCompositionManager(LayerTransactionParent* aParent) MOZ_OVERRIDE;

void DidComposite(uint64_t aId);

/**
* A new child process has been configured to push transactions
* directly to us. Transport is to its thread context.
*/
static PCompositorParent*
Create(Transport* aTransport, ProcessId aOtherProcess);

private:
// Private destructor, to discourage deletion outside of Release():
virtual ~EmbedLiteCompositorProcessParent();

void DeferredDestroy();

// There can be many CPCPs, and IPDL-generated code doesn't hold a
// reference to top-level actors. So we hold a reference to
// ourself. This is released (deferred) in ActorDestroy().
nsRefPtr<EmbedLiteCompositorProcessParent> mSelfRef;
Transport* mTransport;
// Child side's process Id.
base::ProcessId mChildProcessId;

nsRefPtr<CompositorThreadHolder> mCompositorThreadHolder;
// If true, we should send a RemotePaintIsReady message when the layer transaction
// is received
bool mNotifyAfterRemotePaint;
};

} // embedlite
} // mozilla

#endif // mozilla_layers_EmbedLiteCompositorProcessParent_h
1 change: 1 addition & 0 deletions embedding/embedlite/embedshared/EmbedLiteAppBaseChild.cpp
Expand Up @@ -34,6 +34,7 @@ namespace mozilla {
namespace embedlite {

NS_GENERIC_FACTORY_CONSTRUCTOR(EmbedLiteJSON)
NS_GENERIC_FACTORY_CONSTRUCTOR(EmbedLiteAppService)

static EmbedLiteAppBaseChild* sAppBaseChild = nullptr;

Expand Down
6 changes: 4 additions & 2 deletions embedding/embedlite/embedthread/EmbedLiteAppThreadChild.cpp
Expand Up @@ -5,6 +5,8 @@

#include "EmbedLog.h"
#include "EmbedLiteAppThreadChild.h"
#include "EmbedLiteViewThreadChild.h"
#include "mozilla/layers/PCompositorChild.h"

namespace mozilla {
namespace embedlite {
Expand Down Expand Up @@ -40,10 +42,10 @@ EmbedLiteAppThreadChild::AllocPEmbedLiteViewChild(const uint32_t& id, const uint
return view;
}

PCompositorChild*
mozilla::layers::PCompositorChild*
EmbedLiteAppThreadChild::AllocPCompositorChild(Transport* aTransport, ProcessId aOtherProcess)
{
LOGT();
LOGNI();
return 0;
}

Expand Down

0 comments on commit deb051e

Please sign in to comment.