Navigation Menu

Skip to content

Commit

Permalink
[embedlite] Make embedprocess to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Apr 8, 2020
1 parent 5ed68b2 commit 95ed6c9
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 69 deletions.
Expand Up @@ -106,7 +106,7 @@ EmbedLiteAppProcessChild::Init(MessageLoop* aIOLoop,
// Once we start sending IPC messages, we need the thread manager to be
// initialized so we can deal with the responses. Do that here before we
// try to construct the crash reporter.
nsresult rv = nsThreadManager::get()->Init();
nsresult rv = nsThreadManager::get().Init();
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
Expand Down
50 changes: 29 additions & 21 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessParent.cpp
Expand Up @@ -34,6 +34,7 @@
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/ImageBridgeParent.h"
#include "mozilla/Unused.h"

#include "EmbedLiteViewProcessParent.h"
#include "EmbedLiteCompositorProcessParent.h"
Expand Down Expand Up @@ -61,19 +62,23 @@ class EmbedLiteAppProcessParentManager final : public mozilla::layers::LayerMana
}

protected:
virtual void BeginTransaction() {}
virtual void BeginTransactionWithTarget(gfxContext*) {}
virtual bool EndEmptyTransaction(mozilla::layers::LayerManager::EndTransactionFlags) { return false; }
virtual void EndTransaction(mozilla::layers::LayerManager::DrawPaintedLayerCallback, void*, mozilla::layers::LayerManager::EndTransactionFlags) {}
virtual void SetRoot(mozilla::layers::Layer*) {}
virtual already_AddRefed<mozilla::layers::PaintedLayer> CreatePaintedLayer() { return nullptr; }
virtual already_AddRefed<mozilla::layers::ContainerLayer> CreateContainerLayer() { return nullptr; }
virtual already_AddRefed<mozilla::layers::ImageLayer> CreateImageLayer() { return nullptr; }
virtual already_AddRefed<mozilla::layers::ColorLayer> CreateColorLayer() { return nullptr; }
virtual already_AddRefed<mozilla::layers::CanvasLayer> CreateCanvasLayer() { return nullptr; }
virtual mozilla::layers::LayersBackend GetBackendType() { return LayersBackend::LAYERS_OPENGL; }
virtual int32_t GetMaxTextureSize() const { return 0; }
virtual void GetBackendName(nsAString_internal&) {}
virtual bool BeginTransaction() override { return false; }
virtual bool BeginTransactionWithTarget(gfxContext*) override { return false; }
virtual bool EndEmptyTransaction(mozilla::layers::LayerManager::EndTransactionFlags) override { return false; }
virtual void EndTransaction(mozilla::layers::LayerManager::DrawPaintedLayerCallback,
void *aCallbackData,
mozilla::layers::LayerManager::EndTransactionFlags = mozilla::layers::LayerManager::END_DEFAULT) override {
Unused << aCallbackData;
}
virtual void SetRoot(mozilla::layers::Layer*) override {}
virtual already_AddRefed<mozilla::layers::PaintedLayer> CreatePaintedLayer() override { return nullptr; }
virtual already_AddRefed<mozilla::layers::ContainerLayer> CreateContainerLayer() override { return nullptr; }
virtual already_AddRefed<mozilla::layers::ImageLayer> CreateImageLayer() override { return nullptr; }
virtual already_AddRefed<mozilla::layers::ColorLayer> CreateColorLayer() override { return nullptr; }
virtual already_AddRefed<mozilla::layers::CanvasLayer> CreateCanvasLayer() override { return nullptr; }
virtual mozilla::layers::LayersBackend GetBackendType() override { return LayersBackend::LAYERS_OPENGL; }
virtual int32_t GetMaxTextureSize() const override { return 0; }
virtual void GetBackendName(nsAString&) override {}
};

static EmbedLiteAppProcessParent* sAppProcessParent = nullptr;
Expand All @@ -89,10 +94,13 @@ EmbedLiteAppProcessParent::CreateEmbedLiteAppProcessParent()
{
LOGT();
// Establish the main thread here.
NS_ASSERTION(false, "nsThreadManager::get()->Init()");
#if 0
if (NS_FAILED(nsThreadManager::get()->Init())) {
NS_ERROR("Could not initialize thread manager");
return nullptr;
}
#endif

NS_SetMainThread();

Expand Down Expand Up @@ -123,7 +131,8 @@ EmbedLiteAppProcessParent::EmbedLiteAppProcessParent()
sIOThread = ioThread.release();
}

IToplevelProtocol::SetTransport(mSubprocess->GetChannel());
NS_ASSERTION(false, "Fix IToplevelProtocol::SetTransport(mSubprocess->GetChannel())");
//IToplevelProtocol::SetTransport(mSubprocess->GetChannel());

