Bug 1128691. Part 1: Consolidate vsync compositor pref checks. r=benwa

This commit is contained in:
Mason Chang 2015-02-04 13:08:31 -08:00
parent ce170cb3f3
commit 75dbe45832

View File

@ -416,6 +416,7 @@ CompositorParent::CompositorParent(nsIWidget* aWidget,
, mOverrideComposeReadiness(false)
, mForceCompositionTask(nullptr)
, mCompositorThreadHolder(sCompositorThreadHolder)
, mCompositorVsyncObserver(nullptr)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(CompositorThread(),
@ -577,7 +578,7 @@ CompositorParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
bool
CompositorParent::RecvFlushRendering()
{
if (gfxPrefs::VsyncAlignedCompositor() && mCompositorVsyncObserver->NeedsComposite()) {
if (mCompositorVsyncObserver && mCompositorVsyncObserver->NeedsComposite()) {
mCompositorVsyncObserver->SetNeedsComposite(false);
CancelCurrentCompositeTask();
ForceComposeToTarget(nullptr);
@ -718,7 +719,7 @@ CompositorParent::ForceComposition()
void
CompositorParent::CancelCurrentCompositeTask()
{
if (gfxPrefs::VsyncAlignedCompositor()) {
if (mCompositorVsyncObserver) {
mCompositorVsyncObserver->CancelCurrentCompositeTask();
} else if (mCurrentCompositeTask) {
mCurrentCompositeTask->Cancel();
@ -831,7 +832,7 @@ CalculateCompositionFrameRate()
void
CompositorParent::ScheduleSoftwareTimerComposition()
{
MOZ_ASSERT(!gfxPrefs::VsyncAlignedCompositor());
MOZ_ASSERT(!mCompositorVsyncObserver);
if (mCurrentCompositeTask) {
return;
@ -874,7 +875,7 @@ CompositorParent::ScheduleComposition()
return;
}
if (gfxPrefs::VsyncAlignedCompositor()) {
if (mCompositorVsyncObserver) {
mCompositorVsyncObserver->SetNeedsComposite(true);
} else {
ScheduleSoftwareTimerComposition();
@ -884,7 +885,7 @@ CompositorParent::ScheduleComposition()
void
CompositorParent::CompositeCallback(TimeStamp aScheduleTime)
{
if (gfxPrefs::VsyncAlignedCompositor()) {
if (mCompositorVsyncObserver) {
// Align OMTA to vsync time.
// TODO: ensure it aligns with the refresh / start time of
// animations
@ -1097,7 +1098,7 @@ CompositorParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
// conditions.
bool needTestComposite = mIsTesting && root &&
(mCurrentCompositeTask ||
(gfxPrefs::VsyncAlignedCompositor() &&
(mCompositorVsyncObserver &&
mCompositorVsyncObserver->NeedsComposite()));
if (needTestComposite) {
AutoResolveRefLayers resolve(mCompositionManager);
@ -1131,7 +1132,7 @@ CompositorParent::SetTestSampleTime(LayerTransactionParent* aLayerTree,
mTestTime = aTime;
bool testComposite = mCompositionManager && (mCurrentCompositeTask ||
(gfxPrefs::VsyncAlignedCompositor()
(mCompositorVsyncObserver
&& mCompositorVsyncObserver->NeedsComposite()));
// Update but only if we were already scheduled to animate