qeglfsscreen.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/eglfs/qeglfsscreen.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the plugins of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <QtCore/qtextstream.h>-
41#include <QtGui/qwindow.h>-
42#include <qpa/qwindowsysteminterface.h>-
43#include <qpa/qplatformcursor.h>-
44#include <QtPlatformSupport/private/qopenglcompositor_p.h>-
45-
46#include "qeglfsscreen.h"-
47#include "qeglfswindow.h"-
48#include "qeglfshooks.h"-
49-
50QT_BEGIN_NAMESPACE-
51-
52QEglFSScreen::QEglFSScreen(EGLDisplay dpy)-
53 : m_dpy(dpy),-
54 m_surface(EGL_NO_SURFACE),-
55 m_cursor(0)-
56{-
57 m_cursor = qt_egl_device_integration()->createCursor(this);-
58}
never executed: end of block
0
59-
60QEglFSScreen::~QEglFSScreen()-
61{-
62 delete m_cursor;-
63 QOpenGLCompositor::destroy();-
64}
never executed: end of block
0
65-
66QRect QEglFSScreen::geometry() const-
67{-
68 return QRect(QPoint(0, 0), qt_egl_device_integration()->screenSize());
never executed: return QRect(QPoint(0, 0), qt_egl_device_integration()->screenSize());
0
69}-
70-
71int QEglFSScreen::depth() const-
72{-
73 return qt_egl_device_integration()->screenDepth();
never executed: return qt_egl_device_integration()->screenDepth();
0
74}-
75-
76QImage::Format QEglFSScreen::format() const-
77{-
78 return qt_egl_device_integration()->screenFormat();
never executed: return qt_egl_device_integration()->screenFormat();
0
79}-
80-
81QSizeF QEglFSScreen::physicalSize() const-
82{-
83 return qt_egl_device_integration()->physicalScreenSize();
never executed: return qt_egl_device_integration()->physicalScreenSize();
0
84}-
85-
86QDpi QEglFSScreen::logicalDpi() const-
87{-
88 return qt_egl_device_integration()->logicalDpi();
never executed: return qt_egl_device_integration()->logicalDpi();
0
89}-
90-
91qreal QEglFSScreen::pixelDensity() const-
92{-
93 return qt_egl_device_integration()->pixelDensity();
never executed: return qt_egl_device_integration()->pixelDensity();
0
94}-
95-
96Qt::ScreenOrientation QEglFSScreen::nativeOrientation() const-
97{-
98 return qt_egl_device_integration()->nativeOrientation();
never executed: return qt_egl_device_integration()->nativeOrientation();
0
99}-
100-
101Qt::ScreenOrientation QEglFSScreen::orientation() const-
102{-
103 return qt_egl_device_integration()->orientation();
never executed: return qt_egl_device_integration()->orientation();
0
104}-
105-
106QPlatformCursor *QEglFSScreen::cursor() const-
107{-
108 return m_cursor;
never executed: return m_cursor;
0
109}-
110-
111qreal QEglFSScreen::refreshRate() const-
112{-
113 return qt_egl_device_integration()->refreshRate();
never executed: return qt_egl_device_integration()->refreshRate();
0
114}-
115-
116void QEglFSScreen::setPrimarySurface(EGLSurface surface)-
117{-
118 m_surface = surface;-
119}
never executed: end of block
0
120-
121void QEglFSScreen::handleCursorMove(const QPoint &pos)-
122{-
123 const QOpenGLCompositor *compositor = QOpenGLCompositor::instance();-
124 const QList<QOpenGLCompositorWindow *> windows = compositor->windows();-
125-
126 // Generate enter and leave events like a real windowing system would do.-
127 if (windows.isEmpty())
windows.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
128 return;
never executed: return;
0
129-
130 // First window is always fullscreen.-
131 if (windows.count() == 1) {
windows.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
132 QWindow *window = windows[0]->sourceWindow();-
133 if (m_pointerWindow != window) {
m_pointerWindow != windowDescription
TRUEnever evaluated
FALSEnever evaluated
0
134 m_pointerWindow = window;-
135 QWindowSystemInterface::handleEnterEvent(window, window->mapFromGlobal(pos), pos);-
136 }
never executed: end of block
0
137 return;
never executed: return;
0
138 }-
139-
140 QWindow *enter = 0, *leave = 0;-
141 for (int i = windows.count() - 1; i >= 0; --i) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
142 QWindow *window = windows[i]->sourceWindow();-
143 const QRect geom = window->geometry();-
144 if (geom.contains(pos)) {
geom.contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
145 if (m_pointerWindow != window) {
m_pointerWindow != windowDescription
TRUEnever evaluated
FALSEnever evaluated
0
146 leave = m_pointerWindow;-
147 m_pointerWindow = window;-
148 enter = window;-
149 }
never executed: end of block
0
150 break;
never executed: break;
0
151 }-
152 }
never executed: end of block
0
153-
154 if (enter && leave)
enterDescription
TRUEnever evaluated
FALSEnever evaluated
leaveDescription
TRUEnever evaluated
FALSEnever evaluated
0
155 QWindowSystemInterface::handleEnterLeaveEvent(enter, leave, enter->mapFromGlobal(pos), pos);
never executed: QWindowSystemInterface::handleEnterLeaveEvent(enter, leave, enter->mapFromGlobal(pos), pos);
0
156}
never executed: end of block
0
157-
158QPixmap QEglFSScreen::grabWindow(WId wid, int x, int y, int width, int height) const-
159{-
160 QOpenGLCompositor *compositor = QOpenGLCompositor::instance();-
161 const QList<QOpenGLCompositorWindow *> windows = compositor->windows();-
162 Q_ASSERT(!windows.isEmpty());-
163-
164 QImage img;-
165-
166 if (static_cast<QEglFSWindow *>(windows.first()->sourceWindow()->handle())->isRaster()) {
static_cast<QE...))->isRaster()Description
TRUEnever evaluated
FALSEnever evaluated
0
167 // Request the compositor to render everything into an FBO and read it back. This-
168 // is of course slow, but it's safe and reliable. It will not include the mouse-
169 // cursor, which is a plus.-
170 img = compositor->grab();-
171 } else {
never executed: end of block
0
172 // Just a single OpenGL window without compositing. Do not support this case for now. Doing-
173 // glReadPixels is not an option since it would read from the back buffer which may have-
174 // undefined content when calling right after a swapBuffers (unless preserved swap is-
175 // available and enabled, but we have no support for that).-
176 qWarning("grabWindow: Not supported for non-composited OpenGL content. Use QQuickWindow::grabWindow() instead.");-
177 return QPixmap();
never executed: return QPixmap();
0
178 }-
179-
180 if (!wid) {
!widDescription
TRUEnever evaluated
FALSEnever evaluated
0
181 const QSize screenSize = geometry().size();-
182 if (width < 0)
width < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
183 width = screenSize.width() - x;
never executed: width = screenSize.width() - x;
0
184 if (height < 0)
height < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
185 height = screenSize.height() - y;
never executed: height = screenSize.height() - y;
0
186 return QPixmap::fromImage(img).copy(x, y, width, height);
never executed: return QPixmap::fromImage(img).copy(x, y, width, height);
0
187 }-
188-
189 foreach (QOpenGLCompositorWindow *w, windows) {-
190 const QWindow *window = w->sourceWindow();-
191 if (window->winId() == wid) {
window->winId() == widDescription
TRUEnever evaluated
FALSEnever evaluated
0
192 const QRect geom = window->geometry();-
193 if (width < 0)
width < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
194 width = geom.width() - x;
never executed: width = geom.width() - x;
0
195 if (height < 0)
height < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
196 height = geom.height() - y;
never executed: height = geom.height() - y;
0
197 QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height));-
198 rect &= window->geometry();-
199 return QPixmap::fromImage(img).copy(rect);
never executed: return QPixmap::fromImage(img).copy(rect);
0
200 }-
201 }
never executed: end of block
0
202-
203 return QPixmap();
never executed: return QPixmap();
0
204}-
205-
206QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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