Bug 1478016 - Add a strongly-typed LayersObserverEpoch type. r=mattwoodrow

MozReview-Commit-ID: 6fELexXRYeV

--HG--
extra : rebase_source : 0eb028ee9b98199d18421f7ff28433189940fdca
This commit is contained in:
Kartikaya Gupta 2018-07-30 09:24:50 -04:00
parent 1891f8a1f7
commit 3faf3e38d9
31 changed files with 149 additions and 107 deletions

View File

@ -5542,7 +5542,7 @@ ContentParent::SendGetFilesResponseAndForget(const nsID& aUUID,
void
ContentParent::PaintTabWhileInterruptingJS(TabParent* aTabParent,
bool aForceRepaint,
uint64_t aLayerObserverEpoch)
const layers::LayersObserverEpoch& aEpoch)
{
if (!mHangMonitorActor) {
return;
@ -5550,7 +5550,7 @@ ContentParent::PaintTabWhileInterruptingJS(TabParent* aTabParent,
ProcessHangMonitor::PaintWhileInterruptingJS(mHangMonitorActor,
aTabParent,
aForceRepaint,
aLayerObserverEpoch);
aEpoch);
}
void

View File

@ -653,7 +653,9 @@ public:
nsTArray<nsCString>* aResults) override;
// Use the PHangMonitor channel to ask the child to repaint a tab.
void PaintTabWhileInterruptingJS(TabParent* aTabParent, bool aForceRepaint, uint64_t aLayerObserverEpoch);
void PaintTabWhileInterruptingJS(TabParent* aTabParent,
bool aForceRepaint,
const layers::LayersObserverEpoch& aEpoch);
// This function is called when we are about to load a document from an
// HTTP(S), FTP or wyciwyg channel for a content process. It is a useful

View File

