qeglfswindow.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/eglfs/qeglfswindow.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5QEglFSWindow::QEglFSWindow(QWindow *w)-
6 : QPlatformWindow(w),-
7 m_backingStore(0),-
8 m_raster(false),-
9 m_winId(0),-
10 m_surface(((EGLSurface)0)),-
11 m_window(0),-
12 m_flags(0)-
13{-
14}
never executed: end of block
0
15-
16QEglFSWindow::~QEglFSWindow()-
17{-
18 destroy();-
19}
never executed: end of block
0
20-
21static WId newWId()-
22{-
23 static WId id = 0;-
24-
25 if (id == std::numeric_limits<WId>::max()
id == std::num...ts<WId>::max()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
26 QMessageLogger(__FILE__, 76, __PRETTY_FUNCTION__).warning("QEGLPlatformWindow: Out of window IDs");
never executed: QMessageLogger(__FILE__, 76, __PRETTY_FUNCTION__).warning("QEGLPlatformWindow: Out of window IDs");
0
27-
28 return
never executed: return ++id;
++id;
never executed: return ++id;
0
29}-
30-
31void QEglFSWindow::create()-
32{-
33 if (m_flags.testFlag(Created)
m_flags.testFlag(Created)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
34 return;
never executed: return;
0
35-
36 m_winId = newWId();-
37-
38-
39 m_raster = (window()->surfaceType() == QSurface::RasterSurface);-
40 if (m_raster
m_rasterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
41 window()->setSurfaceType(QSurface::OpenGLSurface);
never executed: window()->setSurfaceType(QSurface::OpenGLSurface);
0
42-
43 if (window()->type() == Qt::Desktop
window()->type...== Qt::DesktopDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
44 QRect fullscreenRect(QPoint(), screen()->availableGeometry().size());-
45 QPlatformWindow::setGeometry(fullscreenRect);-
46 QWindowSystemInterface::handleGeometryChange(window(), fullscreenRect);-
47 return;
never executed: return;
0
48 }-
49-
50 m_flags = Created;-
51-
52 if (window()->type() == Qt::Desktop
window()->type...== Qt::DesktopDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
53 return;
never executed: return;
0
54-
55-
56-
57-
58 QEglFSScreen *screen = this->screen();-
59 QOpenGLCompositor *compositor = QOpenGLCompositor::instance();-
60 if (screen->primarySurface() != ((EGLSurface)0)
screen->primar...(EGLSurface)0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
61 if (__builtin_expect(!!(!isRaster() || !compositor->targetWindow()), false)
__builtin_expe...dow()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
62-
63-
64-
65 QMessageLogger(__FILE__, 115, __PRETTY_FUNCTION__).fatal("EGLFS: OpenGL windows cannot be mixed with others.");-
66-
67 return;
never executed: return;
0
68 }-
69 m_format = compositor->targetWindow()->format();-
70 return;
never executed: return;
0
71 }-
72-
73 m_flags |= HasNativeWindow;-
74 setGeometry(QRect());-
75 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size()));-
76-
77 resetSurface();-
78-
79 if (__builtin_expect(!!(m_surface == ((EGLSurface)0)), false)
__builtin_expe...ce)0)), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
80 EGLint error = eglGetError();-
81 eglTerminate(screen->display());-
82 QMessageLogger(__FILE__, 132, __PRETTY_FUNCTION__).fatal("EGL Error : Could not create the egl surface: error = 0x%x\n", error);-
83 }
never executed: end of block
0
84-
85 screen->setPrimarySurface(m_surface);-
86-
87 if (isRaster()
isRaster()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
88 QOpenGLContext *context = new QOpenGLContext(QGuiApplication::instance());-
89 context->setShareContext(qt_gl_global_share_context());-
90 context->setFormat(m_format);-
91 context->setScreen(window()->screen());-
92 if (__builtin_expect(!!(!context->create()), false)
__builtin_expe...ate()), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
93 QMessageLogger(__FILE__, 143, __PRETTY_FUNCTION__).fatal("EGLFS: Failed to create compositing context");
never executed: QMessageLogger(__FILE__, 143, __PRETTY_FUNCTION__).fatal("EGLFS: Failed to create compositing context");
0
94 compositor->setTarget(context, window());-
95-
96-
97 if (!qt_gl_global_share_context()
!qt_gl_global_share_context()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
98 qt_gl_set_global_share_context(context);-
99-
100-
101 QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);-
102 }
never executed: end of block
0
103 }
never executed: end of block
0
104}
never executed: end of block
0
105-
106void QEglFSWindow::destroy()-
107{-
108 QEglFSScreen *screen = this->screen();-
109 if (m_flags.testFlag(HasNativeWindow)
m_flags.testFl...sNativeWindow)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
110 QEglFSCursor *cursor = qobject_cast<QEglFSCursor *>(screen->cursor());-
111 if (cursor
cursorDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
112 cursor->resetResources();
never executed: cursor->resetResources();
0
113-
114 if (screen->primarySurface() == m_surface
screen->primar...) == m_surfaceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
115 screen->setPrimarySurface(((EGLSurface)0));
never executed: screen->setPrimarySurface(((EGLSurface)0));
0
116-
117 invalidateSurface();-
118 }
never executed: end of block
0
119-
120 m_flags = 0;-
121 QOpenGLCompositor::instance()->removeWindow(this);-
122}
never executed: end of block
0
123-
124void QEglFSWindow::invalidateSurface()-
125{-
126 if (m_surface != ((EGLSurface)0)
m_surface != ((EGLSurface)0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
127 eglDestroySurface(screen()->display(), m_surface);-
128 m_surface = ((EGLSurface)0);-
129 }
never executed: end of block
0
130 qt_egl_device_integration()->destroyNativeWindow(m_window);-
131 m_window = 0;-
132}
never executed: end of block
0
133-
134void QEglFSWindow::resetSurface()-
135{-
136 EGLDisplay display = screen()->display();-
137 QSurfaceFormat platformFormat = qt_egl_device_integration()->surfaceFormatFor(window()->requestedFormat());-
138-
139 m_config = QEglFSIntegration::chooseConfig(display, platformFormat);-
140 m_format = q_glFormatFromConfig(display, m_config, platformFormat);-
141 m_window = qt_egl_device_integration()->createNativeWindow(this, screen()->geometry().size(), m_format);-
142 m_surface = eglCreateWindowSurface(display, m_config, m_window, __null);-
143}
never executed: end of block
0
144-
145void QEglFSWindow::setVisible(bool visible)-
146{-
147 QOpenGLCompositor *compositor = QOpenGLCompositor::instance();-
148 QList<QOpenGLCompositorWindow *> windows = compositor->windows();-
149 QWindow *wnd = window();-
150-
151 if (wnd->type() != Qt::Desktop
wnd->type() != Qt::DesktopDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
152 if (visible
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
153 compositor->addWindow(this);-
154 }
never executed: end of block
else {
0
155 compositor->removeWindow(this);-
156 windows = compositor->windows();-
157 if (windows.size()
windows.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
158 windows.last()->sourceWindow()->requestActivate();
never executed: windows.last()->sourceWindow()->requestActivate();
0
159 }
never executed: end of block
0
160 }-
161-
162 QWindowSystemInterface::handleExposeEvent(wnd, QRect(QPoint(0, 0), wnd->geometry().size()));-
163-
164 if (visible
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
165 QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
never executed: QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
0
166}
never executed: end of block
0
167-
168void QEglFSWindow::setGeometry(const QRect &r)-
169{-
170 QRect rect;-
171 bool forceFullscreen = m_flags.testFlag(HasNativeWindow);-
172 if (forceFullscreen
forceFullscreenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
173 rect = screen()->availableGeometry();
never executed: rect = screen()->availableGeometry();
0
174 else-
175 rect = r;
never executed: rect = r;
0
176-
177 QPlatformWindow::setGeometry(rect);-
178-
179-
180 if (rect != r
rect != rDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
181 QWindowSystemInterface::handleGeometryChange(window(), rect, r);
never executed: QWindowSystemInterface::handleGeometryChange(window(), rect, r);
0
182}
never executed: end of block
0
183-
184QRect QEglFSWindow::geometry() const-
185{-
186-
187-
188-
189 if (!m_flags.testFlag(Created)
!m_flags.testFlag(Created)Description
TRUEnever evaluated
FALSEnever evaluated
&& screen()->primarySurface() == ((EGLSurface)0)
screen()->prim...(EGLSurface)0)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
190 return
never executed: return screen()->availableGeometry();
screen()->availableGeometry();
never executed: return screen()->availableGeometry();
0
191-
192 return
never executed: return QPlatformWindow::geometry();
QPlatformWindow::geometry();
never executed: return QPlatformWindow::geometry();
0
193}-
194-
195void QEglFSWindow::requestActivateWindow()-
196{-
197 if (window()->type() != Qt::Desktop
window()->type...!= Qt::DesktopDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
198 QOpenGLCompositor::instance()->moveToTop(this);
never executed: QOpenGLCompositor::instance()->moveToTop(this);
0
199-
200 QWindow *wnd = window();-
201 QWindowSystemInterface::handleWindowActivated(wnd);-
202 QWindowSystemInterface::handleExposeEvent(wnd, QRect(QPoint(0, 0), wnd->geometry().size()));-
203}
never executed: end of block
0
204-
205void QEglFSWindow::raise()-
206{-
207 QWindow *wnd = window();-
208 if (wnd->type() != Qt::Desktop
wnd->type() != Qt::DesktopDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
209 QOpenGLCompositor::instance()->moveToTop(this);-
210 QWindowSystemInterface::handleExposeEvent(wnd, QRect(QPoint(0, 0), wnd->geometry().size()));-
211 }
never executed: end of block
0
212}
never executed: end of block
0
213-
214void QEglFSWindow::lower()-
215{-
216 QOpenGLCompositor *compositor = QOpenGLCompositor::instance();-
217 QList<QOpenGLCompositorWindow *> windows = compositor->windows();-
218 if (window()->type() != Qt::Desktop
window()->type...!= Qt::DesktopDescription
TRUEnever evaluated
FALSEnever evaluated
&& windows.count() > 1
windows.count() > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
219 int idx = windows.indexOf(this);-
220 if (idx > 0
idx > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
221 compositor->changeWindowIndex(this, idx - 1);-
222 QWindowSystemInterface::handleExposeEvent(windows.last()->sourceWindow(),-
223 QRect(QPoint(0, 0), windows.last()->sourceWindow()->geometry().size()));-
224 }
never executed: end of block
0
225 }
never executed: end of block
0
226}
never executed: end of block
0
227-
228EGLSurface QEglFSWindow::surface() const-
229{-
230 return
never executed: return m_surface != ((EGLSurface)0) ? m_surface : screen()->primarySurface();
m_surface != ((EGLSurface)0) ? m_surface : screen()->primarySurface();
never executed: return m_surface != ((EGLSurface)0) ? m_surface : screen()->primarySurface();
0
231}-
232-
233QSurfaceFormat QEglFSWindow::format() const-
234{-
235 return
never executed: return m_format;
m_format;
never executed: return m_format;
0
236}-
237-
238EGLNativeWindowType QEglFSWindow::eglWindow() const-
239{-
240 return
never executed: return m_window;
m_window;
never executed: return m_window;
0
241}-
242-
243QEglFSScreen *QEglFSWindow::screen() const-
244{-
245 return
never executed: return static_cast<QEglFSScreen *>(QPlatformWindow::screen());
static_cast<QEglFSScreen *>(QPlatformWindow::screen());
never executed: return static_cast<QEglFSScreen *>(QPlatformWindow::screen());
0
246}-
247-
248bool QEglFSWindow::isRaster() const-
249{-
250 return
never executed: return m_raster || window()->surfaceType() == QSurface::RasterGLSurface;
m_raster || window()->surfaceType() == QSurface::RasterGLSurface;
never executed: return m_raster || window()->surfaceType() == QSurface::RasterGLSurface;
0
251}-
252-
253QWindow *QEglFSWindow::sourceWindow() const-
254{-
255 return
never executed: return window();
window();
never executed: return window();
0
256}-
257-
258const QPlatformTextureList *QEglFSWindow::textures() const-
259{-
260 if (m_backingStore
m_backingStoreDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
261 return
never executed: return m_backingStore->textures();
m_backingStore->textures();
never executed: return m_backingStore->textures();
0
262-
263 return
never executed: return 0;
0;
never executed: return 0;
0
264}-
265-
266void QEglFSWindow::endCompositing()-
267{-
268 if (m_backingStore
m_backingStoreDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
269 m_backingStore->notifyComposited();
never executed: m_backingStore->notifyComposited();
0
270}
never executed: end of block
0
271-
272WId QEglFSWindow::winId() const-
273{-
274 return
never executed: return m_winId;
m_winId;
never executed: return m_winId;
0
275}-
276-
277void QEglFSWindow::setOpacity(qreal)-
278{-
279 if (!isRaster()
!isRaster()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
280 QMessageLogger(__FILE__, 330, __PRETTY_FUNCTION__).warning("QEglFSWindow: Cannot set opacity for non-raster windows");
never executed: QMessageLogger(__FILE__, 330, __PRETTY_FUNCTION__).warning("QEglFSWindow: Cannot set opacity for non-raster windows");
0
281-
282-
283}
never executed: end of block
0
284-
285-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9