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 "HeadlessCompositorWidget.h"
7 #include "HeadlessWidget.h"
8 #include "mozilla/widget/PlatformWidgetTypes.h"
10 #include "InProcessGtkCompositorWidget.h"
11 #include "VsyncDispatcher.h"
14 namespace mozilla::widget
{
17 RefPtr
<CompositorWidget
> CompositorWidget::CreateLocal(
18 const CompositorWidgetInitData
& aInitData
,
19 const layers::CompositorOptions
& aOptions
, nsIWidget
* aWidget
) {
20 if (aInitData
.type() ==
21 CompositorWidgetInitData::THeadlessCompositorWidgetInitData
) {
22 return new HeadlessCompositorWidget(
23 aInitData
.get_HeadlessCompositorWidgetInitData(), aOptions
,
24 static_cast<HeadlessWidget
*>(aWidget
));
26 return new InProcessGtkCompositorWidget(
27 aInitData
.get_GtkCompositorWidgetInitData(), aOptions
,
28 static_cast<nsWindow
*>(aWidget
));
32 InProcessGtkCompositorWidget::InProcessGtkCompositorWidget(
33 const GtkCompositorWidgetInitData
& aInitData
,
34 const layers::CompositorOptions
& aOptions
, nsWindow
* aWindow
)
35 : GtkCompositorWidget(aInitData
, aOptions
, aWindow
) {}
37 void InProcessGtkCompositorWidget::ObserveVsync(VsyncObserver
* aObserver
) {
38 if (RefPtr
<CompositorVsyncDispatcher
> cvd
=
39 mWidget
->GetCompositorVsyncDispatcher()) {
40 cvd
->SetCompositorVsyncObserver(aObserver
);
44 } // namespace mozilla::widget