@ -42,6 +42,7 @@ using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h";
using struct mozilla::layers::ZoomConstraints from "FrameMetrics.h";
using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h";
using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h";
using mozilla::layers::MaybeZoomConstraints from "FrameMetrics.h";
using mozilla::layers::GeckoContentController::TapType from "mozilla/layers/GeckoContentController.h";
using FrameMetrics::ViewID from "FrameMetrics.h";
@ -542,7 +543,7 @@ parent:
/**
* Child informs the parent that the layer tree is already available.
*/
async PaintWhileInterruptingJSNoOp(uint64_t aLayerObserverEpoch);
async PaintWhileInterruptingJSNoOp(LayersObserverEpoch aEpoch);
/**
* Sent by the child to the parent to inform it that an update to the
@ -752,12 +753,12 @@ child:
* @param aForceRepaint
* True if the child should force a paint even if it's already
* visible.
* @param aLayerObserverEpoch
* @param aEpoch
* The layer observer epoch for this activation. This message should be
* ignored if this epoch has already been observed (via
* PaintWhileInterruptingJS).
*/
async RenderLayers(bool aEnabled, bool aForceRepaint, uint64_t aLayerObserverEpoch);
async RenderLayers(bool aEnabled, bool aForceRepaint, LayersObserverEpoch aEpoch);
/**
* Notify the child that it shouldn't paint the offscreen displayport.

View File

@ -7,6 +7,7 @@
using base::ProcessId from "base/process.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h";
namespace mozilla {
@ -41,7 +42,7 @@ child:
async BeginStartingDebugger();
async EndStartingDebugger();
async PaintWhileInterruptingJS(TabId tabId, bool forceRepaint, uint64_t aLayerObserverEpoch);
async PaintWhileInterruptingJS(TabId tabId, bool forceRepaint, LayersObserverEpoch aEpoch);
};
} // namespace mozilla

View File

@ -96,7 +96,7 @@ class HangMonitorChild
void ClearHang();
void ClearHangAsync();
void ClearPaintWhileInterruptingJS(uint64_t aLayerObserverEpoch);
void ClearPaintWhileInterruptingJS(const LayersObserverEpoch& aEpoch);
// MaybeStartPaintWhileInterruptingJS will notify the background hang monitor of activity
// if this is the first time calling it since ClearPaintWhileInterruptingJS. It should be
@ -110,7 +110,7 @@ class HangMonitorChild
mozilla::ipc::IPCResult RecvPaintWhileInterruptingJS(const TabId& aTabId,
const bool& aForceRepaint,
const uint64_t& aLayerObserverEpoch) override;
const LayersObserverEpoch& aEpoch) override;
void ActorDestroy(ActorDestroyReason aWhy) override;
@ -148,7 +148,7 @@ class HangMonitorChild
bool mPaintWhileInterruptingJS;
bool mPaintWhileInterruptingJSForce;
TabId mPaintWhileInterruptingJSTab;
MOZ_INIT_OUTSIDE_CTOR uint64_t mPaintWhileInterruptingJSEpoch;
MOZ_INIT_OUTSIDE_CTOR LayersObserverEpoch mPaintWhileInterruptingJSEpoch;
JSContext* mContext;
bool mShutdownDone;
@ -236,7 +236,7 @@ public:
void PaintWhileInterruptingJS(dom::TabParent* aTabParent,
bool aForceRepaint,
uint64_t aLayerObserverEpoch);
const LayersObserverEpoch& aEpoch);
void TerminateScript(bool aTerminateGlobal);
void BeginStartingDebugger();
@ -267,7 +267,7 @@ private:
void ClearHangNotification();
void PaintWhileInterruptingJSOnThread(TabId aTabId, bool aForceRepaint, uint64_t aLayerObserverEpoch);
void PaintWhileInterruptingJSOnThread(TabId aTabId, bool aForceRepaint, const LayersObserverEpoch& aEpoch);
void ShutdownOnThread();
@ -338,7 +338,7 @@ HangMonitorChild::InterruptCallback()
bool paintWhileInterruptingJS;
bool paintWhileInterruptingJSForce;
TabId paintWhileInterruptingJSTab;
uint64_t paintWhileInterruptingJSEpoch;
LayersObserverEpoch paintWhileInterruptingJSEpoch;
{
MonitorAutoLock lock(mMonitor);
@ -434,7 +434,7 @@ HangMonitorChild::RecvEndStartingDebugger()
mozilla::ipc::IPCResult
HangMonitorChild::RecvPaintWhileInterruptingJS(const TabId& aTabId,
const bool& aForceRepaint,
const uint64_t& aLayerObserverEpoch)
const LayersObserverEpoch& aEpoch)
{
MOZ_RELEASE_ASSERT(IsOnThread());
@ -444,7 +444,7 @@ HangMonitorChild::RecvPaintWhileInterruptingJS(const TabId& aTabId,
mPaintWhileInterruptingJS = true;
mPaintWhileInterruptingJSForce = aForceRepaint;
mPaintWhileInterruptingJSTab = aTabId;
mPaintWhileInterruptingJSEpoch = aLayerObserverEpoch;
mPaintWhileInterruptingJSEpoch = aEpoch;
}
JS_RequestInterruptCallback(mContext);
@ -464,7 +464,7 @@ HangMonitorChild::MaybeStartPaintWhileInterruptingJS()
}
void
HangMonitorChild::ClearPaintWhileInterruptingJS(uint64_t aLayerObserverEpoch)
HangMonitorChild::ClearPaintWhileInterruptingJS(const LayersObserverEpoch& aEpoch)
{
// See Bug 1449662. The body of this function other than assertions
// has been temporarily removed to diagnose a tab switch spinner
@ -687,31 +687,30 @@ HangMonitorParent::ShutdownOnThread()
void
HangMonitorParent::PaintWhileInterruptingJS(dom::TabParent* aTab,
bool aForceRepaint,
uint64_t aLayerObserverEpoch)
const LayersObserverEpoch& aEpoch)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
if (sShouldPaintWhileInterruptingJS) {
TabId id = aTab->GetTabId();
Dispatch(NewNonOwningRunnableMethod<TabId, bool, uint64_t>(
Dispatch(NewNonOwningRunnableMethod<TabId, bool, LayersObserverEpoch>(
"HangMonitorParent::PaintWhileInterruptingJSOnThread",
this,
&HangMonitorParent::PaintWhileInterruptingJSOnThread,
id,
aForceRepaint,
aLayerObserverEpoch));
aEpoch));
}
}
void
HangMonitorParent::PaintWhileInterruptingJSOnThread(TabId aTabId,
bool aForceRepaint,
uint64_t aLayerObserverEpoch)
const LayersObserverEpoch& aEpoch)
{
MOZ_RELEASE_ASSERT(IsOnThread());
if (mIPCOpen) {
Unused << SendPaintWhileInterruptingJS(aTabId, aForceRepaint,
aLayerObserverEpoch);
Unused << SendPaintWhileInterruptingJS(aTabId, aForceRepaint, aEpoch);
}
}
@ -1386,21 +1385,21 @@ ProcessHangMonitor::ClearHang()
ProcessHangMonitor::PaintWhileInterruptingJS(PProcessHangMonitorParent* aParent,
dom::TabParent* aTabParent,
bool aForceRepaint,
uint64_t aLayerObserverEpoch)
const layers::LayersObserverEpoch& aEpoch)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
auto parent = static_cast<HangMonitorParent*>(aParent);
parent->PaintWhileInterruptingJS(aTabParent, aForceRepaint, aLayerObserverEpoch);
parent->PaintWhileInterruptingJS(aTabParent, aForceRepaint, aEpoch);
}
/* static */ void
ProcessHangMonitor::ClearPaintWhileInterruptingJS(uint64_t aLayerObserverEpoch)
ProcessHangMonitor::ClearPaintWhileInterruptingJS(const layers::LayersObserverEpoch& aEpoch)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(XRE_IsContentProcess());
if (HangMonitorChild* child = HangMonitorChild::Get()) {
child->ClearPaintWhileInterruptingJS(aLayerObserverEpoch);
child->ClearPaintWhileInterruptingJS(aEpoch);
}
}

View File

