Skip to content

Commit

Permalink
Initialize GeckoController as soon as possible and setup compositor w…
Browse files Browse the repository at this point in the history
…hen it is ready
  • Loading branch information
rojkov authored and tmeshkova committed Feb 1, 2014
1 parent c9fb4b1 commit 54c946d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 46 deletions.
8 changes: 6 additions & 2 deletions embedding/embedlite/embedthread/EmbedContentController.cpp
Expand Up @@ -19,11 +19,15 @@ using namespace mozilla::layers;
class FakeListener : public EmbedLiteViewListener {};
static FakeListener sFakeListener;

EmbedContentController::EmbedContentController(EmbedLiteViewThreadParent* aRenderFrame, CompositorParent* aCompositor, MessageLoop* aUILoop)
EmbedContentController::EmbedContentController(EmbedLiteViewThreadParent* aRenderFrame, MessageLoop* aUILoop)
: mUILoop(aUILoop)
, mRenderFrame(aRenderFrame)
{
mAPZC = CompositorParent::GetAPZCTreeManager(aCompositor->RootLayerTreeId());
}

void EmbedContentController::SetManagerByRootLayerTreeId(uint64_t aRootLayerTreeId)
{
mAPZC = CompositorParent::GetAPZCTreeManager(aRootLayerTreeId);
}

void EmbedContentController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
Expand Down
5 changes: 4 additions & 1 deletion embedding/embedlite/embedthread/EmbedContentController.h
Expand Up @@ -26,7 +26,10 @@ class EmbedContentController : public mozilla::layers::GeckoContentController
typedef mozilla::layers::ZoomConstraints ZoomConstraints;

public:
EmbedContentController(EmbedLiteViewThreadParent* aRenderFrame, mozilla::layers::CompositorParent* aCompositor, MessageLoop* aUILoop);
EmbedContentController(EmbedLiteViewThreadParent* aRenderFrame, MessageLoop* aUILoop);

// This method build APZCTreeManager for give layer tree
void SetManagerByRootLayerTreeId(uint64_t aRootLayerTreeId);

