Bug 980207 - When the refresh driver is under test control, make compositor thread only update when a composite is scheduled; r=dzbarsky

In order to make test behavior better match real-world sampling behavior, this
patch updates the test code in CompositorParent so that it only updates the
layer when a composite is scheduled. This enables creating mochitests that
reproduce bugs observed in regular usage.
This commit is contained in:
Brian Birtles 2014-03-10 13:47:12 +09:00
Родитель 730325e4c1
Коммит 73dcc15d98
2 изменённых файлов: 32 добавлений и 7 удалений

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

@ -330,8 +330,7 @@ CompositorParent::RecvFlushRendering()
// If we're waiting to do a composite, then cancel it
// and do it immediately instead.
if (mCurrentCompositeTask) {
mCurrentCompositeTask->Cancel();
mCurrentCompositeTask = nullptr;
CancelCurrentCompositeTask();
ForceComposeToTarget(nullptr);
}
return true;
@ -376,9 +375,15 @@ CompositorParent::RecvSetTestSampleTime(const TimeStamp& aTime)
mIsTesting = true;
mTestTime = aTime;
if (mCompositionManager) {
mCompositionManager->TransformShadowTree(aTime);
// Update but only if we were already scheduled to animate
if (mCompositionManager && mCurrentCompositeTask) {
bool requestNextFrame = mCompositionManager->TransformShadowTree(aTime);
if (!requestNextFrame) {
CancelCurrentCompositeTask();
}
}
return true;
}
@ -464,6 +469,15 @@ CompositorParent::ForceComposition()
ScheduleRenderOnCompositorThread();
}
void
CompositorParent::CancelCurrentCompositeTask()
{
if (mCurrentCompositeTask) {
mCurrentCompositeTask->Cancel();
mCurrentCompositeTask = nullptr;
}
}
void
CompositorParent::SetEGLSurfaceSize(int width, int height)
{
@ -757,12 +771,22 @@ CompositorParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
if (root) {
SetShadowProperties(root);
if (mIsTesting) {
mCompositionManager->TransformShadowTree(mTestTime);
}
}
if (aScheduleComposite) {
ScheduleComposition();
// When testing we synchronously update the shadow tree with the animated
// values to avoid race conditions when calling GetAnimationTransform etc.
// (since the above SetShadowProperties will remove animation effects).
// However, we only do this update when a composite operation is already
// scheduled in order to better match the behavior under regular sampling
// conditions.
if (mIsTesting && root && mCurrentCompositeTask) {
bool requestNextFrame =
mCompositionManager->TransformShadowTree(mTestTime);
if (!requestNextFrame) {
CancelCurrentCompositeTask();
}
}
}
mLayerManager->NotifyShadowTreeTransaction();
}

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

@ -249,6 +249,7 @@ private:
void ResumeComposition();
void ResumeCompositionAndResize(int width, int height);
void ForceComposition();
void CancelCurrentCompositeTask();
inline static PlatformThreadId CompositorThreadID();