Skip to content

Commit

Permalink
Try to make embedding to build
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Apr 8, 2020
1 parent d8f00ab commit 06d49e4
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 47 deletions.
8 changes: 4 additions & 4 deletions embedding/embedlite/EmbedLiteApp.cpp
Expand Up @@ -14,7 +14,7 @@
#include "base/message_loop.h" // for MessageLoop

#include "mozilla/embedlite/EmbedLiteAPI.h"
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder

#include "EmbedLiteUILoop.h"
#include "EmbedLiteSubThread.h"
Expand Down Expand Up @@ -124,13 +124,13 @@ EmbedLiteApp::PostTask(EMBEDTaskCallback callback, void* userData, int timeout)
void*
EmbedLiteApp::PostCompositorTask(EMBEDTaskCallback callback, void* userData, int timeout)
{
if (!mozilla::layers::CompositorParent::CompositorLoop()) {
if (!mozilla::layers::CompositorThreadHolder::IsActive()) {
// Can't post compositor task if gecko compositor thread has not been initialized, yet.
return nullptr;
}

CancelableTask* newTask = NewRunnableFunction(callback, userData);
MessageLoop* compositorLoop = mozilla::layers::CompositorParent::CompositorLoop();
RefPtr<CancelableRunnable> newTask = NewRunnableFunction(callback, userData);
MessageLoop* compositorLoop = mozilla::layers::CompositorThreadHolder::Loop();
MOZ_ASSERT(compositorLoop);

if (timeout) {
Expand Down
7 changes: 4 additions & 3 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessChild.cpp
Expand Up @@ -185,11 +185,12 @@ EmbedLiteAppProcessChild::AllocPEmbedLiteWindowChild(const uint16_t& width, cons
return nullptr;
}

PCompositorChild*
EmbedLiteAppProcessChild::AllocPCompositorChild(Transport* aTransport, ProcessId aOtherProcess)
PCompositorBridgeChild*
EmbedLiteAppProcessChild::AllocPCompositorBridgeChild(Transport* aTransport, ProcessId aOtherProcess)
{
LOGT();
return CompositorChild::Create(aTransport, aOtherProcess);
//return CompositorBridgeChild::Create(aTransport, aOtherProcess);
return nullptr;
}

} // namespace embedlite
Expand Down
Expand Up @@ -46,7 +46,7 @@ class EmbedLiteAppProcessChild : public EmbedLiteAppBaseChild
virtual PEmbedLiteWindowChild* AllocPEmbedLiteWindowChild(const uint16_t& width, const uint16_t& height,
const uint32_t& id) override;

virtual PCompositorChild* AllocPCompositorChild(Transport* aTransport, ProcessId aOtherProcess);
virtual PCompositorBridgeChild* AllocPCompositorBridgeChild(Transport* aTransport, ProcessId aOtherProcess);

// IPDL protocol impl
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
Expand Down
10 changes: 4 additions & 6 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessParent.cpp
Expand Up @@ -30,6 +30,7 @@
#include "base/command_line.h"
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/ImageBridgeParent.h"

Expand Down Expand Up @@ -230,12 +231,9 @@ EmbedLiteAppProcessParent::AllocPEmbedLiteViewParent(const uint32_t& windowId, c
static bool sCompositorCreated = false;
if (!sCompositorCreated) {
sCompositorCreated = true;
mozilla::layers::CompositorParent::StartUp();
bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
LOGT("useOffMainThreadCompositing:%i", useOffMainThreadCompositing);
if (useOffMainThreadCompositing)
mozilla::layers::CompositorThreadHolder::Start();
{
DebugOnly<bool> opened = PCompositor::Open(this);
DebugOnly<bool> opened = PCompositorBridge::Open(this);
MOZ_ASSERT(opened);
}
}
Expand Down Expand Up @@ -338,7 +336,7 @@ EmbedLiteAppProcessParent::AllocPCompositorBridgeParent(Transport* aTransport,
{
LOGT();
RefPtr<EmbedLiteAppProcessParentManager> mgr = new EmbedLiteAppProcessParentManager(); // Dummy manager in order to initialize layers log, fix me by creating proper manager for this process type
// return CompositorParent::Create(aTransport, aOtherProcess);
// return CompositorBridgeParent::Create(aTransport, aOtherProcess);
return EmbedLiteCompositorProcessParent::Create(aTransport, aOtherProcess, 480, 800, 1);
}

Expand Down
Expand Up @@ -6,7 +6,6 @@
#include "EmbedLog.h"

#include "EmbedLiteCompositorProcessParent.h"
#include "mozilla/layers/CompositorParent.h" // for CompositorParent
#include "mozilla/layers/LayerTransactionParent.h" // for LayerTransactionParent
#include "mozilla/layers/LayerManagerComposite.h"
#include "mozilla/layers/Compositor.h" // for Compositor
Expand All @@ -20,6 +19,7 @@
#include "mozilla/layers/APZCTreeManager.h" // for APZCTreeManager
#include "mozilla/layers/AsyncCompositionManager.h"
#include "mozilla/layers/BasicCompositor.h" // for BasicCompositor
#include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder
#include "mozilla/layers/Compositor.h" // for Compositor
#include "mozilla/layers/CompositorOGL.h" // for CompositorOGL

Expand All @@ -31,8 +31,6 @@ using namespace mozilla::ipc;
using namespace mozilla::gfx;
using namespace std;

static StaticRefPtr<CompositorThreadHolder> sCompositorThreadHolder;

static void
OpenCompositor(EmbedLiteCompositorProcessParent* aCompositor,
Transport* aTransport, ProcessHandle aHandle,
Expand Down Expand Up @@ -60,7 +58,7 @@ EmbedLiteCompositorProcessParent::Create(Transport* aTransport, ProcessId aOther
}

cpcp->mSelfRef = cpcp;
CompositorParent::CompositorLoop()->PostTask(
CompositorThreadHolder::Loop()->PostTask(
FROM_HERE,
NewRunnableFunction(OpenCompositor, cpcp.get(),
aTransport, handle, XRE_GetIOMessageLoop()));
Expand All @@ -72,7 +70,6 @@ EmbedLiteCompositorProcessParent::Create(Transport* aTransport, ProcessId aOther
EmbedLiteCompositorProcessParent::EmbedLiteCompositorProcessParent(Transport* aTransport, ProcessId aOtherProcess, int aSurfaceWidth, int aSurfaceHeight, uint32_t id)
: mTransport(aTransport)
, mChildProcessId(aOtherProcess)
, mCompositorThreadHolder(sCompositorThreadHolder)
, mNotifyAfterRemotePaint(false)
, mEGLSurfaceSize(aSurfaceWidth, aSurfaceHeight)
{
Expand Down Expand Up @@ -302,7 +299,6 @@ void
EmbedLiteCompositorProcessParent::DeferredDestroy()
{
LOGT();
mCompositorThreadHolder = nullptr;
mSelfRef = nullptr;
}

Expand Down
Expand Up @@ -8,8 +8,8 @@

#define COMPOSITOR_PERFORMANCE_WARNING

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

Expand All @@ -19,7 +19,7 @@ namespace embedlite {
class EmbedLiteCompositorProcessParent final : public PCompositorBridgeParent,
public ShadowLayersManager
{
friend class CompositorParent;
friend class CompositorBridgeParent;

NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(EmbedLiteCompositorProcessParent)
public:
Expand Down Expand Up @@ -55,7 +55,7 @@ class EmbedLiteCompositorProcessParent final : public PCompositorBridgeParent,
virtual bool RecvStopFrameTimeRecording(const uint32_t& aStartIndex, InfallibleTArray<float>* intervals) override { return true; }

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

Expand Down Expand Up @@ -116,7 +116,6 @@ class EmbedLiteCompositorProcessParent final : public PCompositorBridgeParent,
// Child side's process Id.
base::ProcessId mChildProcessId;

RefPtr<CompositorThreadHolder> mCompositorThreadHolder;
// If true, we should send a RemotePaintIsReady message when the layer transaction
// is received
bool mNotifyAfterRemotePaint;
Expand Down
Expand Up @@ -30,9 +30,9 @@ EmbedLiteViewProcessChild::OnGeckoWindowInitialized()

// Pushing layers transactions directly to a separate
// compositor context.
PCompositorChild* compositorChild = CompositorChild::Get();
CompositorBridgeChild* compositorChild = CompositorBridgeChild::Get();
if (!compositorChild) {
NS_WARNING("failed to get CompositorChild instance");
NS_WARNING("failed to get CompositorBridgeChild instance");
return;
}

Expand Down
11 changes: 8 additions & 3 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.cpp
Expand Up @@ -15,7 +15,8 @@
# include "LayerManagerD3D10.h"
#endif
#include "mozilla/Hal.h"
#include "mozilla/layers/CompositorChild.h"
#include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/ipc/MessageChannel.h"
#include "EmbedLitePuppetWidget.h"
Expand Down Expand Up @@ -110,7 +111,7 @@ EmbedLitePuppetWidget::EmbedLitePuppetWidget(EmbedLiteWindowBaseChild* window)
: EmbedLitePuppetWidget(window, nullptr)
{
if (sUseExternalGLContext && sRequestGLContextEarly) {
CompositorParent::CompositorLoop()->PostTask(FROM_HERE,
CompositorThreadHolder::Loop()->PostTask(FROM_HERE,
NewRunnableFunction(&CreateGLContextEarly, window->GetUniqueID()));
}
}
Expand Down Expand Up @@ -371,10 +372,13 @@ EmbedLitePuppetWidget::Resize(double aWidth, double aHeight, bool aRepaint)
listener->WindowResized(this, mBounds.width, mBounds.height);
}

// Looks that we need CompositorSession
#if 0
if (mCompositorParent) {
static_cast<EmbedLiteCompositorParent*>(mCompositorParent.get())->
SetSurfaceSize(mNaturalBounds.width, mNaturalBounds.height);
}
#endif

return NS_OK;
}
Expand Down Expand Up @@ -778,9 +782,10 @@ void EmbedLitePuppetWidget::UpdateZoomConstraints(const uint32_t &aPresShellId,
}
}

CompositorParent*
CompositorBridgeParent*
EmbedLitePuppetWidget::NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight)
{
// See nsBaseWidget::CreateCompositor and sha1 bb2cbc24f4cb9bee50a46ba7a520b9016d5207a5
LOGT();
mHasCompositor = true;
return new EmbedLiteCompositorParent(this, mWindow->GetUniqueID(), true,
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/embedshared/EmbedLitePuppetWidget.h
Expand Up @@ -150,7 +150,7 @@ class EmbedLitePuppetWidget : public nsBaseWidget
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nullptr) override;

virtual mozilla::layers::CompositorParent* NewCompositorParent(int aSurfaceWidth,
virtual mozilla::layers::CompositorBridgeParent* NewCompositorParent(int aSurfaceWidth,
int aSurfaceHeight) override;
virtual void CreateCompositor() override;
virtual void CreateCompositor(int aWidth, int aHeight) override;
Expand Down
10 changes: 7 additions & 3 deletions embedding/embedlite/embedshared/EmbedLiteViewBaseParent.cpp
Expand Up @@ -85,16 +85,20 @@ EmbedLiteViewBaseParent::UpdateScrollController()
if (mDPI > 0) {
GetApzcTreeManager()->SetDPI(mDPI);
}
CompositorParent::SetControllerForLayerTree(mRootLayerTreeId, mContentController);
CompositorBridgeParent::SetControllerForLayerTree(mRootLayerTreeId, mContentController);
}
}

mozilla::layers::APZCTreeManager *EmbedLiteViewBaseParent::GetApzcTreeManager()
mozilla::layers::IAPZCTreeManager *EmbedLiteViewBaseParent::GetApzcTreeManager()
{
#if 0
if (!mApzcTreeManager) {
mApzcTreeManager = CompositorParent::GetAPZCTreeManager(mRootLayerTreeId);
mApzcTreeManager = CompositorBridgeParent::GetApzcTreeManagerParentForRoot(mRootLayerTreeId);
}
return mApzcTreeManager.get();
#else
return nullptr;
#endif
}

// Child notification
Expand Down
6 changes: 3 additions & 3 deletions embedding/embedlite/embedshared/EmbedLiteViewBaseParent.h
Expand Up @@ -12,7 +12,7 @@
#include "EmbedLiteWindowBaseParent.h"
#include "GLDefs.h"

#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/IAPZCTreeManager.h" // public IAPZCTreeManager

namespace mozilla {
namespace embedlite {
Expand Down Expand Up @@ -134,7 +134,7 @@ class EmbedLiteViewBaseParent : public PEmbedLiteViewParent,
void SetCompositor(EmbedLiteCompositorParent* aCompositor); // XXX: Remove
void UpdateScrollController();

mozilla::layers::APZCTreeManager *GetApzcTreeManager();
mozilla::layers::IAPZCTreeManager *GetApzcTreeManager();

uint32_t mId;
EmbedLiteView* mView;
Expand All @@ -150,7 +150,7 @@ class EmbedLiteViewBaseParent : public PEmbedLiteViewParent,
uint64_t mRootLayerTreeId;
GLuint mUploadTexture;

RefPtr<mozilla::layers::APZCTreeManager> mApzcTreeManager;
RefPtr<mozilla::layers::IAPZCTreeManager> mApzcTreeManager;
RefPtr<EmbedContentController> mContentController;

DISALLOW_EVIL_CONSTRUCTORS(EmbedLiteViewBaseParent);
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/embedthread/EmbedContentController.cpp
Expand Up @@ -8,7 +8,7 @@
#include "EmbedLiteView.h"
#include "mozilla/unused.h"
#include "EmbedLiteViewBaseParent.h"
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "EmbedLiteCompositorParent.h"

using namespace mozilla::embedlite;
Expand Down
4 changes: 2 additions & 2 deletions embedding/embedlite/embedthread/EmbedLiteAppThreadChild.cpp
Expand Up @@ -53,8 +53,8 @@ EmbedLiteAppThreadChild::AllocPEmbedLiteWindowChild(const uint16_t& width, const
return window;
}

mozilla::layers::PCompositorChild*
EmbedLiteAppThreadChild::AllocPCompositorChild(Transport* aTransport, ProcessId aOtherProcess)
mozilla::layers::PCompositorBridgeChild*
EmbedLiteAppThreadChild::AllocPCompositorBridgeChild(Transport* aTransport, ProcessId aOtherProcess)
{
LOGNI();
return 0;
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/embedthread/EmbedLiteAppThreadChild.h
Expand Up @@ -22,7 +22,7 @@ class EmbedLiteAppThreadChild : public EmbedLiteAppBaseChild

virtual PEmbedLiteViewChild* AllocPEmbedLiteViewChild(const uint32_t&, const uint32_t&, const uint32_t& parentId, const bool& isPrivateWindow) override;
virtual PEmbedLiteWindowChild* AllocPEmbedLiteWindowChild(const uint16_t& width, const uint16_t& height, const uint32_t&) override;
virtual PCompositorChild* AllocPCompositorChild(Transport* aTransport, ProcessId aOtherProcess);
virtual mozilla::layers::PCompositorBridgeChild* AllocPCompositorBridgeChild(Transport* aTransport, ProcessId aOtherProcess);

private:
DISALLOW_EVIL_CONSTRUCTORS(EmbedLiteAppThreadChild);
Expand Down
19 changes: 16 additions & 3 deletions embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp
Expand Up @@ -42,6 +42,7 @@ EmbedLiteCompositorParent::EmbedLiteCompositorParent(nsIWidget* widget,
bool aRenderToEGLSurface,
int aSurfaceWidth,
int aSurfaceHeight)
#if 0
: CompositorParent(widget, aRenderToEGLSurface, aSurfaceWidth, aSurfaceHeight)
, mWindowId(windowId)
, mCurrentCompositeTask(nullptr)
Expand All @@ -54,6 +55,9 @@ EmbedLiteCompositorParent::EmbedLiteCompositorParent(nsIWidget* widget,
"embedlite.compositor.external_gl_context", false);
parentWindow->SetCompositor(this);
}
#else
{}
#endif

EmbedLiteCompositorParent::~EmbedLiteCompositorParent()
{
Expand All @@ -67,7 +71,7 @@ EmbedLiteCompositorParent::AllocPLayerTransactionParent(const nsTArray<LayersBac
bool* aSuccess)
{
PLayerTransactionParent* p =
CompositorParent::AllocPLayerTransactionParent(aBackendHints,
CompositorBridgeParent::AllocPLayerTransactionParent(aBackendHints,
aId,
aTextureFactoryIdentifier,
aSuccess);
Expand All @@ -84,11 +88,18 @@ EmbedLiteCompositorParent::AllocPLayerTransactionParent(const nsTArray<LayersBac
return p;
}

bool EmbedLiteCompositorParent::DeallocPLayerTransactionParent(PLayerTransactionParent *aLayers)
{
bool deallocated = CompositorBridgeParent::DeallocPLayerTransactionParent(aLayers);
LOGT();
return deallocated;
}

void
EmbedLiteCompositorParent::PrepareOffscreen()
{

const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(RootLayerTreeId());
const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(RootLayerTreeId());
NS_ENSURE_TRUE(state && state->mLayerManager, );

GLContext* context = static_cast<CompositorOGL*>(state->mLayerManager->GetCompositor())->gl();
Expand Down Expand Up @@ -125,7 +136,7 @@ EmbedLiteCompositorParent::PrepareOffscreen()
void
EmbedLiteCompositorParent::UpdateTransformState()
{
const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(RootLayerTreeId());
const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(RootLayerTreeId());
NS_ENSURE_TRUE(state && state->mLayerManager, );

CompositorOGL *compositor = static_cast<CompositorOGL*>(state->mLayerManager->GetCompositor());
Expand All @@ -142,12 +153,14 @@ EmbedLiteCompositorParent::UpdateTransformState()
void
EmbedLiteCompositorParent::ScheduleTask(CancelableTask* task, int time)
{
#if 0
if (Invalidate()) {
task->Cancel();
CancelCurrentCompositeTask();
} else {
CompositorParent::ScheduleTask(task, time);
}
#endif
}

bool
Expand Down

0 comments on commit 06d49e4

Please sign in to comment.