// GeckoContentController interface
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;
Expand Down
78 changes: 36 additions & 42 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadParent.cpp
Expand Up @@ -54,6 +54,7 @@ EmbedLiteViewThreadParent::EmbedLiteViewThreadParent(const uint32_t& id, const u
, mUILoop(MessageLoop::current())
, mLastIMEState(0)
, mUploadTexture(0)
, mController(new EmbedContentController(this, mUILoop))
{
MOZ_COUNT_CTOR(EmbedLiteViewThreadParent);
MOZ_ASSERT(mView, "View destroyed during OMTC view construction");
Expand Down Expand Up @@ -103,10 +104,9 @@ EmbedLiteViewThreadParent::UpdateScrollController()

NS_ENSURE_TRUE(mView, );

mController = nullptr;
if (mCompositor) {
mRootLayerTreeId = mCompositor->RootLayerTreeId();
mController = new EmbedContentController(this, mCompositor, mUILoop);
mController->SetManagerByRootLayerTreeId(mRootLayerTreeId);
CompositorParent::SetControllerForLayerTree(mRootLayerTreeId, mController);
}
}
Expand Down Expand Up @@ -262,7 +262,7 @@ EmbedLiteViewThreadParent::RecvOnTitleChanged(const nsString& aTitle)
bool
EmbedLiteViewThreadParent::RecvUpdateZoomConstraints(const bool& aAllowZoom, const float& min, const float& max)
{
if (mController) {
if (mController->GetManager()) {
ZoomConstraints constraints(aAllowZoom, CSSToScreenScale(min), CSSToScreenScale(max));
mController->GetManager()->UpdateZoomConstraints(ScrollableLayerGuid(mRootLayerTreeId, 0, 0), constraints);
}
Expand All @@ -272,7 +272,7 @@ EmbedLiteViewThreadParent::RecvUpdateZoomConstraints(const bool& aAllowZoom, con
bool
EmbedLiteViewThreadParent::RecvZoomToRect(const CSSRect& aRect)
{
if (mController) {
if (mController->GetManager()) {
mController->GetManager()->ZoomToRect(ScrollableLayerGuid(mRootLayerTreeId, 0, 0), aRect);
}
return true;
Expand All @@ -281,7 +281,7 @@ EmbedLiteViewThreadParent::RecvZoomToRect(const CSSRect& aRect)
bool
EmbedLiteViewThreadParent::RecvContentReceivedTouch(const ScrollableLayerGuid& aGuid, const bool& aPreventDefault)
{
if (mController) {
if (mController->GetManager()) {
mController->GetManager()->ContentReceivedTouch(aGuid, aPreventDefault);
}
return true;
Expand Down Expand Up @@ -535,7 +535,7 @@ EmbedLiteViewThreadParent::ScheduleRender()
void
EmbedLiteViewThreadParent::ReceiveInputEvent(const InputData& aEvent)
{
if (mController) {
if (mController->GetManager()) {
ScrollableLayerGuid guid;
mController->ReceiveInputEvent(aEvent, &guid);
if (aEvent.mInputType == MULTITOUCH_INPUT) {
Expand Down Expand Up @@ -603,54 +603,48 @@ void
EmbedLiteViewThreadParent::MousePress(int x, int y, int mstime, unsigned int buttons, unsigned int modifiers)
{
LOGT("pt[%i,%i], t:%i, bt:%u, mod:%u", x, y, mstime, buttons, modifiers);
if (mController) {
MultiTouchInput event(MultiTouchInput::MULTITOUCH_START, mstime, modifiers);
event.mTouches.AppendElement(SingleTouchData(0,
mozilla::ScreenIntPoint(x, y),
mozilla::ScreenSize(1, 1),
180.0f,
1.0f));
mController->ReceiveInputEvent(event, nullptr);
unused << SendMouseEvent(NS_LITERAL_STRING("mousedown"),
x, y, buttons, 1, modifiers,
true);
}
MultiTouchInput event(MultiTouchInput::MULTITOUCH_START, mstime, modifiers);
event.mTouches.AppendElement(SingleTouchData(0,
mozilla::ScreenIntPoint(x, y),
mozilla::ScreenSize(1, 1),
180.0f,
1.0f));
mController->ReceiveInputEvent(event, nullptr);
unused << SendMouseEvent(NS_LITERAL_STRING("mousedown"),
x, y, buttons, 1, modifiers,
true);
}

void
EmbedLiteViewThreadParent::MouseRelease(int x, int y, int mstime, unsigned int buttons, unsigned int modifiers)
{
LOGT("pt[%i,%i], t:%i, bt:%u, mod:%u", x, y, mstime, buttons, modifiers);
if (mController) {
MultiTouchInput event(MultiTouchInput::MULTITOUCH_END, mstime, modifiers);
event.mTouches.AppendElement(SingleTouchData(0,
mozilla::ScreenIntPoint(x, y),
mozilla::ScreenSize(1, 1),
180.0f,
1.0f));
mController->ReceiveInputEvent(event, nullptr);
unused << SendMouseEvent(NS_LITERAL_STRING("mouseup"),
x, y, buttons, 1, modifiers,
true);
}
MultiTouchInput event(MultiTouchInput::MULTITOUCH_END, mstime, modifiers);
event.mTouches.AppendElement(SingleTouchData(0,
mozilla::ScreenIntPoint(x, y),
mozilla::ScreenSize(1, 1),
180.0f,
1.0f));
mController->ReceiveInputEvent(event, nullptr);
unused << SendMouseEvent(NS_LITERAL_STRING("mouseup"),
x, y, buttons, 1, modifiers,
true);
}

void
EmbedLiteViewThreadParent::MouseMove(int x, int y, int mstime, unsigned int buttons, unsigned int modifiers)
{
LOGT("pt[%i,%i], t:%i, bt:%u, mod:%u", x, y, mstime, buttons, modifiers);
if (mController) {
MultiTouchInput event(MultiTouchInput::MULTITOUCH_MOVE, mstime, modifiers);
event.mTouches.AppendElement(SingleTouchData(0,
mozilla::ScreenIntPoint(x, y),
mozilla::ScreenSize(1, 1),
180.0f,
1.0f));
mController->ReceiveInputEvent(event, nullptr);
unused << SendMouseEvent(NS_LITERAL_STRING("mousemove"),
x, y, buttons, 1, modifiers,
true);
}
MultiTouchInput event(MultiTouchInput::MULTITOUCH_MOVE, mstime, modifiers);
event.mTouches.AppendElement(SingleTouchData(0,
mozilla::ScreenIntPoint(x, y),
mozilla::ScreenSize(1, 1),
180.0f,
1.0f));
mController->ReceiveInputEvent(event, nullptr);
unused << SendMouseEvent(NS_LITERAL_STRING("mousemove"),
x, y, buttons, 1, modifiers,
true);
}

bool
Expand Down
Expand Up @@ -145,8 +145,8 @@ class EmbedLiteViewThreadParent : public PEmbedLiteViewParent,
int mLastIMEState;

uint64_t mRootLayerTreeId;
nsRefPtr<EmbedContentController> mController;
GLuint mUploadTexture;
nsRefPtr<EmbedContentController> mController;

DISALLOW_EVIL_CONSTRUCTORS(EmbedLiteViewThreadParent);
};
Expand Down

0 comments on commit 54c946d

Please sign in to comment.