Bug 854421 - Part 1: Add a transaction id number to DidComposite. r=nical

This commit is contained in:
Matt Woodrow 2014-05-29 09:42:14 +12:00
parent 94ed02b61d
commit 345fc54583
17 changed files with 89 additions and 54 deletions

View File

@ -2499,6 +2499,7 @@ TabChild::InitRenderingState()
if (!sTabChildren) {
sTabChildren = new TabChildMap;
}
MOZ_ASSERT(!sTabChildren->Get(id));
sTabChildren->Put(id, this);
mLayersId = id;
}
@ -2708,14 +2709,14 @@ TabChild::GetFrom(uint64_t aLayersId)
}
void
TabChild::DidComposite()
TabChild::DidComposite(uint64_t aTransactionId)
{
MOZ_ASSERT(mWidget);
MOZ_ASSERT(mWidget->GetLayerManager());
MOZ_ASSERT(mWidget->GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT);
ClientLayerManager *manager = static_cast<ClientLayerManager*>(mWidget->GetLayerManager());
manager->DidComposite();
manager->DidComposite(aTransactionId);
}
NS_IMETHODIMP

View File

@ -446,7 +446,7 @@ public:
static TabChild* GetFrom(nsIPresShell* aPresShell);
static TabChild* GetFrom(uint64_t aLayersId);
void DidComposite();
void DidComposite(uint64_t aTransactionId);
static inline TabChild*
GetFrom(nsIDOMWindow* aWindow)

View File

