Bug 1510853 - Make VsyncId available to compositor. r=jrmuizel

MozReview-Commit-ID: 8wBDg39R4nZ

Differential Revision: https://phabricator.services.mozilla.com/D13350

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2018-12-07 23:28:03 +00:00
Родитель e3453844bf
Коммит 011bd0697f
20 изменённых файлов: 135 добавлений и 92 удалений

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

@ -10,6 +10,7 @@
#include "nsISupportsImpl.h"
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/VsyncDispatcher.h"
namespace mozilla {
namespace layers {
@ -80,6 +81,8 @@ class TransactionIdAllocator {
* Get the start time of the current refresh tick.
*/
virtual mozilla::TimeStamp GetTransactionStart() = 0;
virtual VsyncId GetVsyncId() = 0;
};
} // namespace layers

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

@ -688,10 +688,11 @@ void ClientLayerManager::ForwardTransaction(bool aScheduleComposite) {
// forward this transaction's changeset to our LayerManagerComposite
bool sent = false;
bool ok = mForwarder->EndTransaction(mRegionToClear, mLatestTransactionId,
aScheduleComposite, mPaintSequenceNumber,
mIsRepeatTransaction, refreshStart,
mTransactionStart, mURL, &sent);
bool ok = mForwarder->EndTransaction(
mRegionToClear, mLatestTransactionId, aScheduleComposite,
mPaintSequenceNumber, mIsRepeatTransaction,
mTransactionIdAllocator->GetVsyncId(), refreshStart, mTransactionStart,
mURL, &sent);
if (ok) {
if (sent) {
mNeedsComposite = false;

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

@ -888,7 +888,7 @@ void CompositorBridgeParent::ScheduleComposition() {
});
}
void CompositorBridgeParent::CompositeToTarget(DrawTarget* aTarget,
void CompositorBridgeParent::CompositeToTarget(VsyncId aId, DrawTarget* aTarget,
const gfx::IntRect* aRect) {
AUTO_PROFILER_TRACING("Paint", "Composite");
AUTO_PROFILER_LABEL("CompositorBridgeParent::CompositeToTarget", GRAPHICS);

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

@ -595,7 +595,7 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
// CompositorVsyncSchedulerOwner
bool IsPendingComposite() override;
void FinishPendingComposite() override;
void CompositeToTarget(gfx::DrawTarget* aTarget,
void CompositeToTarget(VsyncId aId, gfx::DrawTarget* aTarget,
const gfx::IntRect* aRect = nullptr) override;
bool InitializeAdvancedLayers(const nsTArray<LayersBackend>& aBackendHints,

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

@ -106,12 +106,13 @@ void CompositorVsyncScheduler::Destroy() {
}
void CompositorVsyncScheduler::PostCompositeTask(
TimeStamp aCompositeTimestamp) {
VsyncId aId, TimeStamp aCompositeTimestamp) {
MonitorAutoLock lock(mCurrentCompositeTaskMonitor);
if (mCurrentCompositeTask == nullptr && CompositorThreadHolder::Loop()) {
RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod<TimeStamp>(
"layers::CompositorVsyncScheduler::Composite", this,
&CompositorVsyncScheduler::Composite, aCompositeTimestamp);
RefPtr<CancelableRunnable> task =
NewCancelableRunnableMethod<VsyncId, TimeStamp>(
"layers::CompositorVsyncScheduler::Composite", this,
&CompositorVsyncScheduler::Composite, aId, aCompositeTimestamp);
mCurrentCompositeTask = task;
ScheduleTask(task.forget());
}
@ -138,7 +139,7 @@ void CompositorVsyncScheduler::ScheduleComposition() {
if (mAsapScheduling) {
// Used only for performance testing purposes, and when recording/replaying
// to ensure that graphics are up to date.
PostCompositeTask(TimeStamp::Now());
PostCompositeTask(VsyncId(), TimeStamp::Now());
#ifdef MOZ_WIDGET_ANDROID
} else if (mIsObservingVsync && mCompositeRequestedAt &&
(TimeStamp::Now() - mCompositeRequestedAt) >=
@ -149,7 +150,7 @@ void CompositorVsyncScheduler::ScheduleComposition() {
// wait for the vsync. Note that this should only ever happen on Fennec
// because there content runs in the same process as the compositor, and so
// content can actually block the main thread in this process.
PostCompositeTask(TimeStamp::Now());
PostCompositeTask(VsyncId(), TimeStamp::Now());
#endif
} else {
if (!mCompositeRequestedAt) {
@ -161,7 +162,7 @@ void CompositorVsyncScheduler::ScheduleComposition() {
// through the main thread of the UI process. It's possible that
// we're blocking there waiting on a composite, so schedule an initial
// one now to get things started.
PostCompositeTask(TimeStamp::Now());
PostCompositeTask(VsyncId(), TimeStamp::Now());
}
}
}
@ -174,7 +175,7 @@ bool CompositorVsyncScheduler::NotifyVsync(const VsyncEvent& aVsync) {
MOZ_ASSERT_IF(XRE_GetProcessType() == GeckoProcessType_GPU,
CompositorThreadHolder::IsInCompositorThread());
MOZ_ASSERT(!NS_IsMainThread());
PostCompositeTask(aVsync.mTime);
PostCompositeTask(aVsync.mId, aVsync.mTime);
PostVRTask(aVsync.mTime);
return true;
}
@ -189,7 +190,8 @@ void CompositorVsyncScheduler::CancelCurrentCompositeTask() {
}
}
void CompositorVsyncScheduler::Composite(TimeStamp aVsyncTimestamp) {
void CompositorVsyncScheduler::Composite(VsyncId aId,
TimeStamp aVsyncTimestamp) {
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
MOZ_ASSERT(mVsyncSchedulerOwner);
@ -220,7 +222,7 @@ void CompositorVsyncScheduler::Composite(TimeStamp aVsyncTimestamp) {
mLastCompose = aVsyncTimestamp;
// Tell the owner to do a composite
mVsyncSchedulerOwner->CompositeToTarget(nullptr, nullptr);
mVsyncSchedulerOwner->CompositeToTarget(aId, nullptr, nullptr);
mVsyncNotificationsSkipped = 0;
@ -256,7 +258,7 @@ void CompositorVsyncScheduler::ForceComposeToTarget(gfx::DrawTarget* aTarget,
mLastCompose = TimeStamp::Now();
MOZ_ASSERT(mVsyncSchedulerOwner);
mVsyncSchedulerOwner->CompositeToTarget(aTarget, aRect);
mVsyncSchedulerOwner->CompositeToTarget(VsyncId(), aTarget, aRect);
}
bool CompositorVsyncScheduler::NeedsComposite() {

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

@ -108,7 +108,7 @@ class CompositorVsyncScheduler {
// Post a task to run Composite() on the compositor thread, if there isn't
// such a task already queued. Can be called from any thread.
void PostCompositeTask(TimeStamp aCompositeTimestamp);
void PostCompositeTask(VsyncId aId, TimeStamp aCompositeTimestamp);
// Post a task to run DispatchVREvents() on the VR thread, if there isn't
// such a task already queued. Can be called from any thread.
@ -116,7 +116,7 @@ class CompositorVsyncScheduler {
// This gets run at vsync time and "does" a composite (which really means
// update internal state and call the owner to do the composite).
void Composite(TimeStamp aVsyncTimestamp);
void Composite(VsyncId aId, TimeStamp aVsyncTimestamp);
void ObserveVsync();
void UnobserveVsync();

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

@ -7,6 +7,8 @@
#ifndef mozilla_layers_CompositorVsyncSchedulerOwner_h
#define mozilla_layers_CompositorVsyncSchedulerOwner_h
#include "mozilla/VsyncDispatcher.h"
namespace mozilla {
namespace gfx {
@ -19,7 +21,7 @@ class CompositorVsyncSchedulerOwner {
public:
virtual bool IsPendingComposite() = 0;
virtual void FinishPendingComposite() = 0;
virtual void CompositeToTarget(gfx::DrawTarget* aTarget,
virtual void CompositeToTarget(VsyncId aId, gfx::DrawTarget* aTarget,
const gfx::IntRect* aRect = nullptr) = 0;
virtual TimeDuration GetVsyncInterval() const = 0;
};

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

@ -389,9 +389,9 @@ void CrossProcessCompositorBridgeParent::ShadowLayersUpdated(
static_cast<uint32_t>(
(endTime - aInfo.transactionStart()).ToMilliseconds()));
aLayerTree->SetPendingTransactionId(aInfo.id(), aInfo.refreshStart(),
aInfo.transactionStart(), aInfo.url(),
aInfo.fwdTime());
aLayerTree->SetPendingTransactionId(
aInfo.id(), aInfo.vsyncId(), aInfo.refreshStart(),
aInfo.transactionStart(), aInfo.url(), aInfo.fwdTime());
}
void CrossProcessCompositorBridgeParent::DidComposite(

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

@ -72,12 +72,13 @@ class LayerTransactionParent final : public PLayerTransactionParent,
bool IsSameProcess() const override;
const TransactionId& GetPendingTransactionId() { return mPendingTransaction; }
void SetPendingTransactionId(TransactionId aId,
void SetPendingTransactionId(TransactionId aId, const VsyncId& aVsyncId,
const TimeStamp& aRefreshStartTime,
const TimeStamp& aTxnStartTime,
const nsCString& aURL,
const TimeStamp& aFwdTime) {
mPendingTransaction = aId;
mTxnVsyncId = aVsyncId;
mRefreshStartTime = aRefreshStartTime;
mTxnStartTime = aTxnStartTime;
mTxnURL = aURL;
@ -202,6 +203,7 @@ class LayerTransactionParent final : public PLayerTransactionParent,
TimeDuration mVsyncRate;
TransactionId mPendingTransaction;
VsyncId mTxnVsyncId;
TimeStamp mRefreshStartTime;
TimeStamp mTxnStartTime;
TimeStamp mFwdTime;

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

@ -52,6 +52,7 @@ using mozilla::CrossProcessSemaphoreHandle from "mozilla/ipc/CrossProcessSemapho
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h";
using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h";
using mozilla::VsyncId from "mozilla/VsyncDispatcher.h";
namespace mozilla {
namespace layers {
@ -554,6 +555,7 @@ struct TransactionInfo
bool scheduleComposite;
uint32_t paintSequenceNumber;
bool isRepeatTransaction;
VsyncId vsyncId;
TimeStamp refreshStart;
TimeStamp transactionStart;
nsCString url;

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

@ -28,6 +28,7 @@ using mozilla::layers::WebRenderScrollData from "mozilla/layers/WebRenderScrollD
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";
using mozilla::VsyncId from "mozilla/VsyncDispatcher.h";
namespace mozilla {
namespace layers {
@ -48,11 +49,11 @@ parent:
LayoutSize aContentSize, ByteBuf aDL, BuiltDisplayListDescriptor aDLDesc,
WebRenderScrollData aScrollData,
OpUpdateResource[] aResourceUpdates, RefCountedShmem[] aSmallShmems, Shmem[] aLargeShmems,
IdNamespace aIdNamespace, bool containsSVGGroup, TimeStamp refreshStartTime, TimeStamp txnStartTime, nsCString txnURL, TimeStamp fwdTime);
IdNamespace aIdNamespace, bool containsSVGGroup, VsyncId vsyncId, TimeStamp refreshStartTime, TimeStamp txnStartTime, nsCString txnURL, TimeStamp fwdTime);
async EmptyTransaction(FocusTarget focusTarget, ScrollUpdatesMap scrollUpdates, uint32_t aPaintSequenceNumber,
WebRenderParentCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, TransactionId transactionId,
OpUpdateResource[] aResourceUpdates, RefCountedShmem[] aSmallShmems, Shmem[] aLargeShmems,
IdNamespace aIdNamespace, TimeStamp refreshStartTime, TimeStamp txnStartTime, nsCString txnURL, TimeStamp fwdTime);
IdNamespace aIdNamespace, VsyncId vsyncId, TimeStamp refreshStartTime, TimeStamp txnStartTime, nsCString txnURL, TimeStamp fwdTime);
async SetFocusTarget(FocusTarget focusTarget);
async UpdateResources(OpUpdateResource[] aResourceUpdates, RefCountedShmem[] aSmallShmems, Shmem[] aLargeShmems);
async ParentCommands(WebRenderParentCommand[] commands);

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

@ -528,7 +528,8 @@ void ShadowLayerForwarder::SendPaintTime(TransactionId aId,
bool ShadowLayerForwarder::EndTransaction(
const nsIntRegion& aRegionToClear, TransactionId aId,
bool aScheduleComposite, uint32_t aPaintSequenceNumber,
bool aIsRepeatTransaction, const mozilla::TimeStamp& aRefreshStart,
bool aIsRepeatTransaction, const mozilla::VsyncId& aVsyncId,
const mozilla::TimeStamp& aRefreshStart,
const mozilla::TimeStamp& aTransactionStart, const nsCString& aURL,
bool* aSent) {
*aSent = false;
@ -670,6 +671,7 @@ bool ShadowLayerForwarder::EndTransaction(
info.scheduleComposite() = aScheduleComposite;
info.paintSequenceNumber() = aPaintSequenceNumber;
info.isRepeatTransaction() = aIsRepeatTransaction;
info.vsyncId() = aVsyncId;
info.refreshStart() = aRefreshStart;
info.transactionStart() = aTransactionStart;
info.url() = aURL;

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

@ -252,6 +252,7 @@ class ShadowLayerForwarder final : public LayersIPCActor,
bool EndTransaction(const nsIntRegion& aRegionToClear, TransactionId aId,
bool aScheduleComposite, uint32_t aPaintSequenceNumber,
bool aIsRepeatTransaction,
const mozilla::VsyncId& aVsyncId,
const mozilla::TimeStamp& aRefreshStart,
const mozilla::TimeStamp& aTransactionStart,
const nsCString& aURL, bool* aSent);

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

@ -105,7 +105,8 @@ void WebRenderBridgeChild::EndTransaction(
const wr::LayoutSize& aContentSize, wr::BuiltDisplayList& aDL,
wr::IpcResourceUpdateQueue& aResources, const gfx::IntSize& aSize,
TransactionId aTransactionId, const WebRenderScrollData& aScrollData,
bool aContainsSVGGroup, const mozilla::TimeStamp& aRefreshStartTime,
bool aContainsSVGGroup, const mozilla::VsyncId& aVsyncId,
const mozilla::TimeStamp& aRefreshStartTime,
const mozilla::TimeStamp& aTxnStartTime, const nsCString& aTxnURL) {
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(mIsInTransaction);
@ -121,11 +122,12 @@ void WebRenderBridgeChild::EndTransaction(
nsTArray<ipc::Shmem> largeShmems;
aResources.Flush(resourceUpdates, smallShmems, largeShmems);
this->SendSetDisplayList(
aSize, mParentCommands, mDestroyedActors, GetFwdTransactionId(),
aTransactionId, aContentSize, dlData, aDL.dl_desc, aScrollData,
resourceUpdates, smallShmems, largeShmems, mIdNamespace,
aContainsSVGGroup, aRefreshStartTime, aTxnStartTime, aTxnURL, fwdTime);
this->SendSetDisplayList(aSize, mParentCommands, mDestroyedActors,
GetFwdTransactionId(), aTransactionId, aContentSize,
dlData, aDL.dl_desc, aScrollData, resourceUpdates,
smallShmems, largeShmems, mIdNamespace,
aContainsSVGGroup, aVsyncId, aRefreshStartTime,
aTxnStartTime, aTxnURL, fwdTime);
mParentCommands.Clear();
mDestroyedActors.Clear();
@ -136,6 +138,7 @@ void WebRenderBridgeChild::EndEmptyTransaction(
const FocusTarget& aFocusTarget, const ScrollUpdatesMap& aUpdates,
Maybe<wr::IpcResourceUpdateQueue>& aResources,
uint32_t aPaintSequenceNumber, TransactionId aTransactionId,
const mozilla::VsyncId& aVsyncId,
const mozilla::TimeStamp& aRefreshStartTime,
const mozilla::TimeStamp& aTxnStartTime, const nsCString& aTxnURL) {
MOZ_ASSERT(!mDestroyed);
@ -154,8 +157,8 @@ void WebRenderBridgeChild::EndEmptyTransaction(
this->SendEmptyTransaction(
aFocusTarget, aUpdates, aPaintSequenceNumber, mParentCommands,
mDestroyedActors, GetFwdTransactionId(), aTransactionId, resourceUpdates,
smallShmems, largeShmems, mIdNamespace, aRefreshStartTime, aTxnStartTime,
aTxnURL, fwdTime);
smallShmems, largeShmems, mIdNamespace, aVsyncId, aRefreshStartTime,
aTxnStartTime, aTxnURL, fwdTime);
mParentCommands.Clear();
mDestroyedActors.Clear();
mIsInTransaction = false;

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

@ -66,17 +66,21 @@ class WebRenderBridgeChild final : public PWebRenderBridgeChild,
void UpdateResources(wr::IpcResourceUpdateQueue& aResources);
void BeginTransaction();
void EndTransaction(
const wr::LayoutSize& aContentSize, wr::BuiltDisplayList& dl,
wr::IpcResourceUpdateQueue& aResources, const gfx::IntSize& aSize,
TransactionId aTransactionId, const WebRenderScrollData& aScrollData,
bool aContainsSVGroup, const mozilla::TimeStamp& aRefreshStartTime,
const mozilla::TimeStamp& aTxnStartTime, const nsCString& aTxtURL);
void EndTransaction(const wr::LayoutSize& aContentSize,
wr::BuiltDisplayList& dl,
wr::IpcResourceUpdateQueue& aResources,
const gfx::IntSize& aSize, TransactionId aTransactionId,
const WebRenderScrollData& aScrollData,
bool aContainsSVGroup, const mozilla::VsyncId& aVsyncId,
const mozilla::TimeStamp& aRefreshStartTime,
const mozilla::TimeStamp& aTxnStartTime,
const nsCString& aTxtURL);
void EndEmptyTransaction(const FocusTarget& aFocusTarget,
const ScrollUpdatesMap& aUpdates,
Maybe<wr::IpcResourceUpdateQueue>& aResources,
uint32_t aPaintSequenceNumber,
TransactionId aTransactionId,
const mozilla::VsyncId& aVsyncId,
const mozilla::TimeStamp& aRefreshStartTime,
const mozilla::TimeStamp& aTxnStartTime,
const nsCString& aTxtURL);

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

@ -854,9 +854,9 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetDisplayList(
nsTArray<OpUpdateResource>&& aResourceUpdates,
nsTArray<RefCountedShmem>&& aSmallShmems,
nsTArray<ipc::Shmem>&& aLargeShmems, const wr::IdNamespace& aIdNamespace,
const bool& aContainsSVGGroup, const TimeStamp& aRefreshStartTime,
const TimeStamp& aTxnStartTime, const nsCString& aTxnURL,
const TimeStamp& aFwdTime) {
const bool& aContainsSVGGroup, const VsyncId& aVsyncId,
const TimeStamp& aRefreshStartTime, const TimeStamp& aTxnStartTime,
const nsCString& aTxnURL, const TimeStamp& aFwdTime) {
if (mDestroyed) {
for (const auto& op : aToDestroy) {
DestroyActor(op);
@ -945,7 +945,7 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetDisplayList(
mChildLayersObserverEpoch, true);
}
HoldPendingTransactionId(wrEpoch, aTransactionId, aContainsSVGGroup,
HoldPendingTransactionId(wrEpoch, aTransactionId, aContainsSVGGroup, aVsyncId,
aRefreshStartTime, aTxnStartTime, aTxnURL, aFwdTime,
mIsFirstPaint);
mIsFirstPaint = false;
@ -973,8 +973,9 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvEmptyTransaction(
nsTArray<OpUpdateResource>&& aResourceUpdates,
nsTArray<RefCountedShmem>&& aSmallShmems,
nsTArray<ipc::Shmem>&& aLargeShmems, const wr::IdNamespace& aIdNamespace,
const TimeStamp& aRefreshStartTime, const TimeStamp& aTxnStartTime,
const nsCString& aTxnURL, const TimeStamp& aFwdTime) {
const VsyncId& aVsyncId, const TimeStamp& aRefreshStartTime,
const TimeStamp& aTxnStartTime, const nsCString& aTxnURL,
const TimeStamp& aFwdTime) {
if (mDestroyed) {
for (const auto& op : aToDestroy) {
DestroyActor(op);
@ -1058,8 +1059,8 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvEmptyTransaction(
// Only register a value for CONTENT_FRAME_TIME telemetry if we actually drew
// something. It is for consistency with disabling WebRender.
HoldPendingTransactionId(mWrEpoch, aTransactionId, false, aRefreshStartTime,
aTxnStartTime, aTxnURL, aFwdTime,
HoldPendingTransactionId(mWrEpoch, aTransactionId, false, aVsyncId,
aRefreshStartTime, aTxnStartTime, aTxnURL, aFwdTime,
/* aIsFirstPaint */ false,
/* aUseForTelemetry */ scheduleComposite);
@ -1642,11 +1643,12 @@ bool WebRenderBridgeParent::SampleAnimations(
void WebRenderBridgeParent::CompositeIfNeeded() {
if (mSkippedComposite) {
mSkippedComposite = false;
CompositeToTarget(nullptr, nullptr);
CompositeToTarget(VsyncId(), nullptr, nullptr);
}
}
void WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget,
void WebRenderBridgeParent::CompositeToTarget(VsyncId aId,
gfx::DrawTarget* aTarget,
const gfx::IntRect* aRect) {
// This function should only get called in the root WRBP
MOZ_ASSERT(IsRootWebRenderBridgeParent());
@ -1751,13 +1753,13 @@ void WebRenderBridgeParent::MaybeGenerateFrame(bool aForceGenerateFrame) {
void WebRenderBridgeParent::HoldPendingTransactionId(
const wr::Epoch& aWrEpoch, TransactionId aTransactionId,
bool aContainsSVGGroup, const TimeStamp& aRefreshStartTime,
const TimeStamp& aTxnStartTime, const nsCString& aTxnURL,
const TimeStamp& aFwdTime, const bool aIsFirstPaint,
const bool aUseForTelemetry) {
bool aContainsSVGGroup, const VsyncId& aVsyncId,
const TimeStamp& aRefreshStartTime, const TimeStamp& aTxnStartTime,
const nsCString& aTxnURL, const TimeStamp& aFwdTime,
const bool aIsFirstPaint, const bool aUseForTelemetry) {
MOZ_ASSERT(aTransactionId > LastPendingTransactionId());
mPendingTransactionIds.push_back(PendingTransactionId(
aWrEpoch, aTransactionId, aContainsSVGGroup, aRefreshStartTime,
aWrEpoch, aTransactionId, aContainsSVGGroup, aVsyncId, aRefreshStartTime,
aTxnStartTime, aTxnURL, aFwdTime, aIsFirstPaint, aUseForTelemetry));
}

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

@ -102,9 +102,9 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
nsTArray<OpUpdateResource>&& aResourceUpdates,
nsTArray<RefCountedShmem>&& aSmallShmems,
nsTArray<ipc::Shmem>&& aLargeShmems, const wr::IdNamespace& aIdNamespace,
const bool& aContainsSVGGroup, const TimeStamp& aRefreshStartTime,
const TimeStamp& aTxnStartTime, const nsCString& aTxnURL,
const TimeStamp& aFwdTime) override;
const bool& aContainsSVGGroup, const VsyncId& aVsyncId,
const TimeStamp& aRefreshStartTime, const TimeStamp& aTxnStartTime,
const nsCString& aTxnURL, const TimeStamp& aFwdTime) override;
mozilla::ipc::IPCResult RecvEmptyTransaction(
const FocusTarget& aFocusTarget, const ScrollUpdatesMap& aUpdates,
const uint32_t& aPaintSequenceNumber,
@ -114,8 +114,9 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
nsTArray<OpUpdateResource>&& aResourceUpdates,
nsTArray<RefCountedShmem>&& aSmallShmems,
nsTArray<ipc::Shmem>&& aLargeShmems, const wr::IdNamespace& aIdNamespace,
const TimeStamp& aRefreshStartTime, const TimeStamp& aTxnStartTime,
const nsCString& aTxnURL, const TimeStamp& aFwdTime) override;
const VsyncId& aVsyncId, const TimeStamp& aRefreshStartTime,
const TimeStamp& aTxnStartTime, const nsCString& aTxnURL,
const TimeStamp& aFwdTime) override;
mozilla::ipc::IPCResult RecvSetFocusTarget(
const FocusTarget& aFocusTarget) override;
mozilla::ipc::IPCResult RecvParentCommands(
@ -158,7 +159,7 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
// CompositorVsyncSchedulerOwner
bool IsPendingComposite() override { return false; }
void FinishPendingComposite() override {}
void CompositeToTarget(gfx::DrawTarget* aTarget,
void CompositeToTarget(VsyncId aId, gfx::DrawTarget* aTarget,
const gfx::IntRect* aRect = nullptr) override;
TimeDuration GetVsyncInterval() const override;
@ -174,10 +175,10 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
void HoldPendingTransactionId(
const wr::Epoch& aWrEpoch, TransactionId aTransactionId,
bool aContainsSVGGroup, const TimeStamp& aRefreshStartTime,
const TimeStamp& aTxnStartTime, const nsCString& aTxnURL,
const TimeStamp& aFwdTime, const bool aIsFirstPaint,
const bool aUseForTelemetry = true);
bool aContainsSVGGroup, const VsyncId& aVsyncId,
const TimeStamp& aRefreshStartTime, const TimeStamp& aTxnStartTime,
const nsCString& aTxnURL, const TimeStamp& aFwdTime,
const bool aIsFirstPaint, const bool aUseForTelemetry = true);
TransactionId LastPendingTransactionId();
TransactionId FlushTransactionIdsForEpoch(
const wr::Epoch& aEpoch, const TimeStamp& aCompositeStartTime,
@ -320,13 +321,14 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
private:
struct PendingTransactionId {
PendingTransactionId(const wr::Epoch& aEpoch, TransactionId aId,
bool aContainsSVGGroup,
bool aContainsSVGGroup, const VsyncId& aVsyncId,
const TimeStamp& aRefreshStartTime,
const TimeStamp& aTxnStartTime,
const nsCString& aTxnURL, const TimeStamp& aFwdTime,
const bool aIsFirstPaint, const bool aUseForTelemetry)
: mEpoch(aEpoch),
mId(aId),
mVsyncId(aVsyncId),
mRefreshStartTime(aRefreshStartTime),
mTxnStartTime(aTxnStartTime),
mTxnURL(aTxnURL),
@ -337,6 +339,7 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
mUseForTelemetry(aUseForTelemetry) {}
wr::Epoch mEpoch;
TransactionId mId;
VsyncId mVsyncId;
TimeStamp mRefreshStartTime;
TimeStamp mTxnStartTime;
nsCString mTxnURL;

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

@ -232,8 +232,9 @@ bool WebRenderLayerManager::EndEmptyTransaction(EndTransactionFlags aFlags) {
WrBridge()->EndEmptyTransaction(mFocusTarget, mPendingScrollUpdates,
mAsyncResourceUpdates, mPaintSequenceNumber,
mLatestTransactionId, refreshStart,
mTransactionStart, mURL);
mLatestTransactionId,
mTransactionIdAllocator->GetVsyncId(),
refreshStart, mTransactionStart, mURL);
ClearPendingScrollInfoUpdate();
mTransactionStart = TimeStamp();
@ -363,8 +364,9 @@ void WebRenderLayerManager::EndTransactionWithoutLayer(
AUTO_PROFILER_TRACING("Paint", "ForwardDPTransaction");
WrBridge()->EndTransaction(contentSize, dl, resourceUpdates,
size.ToUnknownSize(), mLatestTransactionId,
mScrollData, containsSVGGroup, refreshStart,
mTransactionStart, mURL);
mScrollData, containsSVGGroup,
mTransactionIdAllocator->GetVsyncId(),
refreshStart, mTransactionStart, mURL);
}
mTransactionStart = TimeStamp();

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

@ -285,10 +285,10 @@ class RefreshDriverTimer {
*/
void Tick() {
TimeStamp now = TimeStamp::Now();
Tick(now);
Tick(VsyncId(), now);
}
void TickRefreshDrivers(TimeStamp aNow,
void TickRefreshDrivers(VsyncId aId, TimeStamp aNow,
nsTArray<RefPtr<nsRefreshDriver>>& aDrivers) {
if (aDrivers.IsEmpty()) {
return;
@ -301,14 +301,14 @@ class RefreshDriverTimer {
continue;
}
TickDriver(driver, aNow);
TickDriver(driver, aId, aNow);
}
}
/*
* Tick the refresh drivers based on the given timestamp.
*/
void Tick(TimeStamp now) {
void Tick(VsyncId aId, TimeStamp now) {
ScheduleNextTick(now);
mLastFireTime = now;
@ -317,14 +317,14 @@ class RefreshDriverTimer {
// RD is short for RefreshDriver
AUTO_PROFILER_TRACING("Paint", "RefreshDriverTick");
TickRefreshDrivers(now, mContentRefreshDrivers);
TickRefreshDrivers(now, mRootRefreshDrivers);
TickRefreshDrivers(aId, now, mContentRefreshDrivers);
TickRefreshDrivers(aId, now, mRootRefreshDrivers);
LOG("[%p] done.", this);
}
static void TickDriver(nsRefreshDriver* driver, TimeStamp now) {
driver->Tick(now);
static void TickDriver(nsRefreshDriver* driver, VsyncId aId, TimeStamp now) {
driver->Tick(aId, now);
}
TimeStamp mLastFireTime;
@ -462,11 +462,12 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
public nsIRunnablePriority {
public:
ParentProcessVsyncNotifier(RefreshDriverVsyncObserver* aObserver,
TimeStamp aVsyncTimestamp)
VsyncId aId, TimeStamp aVsyncTimestamp)
: Runnable(
"VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::"
"ParentProcessVsyncNotifier"),
mObserver(aObserver),
mId(aId),
mVsyncTimestamp(aVsyncTimestamp) {}
NS_DECL_ISUPPORTS_INHERITED
@ -483,7 +484,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
}
sHighPriorityEnabled = sHighPriorityPrefValue;
mObserver->TickRefreshDriver(mVsyncTimestamp);
mObserver->TickRefreshDriver(mId, mVsyncTimestamp);
return NS_OK;
}
@ -497,6 +498,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
private:
~ParentProcessVsyncNotifier() {}
RefPtr<RefreshDriverVsyncObserver> mObserver;
VsyncId mId;
TimeStamp mVsyncTimestamp;
static mozilla::Atomic<bool> sHighPriorityEnabled;
};
@ -513,6 +515,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
{ // scope lock
MonitorAutoLock lock(mRefreshTickLock);
mRecentVsync = aVsync.mTime;
mRecentVsyncId = aVsync.mId;
if (!mProcessedVsync) {
return true;
}
@ -520,10 +523,11 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
}
nsCOMPtr<nsIRunnable> vsyncEvent =
new ParentProcessVsyncNotifier(this, aVsync.mTime);
new ParentProcessVsyncNotifier(this, aVsync.mId, aVsync.mTime);
NS_DispatchToMainThread(vsyncEvent);
} else {
mRecentVsync = aVsync.mTime;
mRecentVsyncId = aVsync.mId;
if (!mBlockUntil.IsNull() && mBlockUntil > aVsync.mTime) {
if (mProcessedVsync) {
// Re-post vsync update as a normal priority runnable. This way
@ -539,7 +543,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
}
RefPtr<RefreshDriverVsyncObserver> kungFuDeathGrip(this);
TickRefreshDriver(aVsync.mTime);
TickRefreshDriver(aVsync.mId, aVsync.mTime);
}
return true;
@ -561,7 +565,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
mRecentVsync > mLastProcessedTickInChildProcess) {
// mBlockUntil is for high priority vsync notifications only.
mBlockUntil = TimeStamp();
TickRefreshDriver(mRecentVsync);
TickRefreshDriver(mRecentVsyncId, mRecentVsync);
}
mProcessedVsync = true;
@ -615,7 +619,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
}
}
void TickRefreshDriver(TimeStamp aVsyncTimestamp) {
void TickRefreshDriver(VsyncId aId, TimeStamp aVsyncTimestamp) {
MOZ_ASSERT(NS_IsMainThread());
RecordTelemetryProbes(aVsyncTimestamp);
@ -639,7 +643,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
// before use.
if (mVsyncRefreshDriverTimer) {
RefPtr<VsyncRefreshDriverTimer> timer = mVsyncRefreshDriverTimer;
timer->RunRefreshDrivers(aVsyncTimestamp);
timer->RunRefreshDrivers(aId, aVsyncTimestamp);
// Note: mVsyncRefreshDriverTimer might be null now.
}
@ -655,6 +659,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
VsyncRefreshDriverTimer* mVsyncRefreshDriverTimer;
Monitor mRefreshTickLock;
TimeStamp mRecentVsync;
VsyncId mRecentVsyncId;
TimeStamp mLastChildTick;
TimeStamp mLastProcessedTickInChildProcess;
TimeStamp mBlockUntil;
@ -717,7 +722,9 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
// RefreshDriverVsyncObserver.
}
void RunRefreshDrivers(TimeStamp aTimeStamp) { Tick(aTimeStamp); }
void RunRefreshDrivers(VsyncId aId, TimeStamp aTimeStamp) {
Tick(aId, aTimeStamp);
}
RefPtr<RefreshDriverVsyncObserver> mVsyncObserver;
// Used for parent process.
@ -871,7 +878,7 @@ class InactiveRefreshDriverTimer final
if (index < drivers.Length() &&
!drivers[index]->IsTestControllingRefreshesEnabled()) {
TickDriver(drivers[index], now);
TickDriver(drivers[index], VsyncId(), now);
}
mNextDriverIndex++;
@ -1364,9 +1371,9 @@ void nsRefreshDriver::DoTick() {
"Shouldn't have a JSContext on the stack");
if (mTestControllingRefreshes) {
Tick(mMostRecentRefresh);
Tick(VsyncId(), mMostRecentRefresh);
} else {
Tick(TimeStamp::Now());
Tick(VsyncId(), TimeStamp::Now());
}
}
@ -1608,7 +1615,7 @@ void nsRefreshDriver::CancelIdleRunnable(nsIRunnable* aRunnable) {
}
}
void nsRefreshDriver::Tick(TimeStamp aNowTime) {
void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
MOZ_ASSERT(!nsContentUtils::GetCurrentJSContext(),
"Shouldn't have a JSContext on the stack");
@ -1675,6 +1682,7 @@ void nsRefreshDriver::Tick(TimeStamp aNowTime) {
AutoRestore<TimeStamp> restoreTickStart(mTickStart);
mTickStart = TimeStamp::Now();
mTickVsyncId = aId;
gfxPlatform::GetPlatform()->SchedulePaintIfDeviceReset();
@ -2052,6 +2060,8 @@ void nsRefreshDriver::ResetInitialTransactionId(
mozilla::TimeStamp nsRefreshDriver::GetTransactionStart() { return mTickStart; }
VsyncId nsRefreshDriver::GetVsyncId() { return mTickVsyncId; }
void nsRefreshDriver::NotifyTransactionCompleted(
mozilla::layers::TransactionId aTransactionId) {
if (aTransactionId > mCompletedTransaction) {

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

@ -25,6 +25,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/Maybe.h"
#include "mozilla/layers/TransactionIdAllocator.h"
#include "mozilla/VsyncDispatcher.h"
class nsPresContext;
class nsIPresShell;
@ -361,6 +362,7 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
void ClearPendingTransactions() override;
void ResetInitialTransactionId(TransactionId aTransactionId) override;
mozilla::TimeStamp GetTransactionStart() override;
mozilla::VsyncId GetVsyncId() override;
bool IsWaitingForPaint(mozilla::TimeStamp aTime);
@ -414,7 +416,7 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
void DispatchAnimationEvents();
void RunFrameRequestCallbacks(mozilla::TimeStamp aNowTime);
void UpdateIntersectionObservations();
void Tick(mozilla::TimeStamp aNowTime);
void Tick(mozilla::VsyncId aId, mozilla::TimeStamp aNowTime);
enum EnsureTimerStartedFlags {
eNone = 0,
@ -507,6 +509,7 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
uint64_t mWarningThreshold;
mozilla::TimeStamp mMostRecentRefresh;
mozilla::TimeStamp mTickStart;
mozilla::VsyncId mTickVsyncId;
mozilla::TimeStamp mNextThrottledFrameRequestTick;
mozilla::TimeStamp mNextRecomputeVisibilityTick;