Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / widget / headless / HeadlessCompositorWidget.cpp
blobbb4ee9175e66dc40de1871a7f91368fe309494a3
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/widget/PlatformWidgetTypes.h"
7 #include "HeadlessCompositorWidget.h"
8 #include "VsyncDispatcher.h"
10 namespace mozilla {
11 namespace widget {
13 HeadlessCompositorWidget::HeadlessCompositorWidget(
14 const HeadlessCompositorWidgetInitData& aInitData,
15 const layers::CompositorOptions& aOptions, HeadlessWidget* aWindow)
16 : CompositorWidget(aOptions),
17 mWidget(aWindow),
18 mClientSize(LayoutDeviceIntSize(aInitData.InitialClientSize()),
19 "HeadlessCompositorWidget::mClientSize") {}
21 void HeadlessCompositorWidget::ObserveVsync(VsyncObserver* aObserver) {
22 if (RefPtr<CompositorVsyncDispatcher> cvd =
23 mWidget->GetCompositorVsyncDispatcher()) {
24 cvd->SetCompositorVsyncObserver(aObserver);
28 nsIWidget* HeadlessCompositorWidget::RealWidget() { return mWidget; }
30 void HeadlessCompositorWidget::NotifyClientSizeChanged(
31 const LayoutDeviceIntSize& aClientSize) {
32 auto size = mClientSize.Lock();
33 *size = aClientSize;
36 LayoutDeviceIntSize HeadlessCompositorWidget::GetClientSize() {
37 auto size = mClientSize.Lock();
38 return *size;
41 uintptr_t HeadlessCompositorWidget::GetWidgetKey() {
42 return reinterpret_cast<uintptr_t>(mWidget);
45 } // namespace widget
46 } // namespace mozilla