gfx/ipc/CompositorWidgetVsyncObserver.cpp
author David Anderson <danderson@mozilla.com>
Tue, 19 Jul 2016 11:56:07 -0700
changeset 347842 3fdb8ca3e6ffbd310daf342eb8febb1c17938dd0
child 442275 5f74d262924171a8fa0b4483a64f4cac34c4c9b8
permissions -rw-r--r--
Implement vsync notification for remote compositors. (bug 1285625 part 3, r=mchang)

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=99: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "CompositorWidgetVsyncObserver.h"
#include "mozilla/gfx/VsyncBridgeChild.h"

namespace mozilla {
namespace widget {

CompositorWidgetVsyncObserver::CompositorWidgetVsyncObserver(
    RefPtr<VsyncBridgeChild> aVsyncBridge,
    const uint64_t& aRootLayerTreeId)
 : mVsyncBridge(aVsyncBridge),
   mRootLayerTreeId(aRootLayerTreeId)
{
  MOZ_ASSERT(XRE_IsParentProcess());
  MOZ_ASSERT(NS_IsMainThread());
}

bool
CompositorWidgetVsyncObserver::NotifyVsync(TimeStamp aTimeStamp)
{
  // Vsync notifications should only arrive on the vsync thread.
  MOZ_ASSERT(XRE_IsParentProcess());
  MOZ_ASSERT(!NS_IsMainThread());

  mVsyncBridge->NotifyVsync(aTimeStamp, mRootLayerTreeId);
  return true;
}

} // namespace widget
} // namespace mozilla