Bug 1445662 - Update RemoteContentController to allow the GPU process controller thread to be different from the compositor thread. r=rhunt

A couple of RemoteContentController methods get called on the controller
thread in the GPU process. This is the same as the compositor thread so
we could just do compositor-thread stuff here, but we will want to
support the controller thread being the main thread instead of the
compositor thread. So we detect those cases and bounce the message
accordingly.
This commit is contained in:
Kartikaya Gupta 2018-03-15 15:25:11 -04:00
Родитель c4a6aff0f0
Коммит d16ab46492
2 изменённых файлов: 78 добавлений и 18 удалений

Просмотреть файл

@ -59,6 +59,25 @@ RemoteContentController::HandleTapOnMainThread(TapType aTapType,
}
}
void
RemoteContentController::HandleTapOnCompositorThread(TapType aTapType,
LayoutDevicePoint aPoint,
Modifiers aModifiers,
ScrollableLayerGuid aGuid,
uint64_t aInputBlockId)
{
MOZ_ASSERT(XRE_IsGPUProcess());
MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
// The raw pointer to APZCTreeManagerParent is ok here because we are on the
// compositor thread.
APZCTreeManagerParent* apzctmp =
CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
if (apzctmp) {
Unused << apzctmp->SendHandleTap(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
}
}
void
RemoteContentController::HandleTap(TapType aTapType,
const LayoutDevicePoint& aPoint,
@ -69,16 +88,24 @@ RemoteContentController::HandleTap(TapType aTapType,
APZThreadUtils::AssertOnControllerThread();
if (XRE_GetProcessType() == GeckoProcessType_GPU) {
MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
// The raw pointer to APZCTreeManagerParent is ok here because we are on the
// compositor thread.
APZCTreeManagerParent* apzctmp =
CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
if (apzctmp) {
Unused << apzctmp->SendHandleTap(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
if (MessageLoop::current() == mCompositorThread) {
HandleTapOnCompositorThread(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
} else {
// We have to send messages from the compositor thread
mCompositorThread->PostTask(NewRunnableMethod<TapType,
LayoutDevicePoint,
Modifiers,
ScrollableLayerGuid,
uint64_t>(
"layers::RemoteContentController::HandleTapOnCompositorThread",
this,
&RemoteContentController::HandleTapOnCompositorThread,
aTapType,
aPoint,
aModifiers,
aGuid,
aInputBlockId));
}
return;
}
@ -105,6 +132,24 @@ RemoteContentController::HandleTap(TapType aTapType,
}
}
void
RemoteContentController::NotifyPinchGestureOnCompositorThread(
PinchGestureInput::PinchGestureType aType,
const ScrollableLayerGuid& aGuid,
LayoutDeviceCoord aSpanChange,
Modifiers aModifiers)
{
MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
// The raw pointer to APZCTreeManagerParent is ok here because we are on the
// compositor thread.
APZCTreeManagerParent* apzctmp =
CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
if (apzctmp) {
Unused << apzctmp->SendNotifyPinchGesture(aType, aGuid, aSpanChange, aModifiers);
}
}
void
RemoteContentController::NotifyPinchGesture(PinchGestureInput::PinchGestureType aType,
const ScrollableLayerGuid& aGuid,
@ -119,16 +164,22 @@ RemoteContentController::NotifyPinchGesture(PinchGestureInput::PinchGestureType
// If we're in the GPU process, try to find a handle to the parent process
// and send it there.
if (XRE_IsGPUProcess()) {
MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
// The raw pointer to APZCTreeManagerParent is ok here because we are on the
// compositor thread.
APZCTreeManagerParent* apzctmp =
CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
if (apzctmp) {
Unused << apzctmp->SendNotifyPinchGesture(aType, aGuid, aSpanChange, aModifiers);
return;
if (MessageLoop::current() == mCompositorThread) {
NotifyPinchGestureOnCompositorThread(aType, aGuid, aSpanChange, aModifiers);
} else {
mCompositorThread->PostTask(NewRunnableMethod<PinchGestureInput::PinchGestureType,
ScrollableLayerGuid,
LayoutDeviceCoord,
Modifiers>(
"layers::RemoteContentController::NotifyPinchGestureOnCompositorThread",
this,
&RemoteContentController::NotifyPinchGestureOnCompositorThread,
aType,
aGuid,
aSpanChange,
aModifiers));
}
return;
}
// If we're in the parent process, handle it directly. We don't have a handle

Просмотреть файл

@ -90,6 +90,15 @@ private:
Modifiers aModifiers,
ScrollableLayerGuid aGuid,
uint64_t aInputBlockId);
void HandleTapOnCompositorThread(TapType aType,
LayoutDevicePoint aPoint,
Modifiers aModifiers,
ScrollableLayerGuid aGuid,
uint64_t aInputBlockId);
void NotifyPinchGestureOnCompositorThread(PinchGestureInput::PinchGestureType aType,
const ScrollableLayerGuid& aGuid,
LayoutDeviceCoord aSpanChange,
Modifiers aModifiers);
void CancelAutoscrollInProcess(const ScrollableLayerGuid& aScrollId);
void CancelAutoscrollCrossProcess(const ScrollableLayerGuid& aScrollId);