Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Backed out changeset 1c7162137f66 (bug 1289650)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archaeopteryx committed Aug 24, 2016
1 parent 59683be commit be8d851
Show file tree
Hide file tree
Showing 23 changed files with 199 additions and 216 deletions.
20 changes: 13 additions & 7 deletions dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,19 @@ ContentChild::AllocPGMPServiceChild(mozilla::ipc::Transport* aTransport,
return GMPServiceChild::Create(aTransport, aOtherProcess);
}

PAPZChild*
ContentChild::AllocPAPZChild(const TabId& aTabId)
{
return APZChild::Create(aTabId);
}

bool
ContentChild::DeallocPAPZChild(PAPZChild* aActor)
{
delete aActor;
return true;
}

bool
ContentChild::RecvInitCompositor(Endpoint<PCompositorBridgeChild>&& aEndpoint)
{
Expand Down Expand Up @@ -1378,13 +1391,6 @@ ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker)
return true;
}

bool
ContentChild::RecvNotifyLayerAllocated(const dom::TabId& aTabId, const uint64_t& aLayersId)
{
APZChild* apz = APZChild::Create(aTabId);
return CompositorBridgeChild::Get()->SendPAPZConstructor(apz, aLayersId);
}

bool
ContentChild::RecvSpeakerManagerNotify()
{
Expand Down
7 changes: 5 additions & 2 deletions dom/ipc/ContentChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ class ContentChild final : public PContentChild
AllocPGMPServiceChild(mozilla::ipc::Transport* transport,
base::ProcessId otherProcess) override;

PAPZChild*
AllocPAPZChild(const TabId& aTabId) override;
bool
DeallocPAPZChild(PAPZChild* aActor) override;

bool
RecvInitCompositor(Endpoint<PCompositorBridgeChild>&& aEndpoint) override;
bool
Expand Down Expand Up @@ -392,8 +397,6 @@ class ContentChild final : public PContentChild

virtual bool RecvSetConnectivity(const bool& connectivity) override;

virtual bool RecvNotifyLayerAllocated(const dom::TabId& aTabId, const uint64_t& aLayersId) override;

virtual bool RecvSpeakerManagerNotify() override;

virtual bool RecvBidiKeyboardNotify(const bool& isLangRTL,
Expand Down
17 changes: 16 additions & 1 deletion dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ ContentParent::AllocateLayerTreeId(ContentParent* aContent,
return false;
}

return aContent->SendNotifyLayerAllocated(aTabId, *aId);
return gpu->UpdateRemoteContentController(*aId, aContent, aTabId, aTopLevel);
}

bool
Expand Down Expand Up @@ -2897,6 +2897,21 @@ ContentParent::AllocPGMPServiceParent(mozilla::ipc::Transport* aTransport,
return GMPServiceParent::Create(aTransport, aOtherProcess);
}

PAPZParent*
ContentParent::AllocPAPZParent(const TabId& aTabId)
{
// The PAPZParent should just be created in the main process and then an IPDL
// constructor message sent to hook it up.
MOZ_CRASH("This shouldn't be called");
return nullptr;
}

bool
ContentParent::DeallocPAPZParent(PAPZParent* aActor)
{
return true;
}

PBackgroundParent*
ContentParent::AllocPBackgroundParent(Transport* aTransport,
ProcessId aOtherProcess)
Expand Down
5 changes: 5 additions & 0 deletions dom/ipc/ContentParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,11 @@ class ContentParent final : public PContentParent
AllocPGMPServiceParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess) override;

PAPZParent*
AllocPAPZParent(const TabId& aTabId) override;
bool
DeallocPAPZParent(PAPZParent* aActor) override;

PSharedBufferManagerParent*
AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTranport,
base::ProcessId aOtherProcess) override;
Expand Down
9 changes: 4 additions & 5 deletions dom/ipc/PContent.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 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 protocol PAPZ;
include protocol PBackground;
include protocol PBlob;
include protocol PBluetooth;
Expand Down Expand Up @@ -389,6 +390,7 @@ prio(normal upto urgent) sync protocol PContent
parent opens PGMPService;
child opens PBackground;