@ -24,6 +24,10 @@ class ContentParent;
class TabParent;
} // namespace dom
namespace layers {
struct LayersObserverEpoch;
} // namespace layers
class PProcessHangMonitorParent;
class ProcessHangMonitor final
@ -48,8 +52,8 @@ class ProcessHangMonitor final
static void PaintWhileInterruptingJS(PProcessHangMonitorParent* aParent,
dom::TabParent* aTab,
bool aForceRepaint,
uint64_t aLayerObserverEpoch);
static void ClearPaintWhileInterruptingJS(uint64_t aLayerObserverEpoch);
const layers::LayersObserverEpoch& aEpoch);
static void ClearPaintWhileInterruptingJS(const layers::LayersObserverEpoch& aEpoch);
static void MaybeStartPaintWhileInterruptingJS();
enum SlowScriptAction {

View File

@ -419,7 +419,7 @@ TabChild::TabChild(nsIContentChild* aManager,
, mDidLoadURLInit(false)
, mAwaitingLA(false)
, mSkipKeyPress(false)
, mLayerObserverEpoch(1)
, mLayersObserverEpoch{1}
#if defined(XP_WIN) && defined(ACCESSIBILITY)
, mNativeWindowHandle(0)
#endif
@ -430,7 +430,7 @@ TabChild::TabChild(nsIContentChild* aManager,
, mPendingDocShellReceivedMessage(false)
, mPendingRenderLayers(false)
, mPendingRenderLayersReceivedMessage(false)
, mPendingLayerObserverEpoch(0)
, mPendingLayersObserverEpoch{0}
, mPendingDocShellBlockers(0)
, mWidgetNativeData(0)
{
@ -2551,7 +2551,7 @@ TabChild::RemovePendingDocShellBlocker()
mPendingRenderLayersReceivedMessage = false;
RecvRenderLayers(mPendingRenderLayers,
false /* aForceRepaint */,
mPendingLayerObserverEpoch);
mPendingLayersObserverEpoch);
}
}
@ -2582,12 +2582,12 @@ TabChild::RecvSetDocShellIsActive(const bool& aIsActive)
}
mozilla::ipc::IPCResult
TabChild::RecvRenderLayers(const bool& aEnabled, const bool& aForceRepaint, const uint64_t& aLayerObserverEpoch)
TabChild::RecvRenderLayers(const bool& aEnabled, const bool& aForceRepaint, const layers::LayersObserverEpoch& aEpoch)
{
if (mPendingDocShellBlockers > 0) {
mPendingRenderLayersReceivedMessage = true;
mPendingRenderLayers = aEnabled;
mPendingLayerObserverEpoch = aLayerObserverEpoch;
mPendingLayersObserverEpoch = aEpoch;
return IPC_OK();
}
@ -2595,10 +2595,10 @@ TabChild::RecvRenderLayers(const bool& aEnabled, const bool& aForceRepaint, cons
// monitor channel and the PContent channel, we have an ordering problem. This
// code ensures that we respect the order in which the requests were made and
// ignore stale requests.
if (mLayerObserverEpoch >= aLayerObserverEpoch) {
if (mLayersObserverEpoch >= aEpoch) {
return IPC_OK();
}
mLayerObserverEpoch = aLayerObserverEpoch;
mLayersObserverEpoch = aEpoch;
auto clearPaintWhileInterruptingJS = MakeScopeExit([&] {
// We might force a paint, or we might already have painted and this is a
@ -2607,7 +2607,7 @@ TabChild::RecvRenderLayers(const bool& aEnabled, const bool& aForceRepaint, cons
// been a request to force paint. This is so that the BackgroundHangMonitor
// for force painting can be made to wait again.
if (aEnabled) {
ProcessHangMonitor::ClearPaintWhileInterruptingJS(mLayerObserverEpoch);
ProcessHangMonitor::ClearPaintWhileInterruptingJS(mLayersObserverEpoch);
}
});
@ -2623,7 +2623,7 @@ TabChild::RecvRenderLayers(const bool& aEnabled, const bool& aForceRepaint, cons
// We send the current layer observer epoch to the compositor so that
// TabParent knows whether a layer update notification corresponds to the
// latest RecvRenderLayers request that was made.
lm->SetLayerObserverEpoch(mLayerObserverEpoch);
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
}
if (aEnabled) {
@ -2632,7 +2632,7 @@ TabChild::RecvRenderLayers(const bool& aEnabled, const bool& aForceRepaint, cons
// notification to fire in the parent (so that it knows that the child has
// updated its epoch). PaintWhileInterruptingJSNoOp does that.
if (IPCOpen()) {
Unused << SendPaintWhileInterruptingJSNoOp(mLayerObserverEpoch);
Unused << SendPaintWhileInterruptingJSNoOp(mLayersObserverEpoch);
return IPC_OK();
}
}
@ -2838,7 +2838,7 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden
InitAPZState();
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
MOZ_ASSERT(lm);
lm->SetLayerObserverEpoch(mLayerObserverEpoch);
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
} else {
NS_WARNING("Fallback to BasicLayerManager");
mLayersConnected = Some(false);
@ -3233,7 +3233,7 @@ TabChild::ReinitRendering()
InitAPZState();
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
MOZ_ASSERT(lm);
lm->SetLayerObserverEpoch(mLayerObserverEpoch);
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
nsCOMPtr<nsIDocument> doc(GetDocument());
doc->NotifyLayerManagerRecreated();
@ -3466,7 +3466,7 @@ TabChild::GetOuterRect()
}
void
TabChild::PaintWhileInterruptingJS(uint64_t aLayerObserverEpoch,
TabChild::PaintWhileInterruptingJS(const layers::LayersObserverEpoch& aEpoch,
bool aForceRepaint)
{
if (!IPCOpen() || !mPuppetWidget || !mPuppetWidget->HasLayerManager()) {
@ -3476,7 +3476,7 @@ TabChild::PaintWhileInterruptingJS(uint64_t aLayerObserverEpoch,
}
nsAutoScriptBlocker scriptBlocker;
RecvRenderLayers(true /* aEnabled */, aForceRepaint, aLayerObserverEpoch);
RecvRenderLayers(true /* aEnabled */, aForceRepaint, aEpoch);
}
void

View File

@ -656,10 +656,10 @@ public:
const uint32_t& aFlags);
// Request that the docshell be marked as active.
void PaintWhileInterruptingJS(uint64_t aLayerObserverEpoch,
void PaintWhileInterruptingJS(const layers::LayersObserverEpoch& aEpoch,
bool aForceRepaint);
uint64_t LayerObserverEpoch() const { return mLayerObserverEpoch; }
layers::LayersObserverEpoch LayersObserverEpoch() const { return mLayersObserverEpoch; }
#if defined(XP_WIN) && defined(ACCESSIBILITY)
uintptr_t GetNativeWindowHandle() const { return mNativeWindowHandle; }
@ -732,7 +732,7 @@ protected:
virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive) override;
virtual mozilla::ipc::IPCResult RecvRenderLayers(const bool& aEnabled, const bool& aForce, const uint64_t& aLayerObserverEpoch) override;
virtual mozilla::ipc::IPCResult RecvRenderLayers(const bool& aEnabled, const bool& aForce, const layers::LayersObserverEpoch& aEpoch) override;
virtual mozilla::ipc::IPCResult RecvNavigateByKey(const bool& aForward,
const bool& aForDocumentNavigation) override;
@ -895,7 +895,7 @@ private:
RefPtr<layers::IAPZCTreeManager> mApzcTreeManager;
// The most recently seen layer observer epoch in RecvSetDocShellIsActive.
uint64_t mLayerObserverEpoch;
layers::LayersObserverEpoch mLayersObserverEpoch;
#if defined(XP_WIN) && defined(ACCESSIBILITY)
// The handle associated with the native window that contains this tab
@ -918,7 +918,7 @@ private:
bool mPendingDocShellReceivedMessage;
bool mPendingRenderLayers;
bool mPendingRenderLayersReceivedMessage;
uint64_t mPendingLayerObserverEpoch;
layers::LayersObserverEpoch mPendingLayersObserverEpoch;
// When mPendingDocShellBlockers is greater than 0, the DocShell is blocked,
// and once it reaches 0, it is no longer blocked.
uint32_t mPendingDocShellBlockers;

View File

@ -169,7 +169,7 @@ TabParent::TabParent(nsIContentParent* aManager,
#ifdef DEBUG
, mActiveSupressDisplayportCount(0)
#endif
, mLayerTreeEpoch(1)
, mLayerTreeEpoch{1}
, mPreserveLayers(false)
, mRenderLayers(true)
, mHasLayers(false)
@ -2897,7 +2897,7 @@ TabParent::SetRenderLayers(bool aEnabled)
// event will not naturally arrive, which can confuse the front-end
// layer. So we fire the event here.
RefPtr<TabParent> self = this;
uint64_t epoch = mLayerTreeEpoch;
LayersObserverEpoch epoch = mLayerTreeEpoch;
NS_DispatchToMainThread(NS_NewRunnableFunction(
"dom::TabParent::RenderLayers",
[self, epoch] () {
@ -2948,7 +2948,7 @@ TabParent::SetRenderLayersInternal(bool aEnabled, bool aForceRepaint)
{
// Increment the epoch so that layer tree updates from previous
// RenderLayers requests are ignored.
mLayerTreeEpoch++;
mLayerTreeEpoch = mLayerTreeEpoch.Next();
Unused << SendRenderLayers(aEnabled, aForceRepaint, mLayerTreeEpoch);
@ -3059,7 +3059,7 @@ TabParent::GetHasBeforeUnload(bool* aResult)
}
void
TabParent::LayerTreeUpdate(uint64_t aEpoch, bool aActive)
TabParent::LayerTreeUpdate(const LayersObserverEpoch& aEpoch, bool aActive)
{
// Ignore updates from old epochs. They might tell us that layers are
// available when we've already sent a message to clear them. We can't trust
@ -3089,12 +3089,12 @@ TabParent::LayerTreeUpdate(uint64_t aEpoch, bool aActive)
}
mozilla::ipc::IPCResult
TabParent::RecvPaintWhileInterruptingJSNoOp(const uint64_t& aLayerObserverEpoch)
TabParent::RecvPaintWhileInterruptingJSNoOp(const LayersObserverEpoch& aEpoch)
{
// We sent a PaintWhileInterruptingJS message when layers were already visible. In this
// case, we should act as if an update occurred even though we already have
// the layers.
LayerTreeUpdate(aLayerObserverEpoch, true);
LayerTreeUpdate(aEpoch, true);
return IPC_OK();
}

View File

@ -558,7 +558,7 @@ public:
bool SendLoadRemoteScript(const nsString& aURL,
const bool& aRunInGlobalScope);
void LayerTreeUpdate(uint64_t aEpoch, bool aActive);
void LayerTreeUpdate(const LayersObserverEpoch& aEpoch, bool aActive);
virtual mozilla::ipc::IPCResult
RecvInvokeDragSession(nsTArray<IPCDataTransfer>&& aTransfers,
@ -620,7 +620,7 @@ protected:
virtual mozilla::ipc::IPCResult RecvRemoteIsReadyToHandleInputEvents() override;
virtual mozilla::ipc::IPCResult RecvPaintWhileInterruptingJSNoOp(const uint64_t& aLayerObserverEpoch) override;
virtual mozilla::ipc::IPCResult RecvPaintWhileInterruptingJSNoOp(const LayersObserverEpoch& aEpoch) override;
virtual mozilla::ipc::IPCResult RecvSetDimensions(const uint32_t& aFlags,
const int32_t& aX, const int32_t& aY,
@ -757,7 +757,7 @@ private:
static void RemoveTabParentFromTable(layers::LayersId aLayersId);
uint64_t mLayerTreeEpoch;
LayersObserverEpoch mLayerTreeEpoch;
// If this flag is set, then the tab's layers will be preserved even when
// the tab's docshell is inactive.

View File

@ -686,7 +686,7 @@ public:
return count;
}
virtual void SetLayerObserverEpoch(uint64_t aLayerObserverEpoch) {}
virtual void SetLayersObserverEpoch(LayersObserverEpoch aEpoch) {}
virtual void DidComposite(TransactionId aTransactionId,
const mozilla::TimeStamp& aCompositeStart,

View File

@ -139,6 +139,34 @@ struct TransactionId {
}
};
struct LayersObserverEpoch {
uint64_t mId;
MOZ_MUST_USE LayersObserverEpoch Next() const {
return LayersObserverEpoch{mId + 1};
}
bool operator<=(const LayersObserverEpoch& aOther) const
{
return mId <= aOther.mId;
}
bool operator>=(const LayersObserverEpoch& aOther) const
{
return mId >= aOther.mId;
}
bool operator==(const LayersObserverEpoch& aOther) const
{
return mId == aOther.mId;
}
bool operator!=(const LayersObserverEpoch& aOther) const
{
return mId != aOther.mId;
}
};
enum class LayersBackend : int8_t {
LAYERS_NONE = 0,
LAYERS_BASIC,

View File

@ -932,9 +932,9 @@ ClientLayerManager::AsyncPanZoomEnabled() const
}
void
ClientLayerManager::SetLayerObserverEpoch(uint64_t aLayerObserverEpoch)
ClientLayerManager::SetLayersObserverEpoch(LayersObserverEpoch aEpoch)
{
mForwarder->SetLayerObserverEpoch(aLayerObserverEpoch);
mForwarder->SetLayersObserverEpoch(aEpoch);
}
void

View File

@ -242,7 +242,7 @@ public:
bool AsyncPanZoomEnabled() const override;
virtual void SetLayerObserverEpoch(uint64_t aLayerObserverEpoch) override;
virtual void SetLayersObserverEpoch(LayersObserverEpoch aEpoch) override;
virtual void AddDidCompositeObserver(DidCompositeObserver* aObserver) override;
virtual void RemoveDidCompositeObserver(DidCompositeObserver* aObserver) override;

View File

@ -863,9 +863,9 @@ CompositorBridgeChild::RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessa
}
mozilla::ipc::IPCResult
CompositorBridgeChild::RecvObserveLayerUpdate(const LayersId& aLayersId,
const uint64_t& aEpoch,
const bool& aActive)
CompositorBridgeChild::RecvObserveLayersUpdate(const LayersId& aLayersId,
const LayersObserverEpoch& aEpoch,
const bool& aActive)
{
// This message is sent via the window compositor, not the tab compositor -
// however it still has a layers id.

View File

@ -316,9 +316,9 @@ private:
virtual mozilla::ipc::IPCResult
RecvRemotePaintIsReady() override;
mozilla::ipc::IPCResult RecvObserveLayerUpdate(const LayersId& aLayersId,
const uint64_t& aEpoch,
const bool& aActive) override;
mozilla::ipc::IPCResult RecvObserveLayersUpdate(const LayersId& aLayersId,
const LayersObserverEpoch& aEpoch,
const bool& aActive) override;
virtual mozilla::ipc::IPCResult
RecvNotifyWebRenderError(const WebRenderError& aError) override;

View File

@ -138,7 +138,7 @@ public:
mozilla::ipc::IPCResult Recv__delete__() override { return IPC_OK(); }
virtual void ObserveLayerUpdate(LayersId aLayersId, uint64_t aEpoch, bool aActive) = 0;
virtual void ObserveLayersUpdate(LayersId aLayersId, LayersObserverEpoch aEpoch, bool aActive) = 0;
virtual void DidComposite(LayersId aId, TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd) = 0;
@ -283,7 +283,7 @@ public:
PCompositorWidgetParent* AllocPCompositorWidgetParent(const CompositorWidgetInitData& aInitData) override;
bool DeallocPCompositorWidgetParent(PCompositorWidgetParent* aActor) override;
void ObserveLayerUpdate(LayersId aLayersId, uint64_t aEpoch, bool aActive) override { }
void ObserveLayersUpdate(LayersId aLayersId, LayersObserverEpoch aEpoch, bool aActive) override { }
/**
* This forces the is-first-paint flag to true. This is intended to

View File

@ -370,7 +370,7 @@ CrossProcessCompositorBridgeParent::ShadowLayersUpdated(
if (aLayerTree->ShouldParentObserveEpoch()) {
// Note that we send this through the window compositor, since this needs
// to reach the widget owning the tab.
Unused << state->mParent->SendObserveLayerUpdate(id, aLayerTree->GetChildEpoch(), true);
Unused << state->mParent->SendObserveLayersUpdate(id, aLayerTree->GetChildEpoch(), true);
}
aLayerTree->SetPendingTransactionId(aInfo.id(), aInfo.refreshStart(), aInfo.transactionStart(), aInfo.fwdTime());
@ -429,7 +429,7 @@ CrossProcessCompositorBridgeParent::NotifyClearCachedResources(LayerTransactionP
if (state && state->mParent) {
// Note that we send this through the window compositor, since this needs
// to reach the widget owning the tab.
Unused << state->mParent->SendObserveLayerUpdate(id, aLayerTree->GetChildEpoch(), false);
Unused << state->mParent->SendObserveLayersUpdate(id, aLayerTree->GetChildEpoch(), false);
}
}
@ -648,7 +648,7 @@ CrossProcessCompositorBridgeParent::UpdatePaintTime(LayerTransactionParent* aLay
}
void
CrossProcessCompositorBridgeParent::ObserveLayerUpdate(LayersId aLayersId, uint64_t aEpoch, bool aActive)
CrossProcessCompositorBridgeParent::ObserveLayersUpdate(LayersId aLayersId, LayersObserverEpoch aEpoch, bool aActive)
{
MOZ_ASSERT(aLayersId.IsValid());
@ -658,7 +658,7 @@ CrossProcessCompositorBridgeParent::ObserveLayerUpdate(LayersId aLayersId, uint6
return;
}
Unused << state->mParent->SendObserveLayerUpdate(aLayersId, aEpoch, aActive);
Unused << state->mParent->SendObserveLayersUpdate(aLayersId, aEpoch, aActive);
}
} // namespace layers

View File

@ -151,7 +151,7 @@ public:
wr::IdNamespace* aIdNamespace) override;
bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override;
void ObserveLayerUpdate(LayersId aLayersId, uint64_t aEpoch, bool aActive) override;
void ObserveLayersUpdate(LayersId aLayersId, LayersObserverEpoch aEpoch, bool aActive) override;
bool IsRemote() const override {
return true;

View File

@ -55,8 +55,8 @@ LayerTransactionParent::LayerTransactionParent(HostLayerManager* aManager,
, mCompositorBridge(aBridge)
, mAnimStorage(aAnimStorage)
, mId(aId)
, mChildEpoch(0)
, mParentEpoch(0)
, mChildEpoch{0}
, mParentEpoch{0}
, mVsyncRate(aVsyncRate)
, mPendingTransaction{0}
, mDestroyed(false)
@ -647,9 +647,9 @@ LayerTransactionParent::SetLayerAttributes(const OpSetLayerAttributes& aOp)
}
mozilla::ipc::IPCResult
LayerTransactionParent::RecvSetLayerObserverEpoch(const uint64_t& aLayerObserverEpoch)
LayerTransactionParent::RecvSetLayersObserverEpoch(const LayersObserverEpoch& aChildEpoch)
{
mChildEpoch = aLayerObserverEpoch;
mChildEpoch = aChildEpoch;
return IPC_OK();
}

View File

@ -62,7 +62,7 @@ public:
LayersId GetId() const { return mId; }
Layer* GetRoot() const { return mRoot; }
uint64_t GetChildEpoch() const { return mChildEpoch; }
LayersObserverEpoch GetChildEpoch() const { return mChildEpoch; }
bool ShouldParentObserveEpoch();
ShmemAllocator* AsShmemAllocator() override { return this; }
@ -115,7 +115,7 @@ protected:
mozilla::ipc::IPCResult RecvUpdate(const TransactionInfo& aInfo) override;
mozilla::ipc::IPCResult RecvSetLayerObserverEpoch(const uint64_t& aLayerObserverEpoch) override;
mozilla::ipc::IPCResult RecvSetLayersObserverEpoch(const LayersObserverEpoch& aChildEpoch) override;
mozilla::ipc::IPCResult RecvNewCompositable(const CompositableHandle& aHandle,
const TextureInfo& aInfo) override;
mozilla::ipc::IPCResult RecvReleaseLayer(const LayerHandle& aHandle) override;
@ -198,8 +198,8 @@ private:
// parent. mChildEpoch is the latest epoch value received from the child.
// mParentEpoch is the latest epoch value that we have told TabParent about
// (via ObserveLayerUpdate).
uint64_t mChildEpoch;
uint64_t mParentEpoch;
LayersObserverEpoch mChildEpoch;
LayersObserverEpoch mParentEpoch;
TimeDuration mVsyncRate;

View File

@ -43,6 +43,11 @@ struct ParamTraits<mozilla::layers::TransactionId>
: public PlainOldDataSerializer<mozilla::layers::TransactionId>
{};
template <>
struct ParamTraits<mozilla::layers::LayersObserverEpoch>
: public PlainOldDataSerializer<mozilla::layers::LayersObserverEpoch>
{};
template <>
struct ParamTraits<mozilla::layers::LayersBackend>
: public ContiguousEnumSerializer<

View File

@ -43,6 +43,7 @@ using mozilla::wr::IdNamespace from "mozilla/webrender/WebRenderTypes.h";
using base::ProcessId from "base/process.h";
using mozilla::wr::MaybeExternalImageId from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::WebRenderError from "mozilla/webrender/WebRenderTypes.h";
using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h";
using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h";
namespace mozilla {
@ -133,7 +134,7 @@ child:
async ParentAsyncMessages(AsyncParentMessageData[] aMessages);
async ObserveLayerUpdate(LayersId aLayersId, uint64_t aEpoch, bool aActive);
async ObserveLayersUpdate(LayersId aLayersId, LayersObserverEpoch aEpoch, bool aActive);
parent:
async __delete__();

View File

@ -23,6 +23,7 @@ using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/Comp
using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h";
using mozilla::layers::LayerHandle from "mozilla/layers/LayersTypes.h";
using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h";
using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h";
using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h";
/**
@ -54,7 +55,7 @@ parent:
async PaintTime(TransactionId id, TimeDuration paintTime);
async SetLayerObserverEpoch(uint64_t layerObserverEpoch);
async SetLayersObserverEpoch(LayersObserverEpoch aChildEpoch);
// Create a new Compositable.
async NewCompositable(CompositableHandle handle, TextureInfo info);

View File

@ -24,6 +24,7 @@ using mozilla::wr::BuiltDisplayListDescriptor from "mozilla/webrender/webrender_
using mozilla::wr::IdNamespace from "mozilla/webrender/WebRenderTypes.h";
using mozilla::layers::WebRenderScrollData from "mozilla/layers/WebRenderScrollData.h";
using mozilla::layers::FocusTarget from "mozilla/layers/FocusTarget.h";
using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h";
using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h";
namespace mozilla {
@ -51,7 +52,7 @@ parent:
async UpdateResources(OpUpdateResource[] aResourceUpdates, RefCountedShmem[] aSmallShmems, Shmem[] aLargeShmems);
async ParentCommands(WebRenderParentCommand[] commands);
sync GetSnapshot(PTexture texture);
async SetLayerObserverEpoch(uint64_t layerObserverEpoch);
async SetLayersObserverEpoch(LayersObserverEpoch childEpoch);
async ClearCachedResources();
// Schedule a composite if one isn't already scheduled.
async ScheduleComposite();

View File

@ -808,12 +808,12 @@ ShadowLayerForwarder::FindCompositable(const CompositableHandle& aHandle)
}
void
ShadowLayerForwarder::SetLayerObserverEpoch(uint64_t aLayerObserverEpoch)
ShadowLayerForwarder::SetLayersObserverEpoch(LayersObserverEpoch aEpoch)
{
if (!IPCOpen()) {
return;
}
Unused << mShadowManager->SendSetLayerObserverEpoch(aLayerObserverEpoch);
Unused << mShadowManager->SendSetLayersObserverEpoch(aEpoch);
}
void

View File

@ -343,7 +343,7 @@ public:
*/
void SetFocusTarget(const FocusTarget& aFocusTarget) { mFocusTarget = aFocusTarget; }
void SetLayerObserverEpoch(uint64_t aLayerObserverEpoch);
void SetLayersObserverEpoch(LayersObserverEpoch aEpoch);
static void PlatformSyncBeforeUpdate();

View File

@ -194,8 +194,8 @@ WebRenderBridgeParent::WebRenderBridgeParent(CompositorBridgeParentBase* aCompos
, mCompositorScheduler(aScheduler)
, mAnimStorage(aAnimStorage)
, mVsyncRate(aVsyncRate)
, mChildLayerObserverEpoch(0)
, mParentLayerObserverEpoch(0)
, mChildLayersObserverEpoch{0}
, mParentLayersObserverEpoch{0}
, mWrEpoch{0}
, mIdNamespace(aApi->GetNamespace())
, mPaused(false)
@ -215,8 +215,8 @@ WebRenderBridgeParent::WebRenderBridgeParent(CompositorBridgeParentBase* aCompos
WebRenderBridgeParent::WebRenderBridgeParent(const wr::PipelineId& aPipelineId)
: mCompositorBridge(nullptr)
, mPipelineId(aPipelineId)
, mChildLayerObserverEpoch(0)
, mParentLayerObserverEpoch(0)
, mChildLayersObserverEpoch{0}
, mParentLayersObserverEpoch{0}
, mWrEpoch{0}
, mIdNamespace{0}
, mPaused(false)
@ -829,7 +829,7 @@ WebRenderBridgeParent::RecvSetDisplayList(const gfx::IntSize& aSize,
}
if (ShouldParentObserveEpoch()) {
mCompositorBridge->ObserveLayerUpdate(GetLayersId(), GetChildLayerObserverEpoch(), true);
mCompositorBridge->ObserveLayersUpdate(GetLayersId(), mChildLayersObserverEpoch, true);
}
wr::IpcResourceUpdateQueue::ReleaseShmems(this, aSmallShmems);
@ -913,7 +913,7 @@ WebRenderBridgeParent::RecvEmptyTransaction(const FocusTarget& aFocusTarget,
}
if (ShouldParentObserveEpoch()) {
mCompositorBridge->ObserveLayerUpdate(GetLayersId(), GetChildLayerObserverEpoch(), true);
mCompositorBridge->ObserveLayersUpdate(GetLayersId(), mChildLayersObserverEpoch, true);
}
return IPC_OK();
@ -1221,12 +1221,12 @@ WebRenderBridgeParent::ReleaseTextureOfImage(const wr::ImageKey& aKey)
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvSetLayerObserverEpoch(const uint64_t& aLayerObserverEpoch)
WebRenderBridgeParent::RecvSetLayersObserverEpoch(const LayersObserverEpoch& aChildEpoch)
{
if (mDestroyed) {
return IPC_OK();
}
mChildLayerObserverEpoch = aLayerObserverEpoch;
mChildLayersObserverEpoch = aChildEpoch;
return IPC_OK();
}
@ -1236,7 +1236,7 @@ WebRenderBridgeParent::RecvClearCachedResources()
if (mDestroyed) {
return IPC_OK();
}
mCompositorBridge->ObserveLayerUpdate(GetLayersId(), GetChildLayerObserverEpoch(), false);
mCompositorBridge->ObserveLayersUpdate(GetLayersId(), mChildLayersObserverEpoch, false);
// Clear resources
wr::TransactionBuilder txn;
@ -1781,11 +1781,11 @@ WebRenderBridgeParent::ClearResources()
bool
WebRenderBridgeParent::ShouldParentObserveEpoch()
{
if (mParentLayerObserverEpoch == mChildLayerObserverEpoch) {
if (mParentLayersObserverEpoch == mChildLayersObserverEpoch) {
return false;
}
mParentLayerObserverEpoch = mChildLayerObserverEpoch;
mParentLayersObserverEpoch = mChildLayersObserverEpoch;
return true;
}

View File

@ -106,7 +106,7 @@ public:
mozilla::ipc::IPCResult RecvParentCommands(nsTArray<WebRenderParentCommand>&& commands) override;
mozilla::ipc::IPCResult RecvGetSnapshot(PTextureParent* aTexture) override;
mozilla::ipc::IPCResult RecvSetLayerObserverEpoch(const uint64_t& aLayerObserverEpoch) override;
mozilla::ipc::IPCResult RecvSetLayersObserverEpoch(const LayersObserverEpoch& aChildEpoch) override;
mozilla::ipc::IPCResult RecvClearCachedResources() override;
mozilla::ipc::IPCResult RecvScheduleComposite() override;
@ -231,7 +231,6 @@ private:
wr::TransactionBuilder& aTxn);
void ClearResources();
uint64_t GetChildLayerObserverEpoch() const { return mChildLayerObserverEpoch; }
bool ShouldParentObserveEpoch();
mozilla::ipc::IPCResult HandleShutdown();
@ -304,11 +303,11 @@ private:
TimeDuration mVsyncRate;
TimeStamp mPreviousFrameTimeStamp;
// These fields keep track of the latest layer observer epoch values in the child and the
// parent. mChildLayerObserverEpoch is the latest epoch value received from the child.
// mParentLayerObserverEpoch is the latest epoch value that we have told TabParent about
// parent. mChildLayersObserverEpoch is the latest epoch value received from the child.
// mParentLayersObserverEpoch is the latest epoch value that we have told TabParent about
// (via ObserveLayerUpdate).
uint64_t mChildLayerObserverEpoch;
uint64_t mParentLayerObserverEpoch;
LayersObserverEpoch mChildLayersObserverEpoch;
LayersObserverEpoch mParentLayersObserverEpoch;
std::queue<PendingTransactionId> mPendingTransactionIds;
std::queue<CompositorAnimationIdsForEpoch> mCompositorAnimationsToDelete;

View File

@ -480,10 +480,10 @@ WebRenderLayerManager::DiscardLocalImages()
}
void
WebRenderLayerManager::SetLayerObserverEpoch(uint64_t aLayerObserverEpoch)
WebRenderLayerManager::SetLayersObserverEpoch(LayersObserverEpoch aEpoch)
{
if (WrBridge()->IPCOpen()) {
WrBridge()->SendSetLayerObserverEpoch(aLayerObserverEpoch);
WrBridge()->SendSetLayersObserverEpoch(aEpoch);
}
}

View File

@ -91,7 +91,7 @@ public:
virtual bool NeedsWidgetInvalidation() override { return false; }
virtual void SetLayerObserverEpoch(uint64_t aLayerObserverEpoch) override;
virtual void SetLayersObserverEpoch(LayersObserverEpoch aEpoch) override;
virtual void DidComposite(TransactionId aTransactionId,
const mozilla::TimeStamp& aCompositeStart,