@ -285,7 +285,7 @@ ClientLayerManager::Composite()
}
void
ClientLayerManager::DidComposite()
ClientLayerManager::DidComposite(uint64_t aTransactionId)
{
MOZ_ASSERT(mWidget);
nsIWidgetListener *listener = mWidget->GetWidgetListener();
@ -421,11 +421,13 @@ ClientLayerManager::ForwardTransaction(bool aScheduleComposite)
{
mPhase = PHASE_FORWARD;
uint64_t pendingTransactionId = 1;
// forward this transaction's changeset to our LayerManagerComposite
bool sent;
AutoInfallibleTArray<EditReply, 10> replies;
if (HasShadowManager() && mForwarder->EndTransaction(&replies, mRegionToClear,
aScheduleComposite, mPaintSequenceNumber, &sent)) {
pendingTransactionId, aScheduleComposite, mPaintSequenceNumber, &sent)) {
for (nsTArray<EditReply>::size_type i = 0; i < replies.Length(); ++i) {
const EditReply& reply = replies[i];

View File

@ -166,7 +166,7 @@ public:
virtual bool RequestOverfill(mozilla::dom::OverfillCallback* aCallback) MOZ_OVERRIDE;
virtual void RunOverfillCallback(const uint32_t aOverfill) MOZ_OVERRIDE;
virtual void DidComposite();
virtual void DidComposite(uint64_t aTransactionId);
virtual bool SupportsMixBlendModes(EnumSet<gfx::CompositionOp>& aMixBlendModes) MOZ_OVERRIDE
{

View File

@ -124,15 +124,15 @@ CompositorChild::RecvInvalidateAll()
}
bool
CompositorChild::RecvDidComposite(const uint64_t& aId)
CompositorChild::RecvDidComposite(const uint64_t& aId, const uint64_t& aTransactionId)
{
if (mLayerManager) {
MOZ_ASSERT(aId == 0);
mLayerManager->DidComposite();
mLayerManager->DidComposite(aTransactionId);
} else if (aId != 0) {
dom::TabChild *child = dom::TabChild::GetFrom(aId);
if (child) {
child->DidComposite();
child->DidComposite(aTransactionId);
}
}
return true;

View File

@ -58,7 +58,7 @@ public:
virtual bool RecvOverfill(const uint32_t &aOverfill) MOZ_OVERRIDE;
void AddOverfillObserver(ClientLayerManager* aLayerManager);
virtual bool RecvDidComposite(const uint64_t& aId) MOZ_OVERRIDE;
virtual bool RecvDidComposite(const uint64_t& aId, const uint64_t& aTransactionId) MOZ_OVERRIDE;
private:
// Private destructor, to discourage deletion outside of Release():

View File

@ -66,6 +66,7 @@ CompositorParent::LayerTreeState::LayerTreeState()
: mParent(nullptr)
, mLayerManager(nullptr)
, mCrossProcessParent(nullptr)
, mLayerTree(nullptr)
{
}
@ -193,6 +194,7 @@ CompositorParent::CompositorParent(nsIWidget* aWidget,
: mWidget(aWidget)
, mCurrentCompositeTask(nullptr)
, mIsTesting(false)
, mPendingTransaction(0)
, mPaused(false)
, mUseExternalSurfaceSize(aUseExternalSurfaceSize)
, mEGLSurfaceSize(aSurfaceWidth, aSurfaceHeight)
@ -200,7 +202,6 @@ CompositorParent::CompositorParent(nsIWidget* aWidget,
, mResumeCompositionMonitor("ResumeCompositionMonitor")
, mOverrideComposeReadiness(false)
, mForceCompositionTask(nullptr)
, mWantDidCompositeEvent(false)
{
NS_ABORT_IF_FALSE(sCompositorThread != nullptr || sCompositorThreadID,
"The compositor thread must be Initialized before instanciating a COmpositorParent.");
@ -443,7 +444,7 @@ CompositorParent::ResumeComposition()
mPaused = false;
Composite();
CompositeToTarget(nullptr);
// if anyone's waiting to make sure that composition really got resumed, tell them
lock.NotifyAll();
@ -541,8 +542,6 @@ CompositorParent::NotifyShadowTreeTransaction(uint64_t aId, bool aIsFirstPaint,
if (aScheduleComposite) {
ScheduleComposition();
}
mWantDidCompositeEvent = true;
}
// Used when layout.frame_rate is -1. Needs to be kept in sync with
@ -585,7 +584,7 @@ CompositorParent::ScheduleComposition()
rate == 0 ? 0.0 : std::max(0.0, 1000.0 / rate));
mCurrentCompositeTask = NewRunnableMethod(this, &CompositorParent::Composite);
mCurrentCompositeTask = NewRunnableMethod(this, &CompositorParent::CompositeCallback);
if (!initialComposition && delta < minFrameDelta) {
TimeDuration delay = minFrameDelta - delta;
@ -602,8 +601,9 @@ CompositorParent::ScheduleComposition()
}
void
CompositorParent::Composite()
CompositorParent::CompositeCallback()
{
mCurrentCompositeTask = nullptr;
CompositeToTarget(nullptr);
}
@ -624,11 +624,6 @@ CompositorParent::CompositeToTarget(DrawTarget* aTarget, const nsIntRect* aRect)
}
#endif
if (mCurrentCompositeTask) {
mCurrentCompositeTask->Cancel();
mCurrentCompositeTask = nullptr;
}
mLastCompose = TimeStamp::Now();
if (!CanComposite()) {
@ -672,9 +667,8 @@ CompositorParent::CompositeToTarget(DrawTarget* aTarget, const nsIntRect* aRect)
mLayerManager->SetDebugOverlayWantsNextFrame(false);
mLayerManager->EndEmptyTransaction();
if (!aTarget && mWantDidCompositeEvent) {
if (!aTarget) {
DidComposite();
mWantDidCompositeEvent = false;
}
if (mLayerManager->DebugOverlayWantsNextFrame()) {
@ -704,20 +698,6 @@ CompositorParent::CompositeToTarget(DrawTarget* aTarget, const nsIntRect* aRect)
profiler_tracing("Paint", "Composite", TRACING_INTERVAL_END);
}
void
CompositorParent::DidComposite()
{
unused << SendDidComposite(0);
for (LayerTreeMap::iterator it = sIndirectLayerTrees.begin();
it != sIndirectLayerTrees.end(); it++) {
LayerTreeState* lts = &it->second;
if (lts->mParent == this && lts->mCrossProcessParent) {
unused << lts->mCrossProcessParent->SendDidComposite(it->first);
}
}
}
void
CompositorParent::ForceComposeToTarget(DrawTarget* aTarget, const nsIntRect* aRect)
{
@ -773,6 +753,7 @@ CompositorParent::ScheduleRotationOnCompositorThread(const TargetConfig& aTarget
void
CompositorParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
const uint64_t& aTransactionId,
const TargetConfig& aTargetConfig,
bool aIsFirstPaint,
bool aScheduleComposite,
@ -795,6 +776,7 @@ CompositorParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
mApzcTreeManager->UpdatePanZoomControllerTree(this, root, aIsFirstPaint,
mRootLayerTreeID, aPaintSequenceNumber);
}
mPendingTransaction = aTransactionId;
if (root) {
SetShadowProperties(root);
@ -817,7 +799,6 @@ CompositorParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
}
}
mLayerManager->NotifyShadowTreeTransaction();
mWantDidCompositeEvent = true;
}
void
@ -1151,6 +1132,7 @@ public:
virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) MOZ_OVERRIDE;
virtual void ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
const uint64_t& aTransactionId,
const TargetConfig& aTargetConfig,
bool aIsFirstPaint,
bool aScheduleComposite,
@ -1164,6 +1146,7 @@ public:
virtual AsyncCompositionManager* GetCompositionManager(LayerTransactionParent* aParent) MOZ_OVERRIDE;
void DidComposite(uint64_t aId);
private:
// Private destructor, to discourage deletion outside of Release():
virtual ~CrossProcessCompositorParent();
@ -1179,6 +1162,23 @@ private:
base::ProcessId mChildProcessId;
};
void
CompositorParent::DidComposite()
{
if (mPendingTransaction) {
unused << SendDidComposite(0, mPendingTransaction);
mPendingTransaction = 0;
}
for (LayerTreeMap::iterator it = sIndirectLayerTrees.begin();
it != sIndirectLayerTrees.end(); it++) {
LayerTreeState* lts = &it->second;
if (lts->mParent == this && lts->mCrossProcessParent) {
static_cast<CrossProcessCompositorParent*>(lts->mCrossProcessParent)->DidComposite(it->first);
}
}
}
static void
OpenCompositor(CrossProcessCompositorParent* aCompositor,
Transport* aTransport, ProcessHandle aHandle,
@ -1280,6 +1280,7 @@ CrossProcessCompositorParent::AllocPLayerTransactionParent(const nsTArray<Layers
*aSuccess = true;
LayerTransactionParent* p = new LayerTransactionParent(lm, this, aId, mChildProcessId);
p->AddIPDLReference();
sIndirectLayerTrees[aId].mLayerTree = p;
return p;
}
@ -1317,6 +1318,7 @@ CrossProcessCompositorParent::RecvNotifyChildCreated(const uint64_t& child)
void
CrossProcessCompositorParent::ShadowLayersUpdated(
LayerTransactionParent* aLayerTree,
const uint64_t& aTransactionId,
const TargetConfig& aTargetConfig,
bool aIsFirstPaint,
bool aScheduleComposite,
@ -1341,6 +1343,17 @@ CrossProcessCompositorParent::ShadowLayersUpdated(
state->mParent->NotifyShadowTreeTransaction(id, aIsFirstPaint, aScheduleComposite,
aPaintSequenceNumber);
aLayerTree->SetPendingTransactionId(aTransactionId);
}
void
CrossProcessCompositorParent::DidComposite(uint64_t aId)
{
LayerTransactionParent *layerTree = sIndirectLayerTrees[aId].mLayerTree;
if (layerTree && layerTree->GetPendingTransactionId()) {
unused << SendDidComposite(aId, layerTree->GetPendingTransactionId());
layerTree->SetPendingTransactionId(0);
}
}
void

View File

@ -96,6 +96,7 @@ public:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
virtual void ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
const uint64_t& aTransactionId,
const TargetConfig& aTargetConfig,
bool aIsFirstPaint,
bool aScheduleComposite,
@ -226,6 +227,7 @@ public:
PCompositorParent* mCrossProcessParent;
TargetConfig mTargetConfig;
APZTestData mApzTestData;
LayerTransactionParent* mLayerTree;
};
/**
@ -253,7 +255,7 @@ private:
bool* aSuccess) MOZ_OVERRIDE;
virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) MOZ_OVERRIDE;
virtual void ScheduleTask(CancelableTask*, int);
void Composite();
void CompositeCallback();
void CompositeToTarget(gfx::DrawTarget* aTarget, const nsIntRect* aRect = nullptr);
void ForceComposeToTarget(gfx::DrawTarget* aTarget, const nsIntRect* aRect = nullptr);
@ -327,6 +329,8 @@ private:
TimeStamp mExpectedComposeStartTime;
#endif
uint64_t mPendingTransaction;
bool mPaused;
bool mUseExternalSurfaceSize;
@ -343,8 +347,6 @@ private:
nsRefPtr<APZCTreeManager> mApzcTreeManager;
bool mWantDidCompositeEvent;
DISALLOW_EVIL_CONSTRUCTORS(CompositorParent);
};

View File

@ -148,6 +148,7 @@ LayerTransactionParent::LayerTransactionParent(LayerManagerComposite* aManager,
: mLayerManager(aManager)
, mShadowLayersManager(aLayersManager)
, mId(aId)
, mPendingTransaction(0)
, mChildProcessId(aOtherProcess)
, mDestroyed(false)
, mIPCOpen(false)
@ -179,17 +180,19 @@ LayerTransactionParent::GetCompositorBackendType() const
bool
LayerTransactionParent::RecvUpdateNoSwap(const InfallibleTArray<Edit>& cset,
const uint64_t& aTransactionId,
const TargetConfig& targetConfig,
const bool& isFirstPaint,
const bool& scheduleComposite,
const uint32_t& paintSequenceNumber)
{
return RecvUpdate(cset, targetConfig, isFirstPaint, scheduleComposite,
paintSequenceNumber, nullptr);
return RecvUpdate(cset, aTransactionId, targetConfig, isFirstPaint,
scheduleComposite, paintSequenceNumber, nullptr);
}
bool
LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
const uint64_t& aTransactionId,
const TargetConfig& targetConfig,
const bool& isFirstPaint,
const bool& scheduleComposite,
@ -549,8 +552,8 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
// other's buffer contents.
LayerManagerComposite::PlatformSyncBeforeReplyUpdate();
mShadowLayersManager->ShadowLayersUpdated(this, targetConfig, isFirstPaint,
scheduleComposite, paintSequenceNumber);
mShadowLayersManager->ShadowLayersUpdated(this, aTransactionId, targetConfig,
isFirstPaint, scheduleComposite, paintSequenceNumber);
#ifdef COMPOSITOR_PERFORMANCE_WARNING
int compositeTime = (int)(mozilla::TimeStamp::Now() - updateStart).ToMilliseconds();

View File

@ -81,6 +81,9 @@ public:
virtual bool IsSameProcess() const MOZ_OVERRIDE;
const uint64_t& GetPendingTransactionId() { return mPendingTransaction; }
void SetPendingTransactionId(uint64_t aId) { mPendingTransaction = aId; }
// CompositableParentManager
virtual void SendFenceHandle(AsyncTransactionTracker* aTracker,
PTextureParent* aTexture,
@ -95,6 +98,7 @@ public:
protected:
virtual bool RecvUpdate(const EditArray& cset,
const uint64_t& aTransactionId,
const TargetConfig& targetConfig,
const bool& isFirstPaint,
const bool& scheduleComposite,
@ -102,6 +106,7 @@ protected:
EditReplyArray* reply) MOZ_OVERRIDE;
virtual bool RecvUpdateNoSwap(const EditArray& cset,
const uint64_t& aTransactionId,
const TargetConfig& targetConfig,
const bool& isFirstPaint,
const bool& scheduleComposite,
@ -164,6 +169,8 @@ private:
// mId != 0 => mRoot == null
// because the "real tree" is owned by the compositor.
uint64_t mId;
uint64_t mPendingTransaction;
// When the widget/frame/browser stuff in this process begins its
// destruction process, we need to Disconnect() all the currently
// live shadow layers, because some of them might be orphaned from

View File

@ -42,7 +42,7 @@ child:
// The compositor completed a layers transaction. id is the layers id
// of the child layer tree that was composited (or 0 when notifying
// the root layer tree).
async DidComposite(uint64_t id);
async DidComposite(uint64_t id, uint64_t transactionId);
// The parent sends the child the requested fill ratio numbers.
async Overfill(uint32_t aOverfill);

View File

@ -52,9 +52,14 @@ parent:
// The isFirstPaint flag can be used to indicate that this is the first update
// for a particular document.
sync Update(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint,
sync Update(Edit[] cset, uint64_t id, TargetConfig targetConfig, bool isFirstPaint,
bool scheduleComposite, uint32_t paintSequenceNumber)
returns (EditReply[] reply);
// We don't need to send a sync transaction if
// no transaction operate require a swap.
async UpdateNoSwap(Edit[] cset, uin64_t id, TargetConfig targetConfig, bool isFirstPaint,
bool scheduleComposite, uint32_t paintSequenceNumber);
// Testing APIs
@ -78,11 +83,6 @@ parent:
// Useful for testing rendering of async scrolling.
async SetAsyncScrollOffset(PLayer layer, int32_t x, int32_t y);
// We don't need to send a sync transaction if
// no transaction operate require a swap.
async UpdateNoSwap(Edit[] cset, TargetConfig targetConfig, bool isFirstPaint,
bool scheduleComposite, uint32_t paintSequenceNumber);
// Drop any front buffers that might be retained on the compositor
// side.
async ClearCachedResources();

View File

@ -451,12 +451,15 @@ ShadowLayerForwarder::RemoveTexture(TextureClient* aTexture)
bool
ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
const nsIntRegion& aRegionToClear,
uint64_t aId,
bool aScheduleComposite,
uint32_t aPaintSequenceNumber,
bool* aSent)
{
*aSent = false;
MOZ_ASSERT(aId);
PROFILER_LABEL("ShadowLayerForwarder", "EndTranscation");
RenderTraceScope rendertrace("Foward Transaction", "000091");
NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to");
@ -562,7 +565,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
RenderTraceScope rendertrace3("Forward Transaction", "000093");
if (!HasShadowManager() ||
!mShadowManager->IPCOpen() ||
!mShadowManager->SendUpdate(cset, targetConfig, mIsFirstPaint,
!mShadowManager->SendUpdate(cset, aId, targetConfig, mIsFirstPaint,
aScheduleComposite, aPaintSequenceNumber,
aReplies)) {
MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
@ -575,7 +578,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
RenderTraceScope rendertrace3("Forward NoSwap Transaction", "000093");
if (!HasShadowManager() ||
!mShadowManager->IPCOpen() ||
!mShadowManager->SendUpdateNoSwap(cset, targetConfig, mIsFirstPaint,
!mShadowManager->SendUpdateNoSwap(cset, aId, targetConfig, mIsFirstPaint,
aPaintSequenceNumber, aScheduleComposite)) {
MOZ_LAYERS_LOG(("[LayersForwarder] WARNING: sending transaction failed!"));
return false;

View File

@ -295,6 +295,7 @@ public:
*/
bool EndTransaction(InfallibleTArray<EditReply>* aReplies,
const nsIntRegion& aRegionToClear,
uint64_t aId,
bool aScheduleComposite,
uint32_t aPaintSequenceNumber,
bool* aSent);

View File

@ -19,6 +19,7 @@ class ShadowLayersManager
{
public:
virtual void ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
const uint64_t& aTransactionId,
const TargetConfig& aTargetConfig,
bool aIsFirstPaint,
bool aScheduleComposite,

View File

@ -809,6 +809,7 @@ RenderFrameParent::ContentViewScaleChanged(nsContentView* aView)
void
RenderFrameParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
const uint64_t& aTransactionId,
const TargetConfig& aTargetConfig,
bool aIsFirstPaint,
bool aScheduleComposite,

View File

@ -79,6 +79,7 @@ public:
void ContentViewScaleChanged(nsContentView* aView);
virtual void ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
const uint64_t& aTransactionId,
const TargetConfig& aTargetConfig,
bool aIsFirstPaint,
bool aScheduleComposite,