manages PAPZ;
manages PBlob;
manages PBluetooth;
manages PBrowser;
Expand Down Expand Up @@ -482,11 +484,6 @@ child:
async PMemoryReportRequest(uint32_t generation, bool anonymize,
bool minimizeMemoryUsage, MaybeFileDesc DMDFile);

/**
* Sent to notify that aTabId has been allocated aLayersId
*/
async NotifyLayerAllocated(TabId aTabId, uint64_t aLayersId);

async SpeakerManagerNotify();

/**
Expand All @@ -507,6 +504,8 @@ child:

async PTestShell();

async PAPZ(TabId tabId);

async RegisterChrome(ChromePackage[] packages, SubstitutionMapping[] substitutions,
OverrideMapping[] overrides, nsCString locale, bool reset);
async RegisterChromeItem(ChromeRegistryItem item);
Expand Down
13 changes: 13 additions & 0 deletions gfx/ipc/GPUProcessManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,19 @@ GPUProcessManager::SwapLayerTreeObservers(uint64_t aLayer, uint64_t aOtherLayer)
CompositorBridgeParent::SwapLayerTreeObservers(aLayer, aOtherLayer);
}

bool
GPUProcessManager::UpdateRemoteContentController(uint64_t aLayersId,
dom::ContentParent* aContentParent,
const dom::TabId& aTabId,
dom::TabParent* aBrowserParent)
{
return CompositorBridgeParent::UpdateRemoteContentController(
aLayersId,
aContentParent,
aTabId,
aBrowserParent);
}

void
GPUProcessManager::EnsureVsyncIOThread()
{
Expand Down
12 changes: 12 additions & 0 deletions gfx/ipc/GPUProcessManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ class GPUProcessManager final : public GPUProcessHost::Listener
void RequestNotifyLayerTreeCleared(uint64_t aLayersId, CompositorUpdateObserver* aObserver);
void SwapLayerTreeObservers(uint64_t aLayer, uint64_t aOtherLayer);

// Creates a new RemoteContentController for aTabId. Should only be called on
// the main thread.
//
// aLayersId The layers id for the browser corresponding to aTabId.
// aContentParent The ContentParent for the process that the TabChild for
// aTabId lives in.
// aBrowserParent The toplevel TabParent for aTabId.
bool UpdateRemoteContentController(uint64_t aLayersId,
dom::ContentParent* aContentParent,
const dom::TabId& aTabId,
dom::TabParent* aBrowserParent);

void OnProcessLaunchComplete(GPUProcessHost* aHost) override;
void OnProcessUnexpectedShutdown(GPUProcessHost* aHost) override;

Expand Down
18 changes: 7 additions & 11 deletions gfx/layers/apz/public/GeckoContentController.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
#include "mozilla/EventForwards.h" // for Modifiers
#include "nsISupportsImpl.h"
#include "ThreadSafeRefcountingWithMainThreadDestruction.h"

namespace mozilla {

Expand All @@ -22,7 +23,12 @@ namespace layers {
class GeckoContentController
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GeckoContentController)
/**
* At least one class deriving from GeckoContentController needs to do
* synchronous cleanup on the main thread, so we use
* NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION.
*/
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(GeckoContentController)

/**
* Requests a paint of the given FrameMetrics |aFrameMetrics| from Gecko.
Expand Down Expand Up @@ -65,16 +71,6 @@ class GeckoContentController
*/
virtual void PostDelayedTask(already_AddRefed<Runnable> aRunnable, int aDelayMs) = 0;

/**
* Returns true if we are currently on the thread that can send repaint requests.
*/
virtual bool IsRepaintThread() = 0;

/**
* Runs the given task on the "repaint" thread.
*/
virtual void DispatchToRepaintThread(already_AddRefed<Runnable> aTask) = 0;