// set gGREBinPath
gGREBinPath = ToNewUnicode(nsDependentCString(getenv("GRE_HOME")));
Expand Down Expand Up @@ -197,8 +206,9 @@ bool
EmbedLiteAppProcessParent::RecvReadyToShutdown()
{
LOGT();
MessageLoop::current()->PostTask(
FROM_HERE, NewRunnableMethod(this, &EmbedLiteAppProcessParent::ShutDownProcess, /* force */ false));
MessageLoop::current()->PostTask(NewRunnableMethod<bool>(this,
&EmbedLiteAppProcessParent::ShutDownProcess,
/* force */ false));

return true;
}
Expand Down Expand Up @@ -274,8 +284,8 @@ void
DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess)
{
LOGT();
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new DeleteTask<GeckoChildProcessHost>(aSubprocess));
RefPtr<DeleteTask<GeckoChildProcessHost>> task = new DeleteTask<GeckoChildProcessHost>(aSubprocess);
XRE_GetIOMessageLoop()->PostTask(task.forget());
}

// This runnable only exists to delegate ownership of the
Expand All @@ -302,9 +312,7 @@ EmbedLiteAppProcessParent::ActorDestroy(ActorDestroyReason aWhy)
ShutDownProcess(true);
}

MessageLoop::current()->
PostTask(FROM_HERE,
NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
MessageLoop::current()->PostTask(NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
mSubprocess = nullptr;
}

Expand Down
Expand Up @@ -15,6 +15,7 @@
#include <utility> // for pair

#include "gfxPrefs.h"
#include "VsyncSource.h"

#include "mozilla/layers/APZCTreeManager.h" // for APZCTreeManager
#include "mozilla/layers/AsyncCompositionManager.h"
Expand Down Expand Up @@ -59,19 +60,21 @@ EmbedLiteCompositorProcessParent::Create(Transport* aTransport, ProcessId aOther

cpcp->mSelfRef = cpcp;
CompositorThreadHolder::Loop()->PostTask(
FROM_HERE,
NewRunnableFunction(OpenCompositor, cpcp.get(),
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, int aSurfaceWidth, int aSurfaceHeight, uint32_t id)
: mTransport(aTransport)
: CompositorBridgeParent(CSSToLayoutDeviceScale(1.0),
gfxPlatform::GetPlatform()->GetHardwareVsync()->GetGlobalDisplay().GetVsyncRate(),
true,
IntSize(aSurfaceWidth, aSurfaceHeight))
, mTransport(aTransport)
, mChildProcessId(aOtherProcess)
, mNotifyAfterRemotePaint(false)
, mEGLSurfaceSize(aSurfaceWidth, aSurfaceHeight)
{
LOGT();
MOZ_ASSERT(NS_IsMainThread());
Expand All @@ -92,8 +95,7 @@ EmbedLiteCompositorProcessParent::ActorDestroy(ActorDestroyReason aWhy)
{
LOGT();
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedLiteCompositorProcessParent::DeferredDestroy));
NewRunnableMethod(this, &EmbedLiteCompositorProcessParent::DeferredDestroy));
}

void
Expand All @@ -105,22 +107,23 @@ EmbedLiteCompositorProcessParent::InitializeLayerManager(const nsTArray<LayersBa
for (size_t i = 0; i < aBackendHints.Length(); ++i) {
RefPtr<Compositor> compositor;
if (aBackendHints[i] == LayersBackend::LAYERS_OPENGL) {
compositor = new CompositorOGL(nullptr,
compositor = new CompositorOGL(this,
nullptr,
mEGLSurfaceSize.width,
mEGLSurfaceSize.height,
true);
} else if (aBackendHints[i] == LayersBackend::LAYERS_BASIC) {
#ifdef MOZ_WIDGET_GTK
if (gfxPlatformGtk::GetPlatform()->UseXRender()) {
compositor = new X11BasicCompositor(nullptr);
compositor = new X11BasicCompositor(this, nullptr);
} else
#endif
{
compositor = new BasicCompositor(nullptr);
compositor = new BasicCompositor(this, nullptr);
}
#ifdef XP_WIN
} else if (aBackendHints[i] == LayersBackend::LAYERS_D3D11) {
compositor = new CompositorD3D11(nullptr);
compositor = new CompositorD3D11(this, nullptr);
} else if (aBackendHints[i] == LayersBackend::LAYERS_D3D9) {
compositor = new CompositorD3D9(this, nullptr);
#endif
Expand All @@ -135,12 +138,19 @@ EmbedLiteCompositorProcessParent::InitializeLayerManager(const nsTArray<LayersBa
compositor->SetCompositorID(mCompositorID);
RefPtr<LayerManagerComposite> layerManager = new LayerManagerComposite(compositor);

if (layerManager->Initialize()) {
nsCString failureReason;
if (compositor->Initialize(&failureReason)) {
if (failureReason.IsEmpty()){
failureReason = "SUCCESS";
}
mLayerManager = layerManager;
MOZ_ASSERT(compositor);
mCompositor = compositor;
return;
}

gfxCriticalNote << "[OPENGL] Failed to init compositor with reason: "
<< failureReason.get();
}
}

Expand Down Expand Up @@ -198,7 +208,7 @@ EmbedLiteCompositorProcessParent::ShadowLayersUpdated(LayerTransactionParent* aL
bool aScheduleComposite,
uint32_t aPaintSequenceNumber,
bool aIsRepeatTransaction,
int32_t aPaintSyncId)
int32_t aPaintSyncId, bool aHitTestUpdate)
{
LOGT("Implement me");
Unused << aTransactionId;
Expand All @@ -209,6 +219,7 @@ EmbedLiteCompositorProcessParent::ShadowLayersUpdated(LayerTransactionParent* aL
Unused << aPaintSequenceNumber;
Unused << aIsRepeatTransaction;
Unused << aPaintSyncId;
Unused << aHitTestUpdate;
uint64_t id = aLayerTree->GetId();
MOZ_ASSERT(id != 0);
Unused << id;
Expand Down Expand Up @@ -307,25 +318,8 @@ 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;
}

bool
EmbedLiteCompositorProcessParent::RecvGetTileSize(int32_t* aWidth, int32_t* aHeight)
{
MOZ_ASSERT(false);
return true;
RefPtr<DeleteTask<Transport>> task = new DeleteTask<Transport>(mTransport);
XRE_GetIOMessageLoop()->PostTask(task.forget());
}

} // namespace embedlite
Expand Down
Expand Up @@ -16,39 +16,26 @@
namespace mozilla {
namespace embedlite {

class EmbedLiteCompositorProcessParent final : public PCompositorBridgeParent,
public ShadowLayersManager
class EmbedLiteCompositorProcessParent final : public CompositorBridgeParent
{
friend class CompositorBridgeParent;

NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(EmbedLiteCompositorProcessParent)
public:
EmbedLiteCompositorProcessParent(Transport* aTransport, ProcessId aOtherProcess, int aSurfaceWidth, int aSurfaceHeight, uint32_t id);

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

virtual void ActorDestroy(ActorDestroyReason aWhy) override;

virtual bool RecvGetFrameUniformity(FrameUniformityData* aOutData) override { return true; }
// FIXME/bug 774388: work out what shutdown protocol we need.
virtual bool RecvRequestOverfill() override { return true; }
virtual bool RecvWillStop() override { return true; }
virtual bool RecvStop() override { return true; }
virtual bool RecvPause() override { return true; }
virtual bool RecvResume() override { return true; }
virtual bool RecvNotifyHidden(const uint64_t& id) override { return true; }
virtual bool RecvNotifyVisible(const uint64_t& id) override { return true; }
virtual bool RecvNotifyChildCreated(const uint64_t& child) override;
virtual bool RecvAdoptChild(const uint64_t& child) override { return false; }
virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
const nsIntRect& aRect) { return true; }
virtual bool RecvMakeWidgetSnapshot(const SurfaceDescriptor& aInSnapshot) override { return true; }
virtual bool RecvFlushRendering() override { return true; }
virtual bool RecvGetTileSize(int32_t* aWidth, int32_t* aHeight) override;

virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) { return true; }
virtual bool RecvStartFrameTimeRecording(const int32_t& aBufferSize, uint32_t* aOutStartIndex) override { return true; }
Expand All @@ -75,7 +62,8 @@ class EmbedLiteCompositorProcessParent final : public PCompositorBridgeParent,
bool aScheduleComposite,
uint32_t aPaintSequenceNumber,
bool aIsRepeatTransaction,
int32_t aPaintSyncId) override;
int32_t aPaintSyncId,
bool aHitTestUpdate) override;
virtual void ForceComposite(LayerTransactionParent* aLayerTree) override;
virtual bool SetTestSampleTime(LayerTransactionParent* aLayerTree,
const TimeStamp& aTime) override;
Expand Down Expand Up @@ -124,7 +112,6 @@ class EmbedLiteCompositorProcessParent final : public PCompositorBridgeParent,
RefPtr<Compositor> mCompositor;
RefPtr<AsyncCompositionManager> mCompositionManager;
uint64_t mCompositorID;
nsIntSize mEGLSurfaceSize;
};

} // embedlite
Expand Down

0 comments on commit 95ed6c9

Please sign in to comment.