Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/widget/gtk/GtkCompositorWidget.cpp
Line
Count
Source (jump to first uncovered line)
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/. */
5
6
#include "GtkCompositorWidget.h"
7
8
#include "gfxPlatformGtk.h"
9
#include "mozilla/layers/CompositorThread.h"
10
#include "mozilla/widget/InProcessCompositorWidget.h"
11
#include "mozilla/widget/PlatformWidgetTypes.h"
12
#include "nsWindow.h"
13
14
namespace mozilla {
15
namespace widget {
16
17
GtkCompositorWidget::GtkCompositorWidget(const GtkCompositorWidgetInitData& aInitData,
18
                                         const layers::CompositorOptions& aOptions,
19
                                         nsWindow* aWindow)
20
      : CompositorWidget(aOptions)
21
      , mWidget(aWindow)
22
0
{
23
0
  // If we have a nsWindow, then grab the already existing display connection
24
0
  // If we don't, then use the init data to connect to the display
25
0
  if (aWindow) {
26
0
    mXDisplay = aWindow->XDisplay();
27
0
  } else {
28
0
    mXDisplay = XOpenDisplay(aInitData.XDisplayString().get());
29
0
  }
30
0
31
#ifdef MOZ_WAYLAND
32
  if (!mXDisplay) {
33
    MOZ_RELEASE_ASSERT(aWindow,
34
      "We're running on Wayland and but without valid nsWindow.");
35
    mProvider.Initialize(aWindow);
36
  } else
37
#endif
38
  {
39
0
    mXWindow = (Window)aInitData.XWindow();
40
0
41
0
    // Grab the window's visual and depth
42
0
    XWindowAttributes windowAttrs;
43
0
    if (!XGetWindowAttributes(mXDisplay, mXWindow, &windowAttrs)) {
44
0
      NS_WARNING("GtkCompositorWidget(): XGetWindowAttributes() failed!");
45
0
    }
46
0
47
0
    Visual*   visual = windowAttrs.visual;
48
0
    int       depth = windowAttrs.depth;
49
0
50
0
    // Initialize the window surface provider
51
0
    mProvider.Initialize(
52
0
      mXDisplay,
53
0
      mXWindow,
54
0
      visual,
55
0
      depth,
56
0
      aInitData.Shaped());
57
0
  }
58
0
  mClientSize = aInitData.InitialClientSize();
59
0
}
60
61
GtkCompositorWidget::~GtkCompositorWidget()
62
0
{
63
0
  mProvider.CleanupResources();
64
0
65
0
  // If we created our own display connection, we need to destroy it
66
0
  if (!mWidget && mXDisplay) {
67
0
    XCloseDisplay(mXDisplay);
68
0
    mXDisplay = nullptr;
69
0
  }
70
0
}
71
72
already_AddRefed<gfx::DrawTarget>
73
GtkCompositorWidget::StartRemoteDrawing()
74
0
{
75
0
  return nullptr;
76
0
}
77
void
78
GtkCompositorWidget::EndRemoteDrawing()
79
0
{
80
0
}
81
82
already_AddRefed<gfx::DrawTarget>
83
GtkCompositorWidget::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
84
                                                layers::BufferMode* aBufferMode)
85
0
{
86
0
  return mProvider.StartRemoteDrawingInRegion(aInvalidRegion,
87
0
                                              aBufferMode);
88
0
}
89
90
void GtkCompositorWidget::EndRemoteDrawingInRegion(gfx::DrawTarget* aDrawTarget,
91
                              LayoutDeviceIntRegion& aInvalidRegion)
92
0
{
93
0
  mProvider.EndRemoteDrawingInRegion(aDrawTarget,
94
0
                                     aInvalidRegion);
95
0
}
96
97
nsIWidget* GtkCompositorWidget::RealWidget()
98
0
{
99
0
  return mWidget;
100
0
}
101
102
void
103
GtkCompositorWidget::NotifyClientSizeChanged(const LayoutDeviceIntSize& aClientSize)
104
0
{
105
0
  mClientSize = aClientSize;
106
0
}
107
108
LayoutDeviceIntSize
109
GtkCompositorWidget::GetClientSize()
110
0
{
111
0
  return mClientSize;
112
0
}
113
114
uintptr_t
115
GtkCompositorWidget::GetWidgetKey()
116
0
{
117
0
  return reinterpret_cast<uintptr_t>(mWidget);
118
0
}
119
120
} // namespace widget
121
} // namespace mozilla