/**
* APZ uses |FrameMetrics::mCompositionBounds| for hit testing. Sometimes,
* widget code has knowledge of a touch-sensitive region that should
Expand Down
4 changes: 2 additions & 2 deletions gfx/layers/apz/src/APZCTreeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ APZCTreeManager::FlushApzRepaints(uint64_t aLayersId)
const CompositorBridgeParent::LayerTreeState* state =
CompositorBridgeParent::GetIndirectShadowTree(aLayersId);
MOZ_ASSERT(state && state->mController);
state->mController->DispatchToRepaintThread(NewRunnableMethod(
state->mController, &GeckoContentController::NotifyFlushComplete));
NS_DispatchToMainThread(NewRunnableMethod(
state->mController, &GeckoContentController::NotifyFlushComplete));
}

nsEventStatus
Expand Down
32 changes: 12 additions & 20 deletions gfx/layers/apz/src/AsyncPanZoomController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2819,23 +2819,19 @@ int32_t AsyncPanZoomController::GetLastTouchIdentifier() const {
}

void AsyncPanZoomController::RequestContentRepaint(bool aUserAction) {
// Reinvoke this method on the repaint thread if it's not there already. It's
// Reinvoke this method on the main thread if it's not there already. It's
// important to do this before the call to CalculatePendingDisplayPort, so
// that CalculatePendingDisplayPort uses the most recent available version of
// mFrameMetrics, just before the paint request is dispatched to content.
RefPtr<GeckoContentController> controller = GetGeckoContentController();
if (!controller) {
return;
}
if (!controller->IsRepaintThread()) {
if (!NS_IsMainThread()) {
// use the local variable to resolve the function overload.
auto func = static_cast<void (AsyncPanZoomController::*)(bool)>
(&AsyncPanZoomController::RequestContentRepaint);
controller->DispatchToRepaintThread(NewRunnableMethod<bool>(this, func, aUserAction));
NS_DispatchToMainThread(NewRunnableMethod<bool>(this, func, aUserAction));
return;
}

MOZ_ASSERT(controller->IsRepaintThread());
MOZ_ASSERT(NS_IsMainThread());

ReentrantMonitorAutoEnter lock(mMonitor);
ParentLayerPoint velocity = GetVelocityVector();
Expand All @@ -2861,11 +2857,7 @@ void
AsyncPanZoomController::RequestContentRepaint(const FrameMetrics& aFrameMetrics,
const ParentLayerPoint& aVelocity)
{
RefPtr<GeckoContentController> controller = GetGeckoContentController();
if (!controller) {
return;
}
MOZ_ASSERT(controller->IsRepaintThread());
MOZ_ASSERT(NS_IsMainThread());

// If we're trying to paint what we already think is painted, discard this
// request since it's a pointless paint.
Expand All @@ -2889,6 +2881,11 @@ AsyncPanZoomController::RequestContentRepaint(const FrameMetrics& aFrameMetrics,
return;
}

RefPtr<GeckoContentController> controller = GetGeckoContentController();
if (!controller) {
return;
}

APZC_LOG_FM(aFrameMetrics, "%p requesting content repaint", this);
{ // scope lock
MutexAutoLock lock(mCheckerboardEventLock);
Expand Down Expand Up @@ -3589,18 +3586,13 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect, const uint32_t aFlags) {
endZoomToMetrics.SetUseDisplayPortMargins(true);
endZoomToMetrics.SetPaintRequestTime(TimeStamp::Now());
endZoomToMetrics.SetRepaintDrivenByUserAction(true);

RefPtr<GeckoContentController> controller = GetGeckoContentController();
if (!controller) {
return;
}
if (controller->IsRepaintThread()) {
if (NS_IsMainThread()) {
RequestContentRepaint(endZoomToMetrics, velocity);
} else {
// use a local var to resolve the function overload
auto func = static_cast<void (AsyncPanZoomController::*)(const FrameMetrics&, const ParentLayerPoint&)>
(&AsyncPanZoomController::RequestContentRepaint);
controller->DispatchToRepaintThread(
NS_DispatchToMainThread(
NewRunnableMethod<FrameMetrics, ParentLayerPoint>(
this, func, endZoomToMetrics, velocity));
}
Expand Down
6 changes: 0 additions & 6 deletions gfx/layers/apz/test/gtest/APZTestCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ class MockContentController : public GeckoContentController {
void PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs) {
RefPtr<Runnable> task = aTask;
}
bool IsRepaintThread() {
return NS_IsMainThread();
}
void DispatchToRepaintThread(already_AddRefed<Runnable> aTask) {
NS_DispatchToMainThread(Move(aTask));
}
MOCK_METHOD3(NotifyAPZStateChange, void(const ScrollableLayerGuid& aGuid, APZStateChange aChange, int aArg));
MOCK_METHOD0(NotifyFlushComplete, void());
};
Expand Down
17 changes: 2 additions & 15 deletions gfx/layers/apz/util/ChromeProcessController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ChromeProcessController::InitializeRoot()
void
ChromeProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
{
MOZ_ASSERT(IsRepaintThread());
MOZ_ASSERT(NS_IsMainThread());

FrameMetrics metrics = aFrameMetrics;
if (metrics.IsRootContent()) {
Expand All @@ -66,18 +66,6 @@ ChromeProcessController::PostDelayedTask(already_AddRefed<Runnable> aTask, int a
MessageLoop::current()->PostDelayedTask(Move(aTask), aDelayMs);
}

bool
ChromeProcessController::IsRepaintThread()
{
return NS_IsMainThread();
}

void
ChromeProcessController::DispatchToRepaintThread(already_AddRefed<Runnable> aTask)
{
NS_DispatchToMainThread(Move(aTask));
}

void
ChromeProcessController::Destroy()
{
Expand Down Expand Up @@ -236,7 +224,6 @@ ChromeProcessController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& a
void
ChromeProcessController::NotifyFlushComplete()
{
MOZ_ASSERT(IsRepaintThread());

MOZ_ASSERT(NS_IsMainThread());
APZCCallbackHelper::NotifyFlushComplete(GetPresShell());
}
2 changes: 0 additions & 2 deletions gfx/layers/apz/util/ChromeProcessController.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class ChromeProcessController : public mozilla::layers::GeckoContentController
// GeckoContentController interface
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) override;
virtual void PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs) override;
virtual bool IsRepaintThread() override;
virtual void DispatchToRepaintThread(already_AddRefed<Runnable> aTask) override;
virtual void HandleTap(TapType aType,
const mozilla::LayoutDevicePoint& aPoint,
Modifiers aModifiers,
Expand Down
14 changes: 2 additions & 12 deletions gfx/layers/ipc/APZChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,11 @@ APZChild::RecvHandleTap(const TapType& aType,
const uint64_t& aInputBlockId,
const bool& aCallTakeFocusForClickFromTap)
{
mBrowser->HandleTap(aType, aPoint - mBrowser->GetChromeDisplacement(), aModifiers, aGuid,
mBrowser->HandleTap(aType, aPoint, aModifiers, aGuid,
aInputBlockId, aCallTakeFocusForClickFromTap);
return true;
}

bool
APZChild::RecvNotifyMozMouseScrollEvent(const uint64_t& aLayersId,
const ViewID& aScrollId,
const nsString& aEvent)
{
if (mBrowser) {
mBrowser->RecvMouseScrollTestEvent(aLayersId, aScrollId, aEvent);
}
return true;
}

bool
APZChild::RecvNotifyAPZStateChange(const ViewID& aViewId,
const APZStateChange& aChange,
Expand Down Expand Up @@ -150,6 +139,7 @@ APZChild::RecvDestroy()
mBrowser->SetAPZChild(nullptr);
mBrowser = nullptr;
}
PAPZChild::Send__delete__(this);
return true;
}

Expand Down
4 changes: 0 additions & 4 deletions gfx/layers/ipc/APZChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ class APZChild final : public PAPZChild
const uint64_t& aInputBlockId,
const bool& aCallTakeFocusForClickFromTap) override;

bool RecvNotifyMozMouseScrollEvent(const uint64_t& aLayersId,
const ViewID& aScrollId,
const nsString& aEvent) override;

bool RecvNotifyAPZStateChange(const ViewID& aViewId,
const APZStateChange& aChange,
const int& aArg) override;
Expand Down
Loading

0 comments on commit be8d851

Please sign in to comment.