qfbscreen.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/fbconvenience/qfbscreen.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 "qfbscreen_p.h"-
41#include "qfbcursor_p.h"-
42#include "qfbwindow_p.h"-
43#include "qfbbackingstore_p.h"-
44-
45#include <QtGui/QPainter>-
46#include <QtCore/QCoreApplication>-
47#include <qpa/qwindowsysteminterface.h>-
48-
49#include <QtCore/QDebug>-
50#include <QtCore/QElapsedTimer>-
51-
52QT_BEGIN_NAMESPACE-
53-
54QFbScreen::QFbScreen() : mUpdatePending(false), mCursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), mCompositePainter(0), mIsUpToDate(false)-
55{-
56}
never executed: end of block
0
57-
58QFbScreen::~QFbScreen()-
59{-
60 delete mCompositePainter;-
61 delete mScreenImage;-
62}
never executed: end of block
0
63-
64void QFbScreen::initializeCompositor()-
65{-
66 mScreenImage = new QImage(mGeometry.size(), mFormat);-
67 scheduleUpdate();-
68}
never executed: end of block
0
69-
70bool QFbScreen::event(QEvent *event)-
71{-
72 if (event->type() == QEvent::UpdateRequest) {
event->type() ...:UpdateRequestDescription
TRUEnever evaluated
FALSEnever evaluated
0
73 doRedraw();-
74 mUpdatePending = false;-
75 return true;
never executed: return true;
0
76 }-
77 return QObject::event(event);
never executed: return QObject::event(event);
0
78}-
79-
80void QFbScreen::addWindow(QFbWindow *window)-
81{-
82 mWindowStack.prepend(window);-
83 if (!mPendingBackingStores.isEmpty()) {
!mPendingBacki...ores.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
84 //check if we have a backing store for this window-
85 for (int i = 0; i < mPendingBackingStores.size(); ++i) {
i < mPendingBa...gStores.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
86 QFbBackingStore *bs = mPendingBackingStores.at(i);-
87 // this gets called during QWindow::create() at a point where the-
88 // invariant (window->handle()->window() == window) is broken-
89 if (bs->window() == window->window()) {
bs->window() =...ndow->window()Description
TRUEnever evaluated
FALSEnever evaluated
0
90 window->setBackingStore(bs);-
91 mPendingBackingStores.removeAt(i);-
92 break;
never executed: break;
0
93 }-
94 }
never executed: end of block
0
95 }
never executed: end of block
0
96 invalidateRectCache();-
97 setDirty(window->geometry());-
98 QWindow *w = topWindow();-
99 QWindowSystemInterface::handleWindowActivated(w);-
100 topWindowChanged(w);-
101}
never executed: end of block
0
102-
103void QFbScreen::removeWindow(QFbWindow *window)-
104{-
105 mWindowStack.removeOne(window);-
106 invalidateRectCache();-
107 setDirty(window->geometry());-
108 QWindow *w = topWindow();-
109 QWindowSystemInterface::handleWindowActivated(w);-
110 topWindowChanged(w);-
111}
never executed: end of block
0
112-
113void QFbScreen::raise(QFbWindow *window)-
114{-
115 int index = mWindowStack.indexOf(window);-
116 if (index <= 0)
index <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
117 return;
never executed: return;
0
118 mWindowStack.move(index, 0);-
119 invalidateRectCache();-
120 setDirty(window->geometry());-
121 QWindow *w = topWindow();-
122 QWindowSystemInterface::handleWindowActivated(w);-
123 topWindowChanged(w);-
124}
never executed: end of block
0
125-
126void QFbScreen::lower(QFbWindow *window)-
127{-
128 int index = mWindowStack.indexOf(window);-
129 if (index == -1 || index == (mWindowStack.size() - 1))
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
index == (mWin...ck.size() - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
130 return;
never executed: return;
0
131 mWindowStack.move(index, mWindowStack.size() - 1);-
132 invalidateRectCache();-
133 setDirty(window->geometry());-
134 QWindow *w = topWindow();-
135 QWindowSystemInterface::handleWindowActivated(w);-
136 topWindowChanged(w);-
137}
never executed: end of block
0
138-
139QWindow *QFbScreen::topWindow() const-
140{-
141 foreach (QFbWindow *fbw, mWindowStack)-
142 if (fbw->window()->type() == Qt::Window || fbw->window()->type() == Qt::Dialog)
fbw->window()-... == Qt::WindowDescription
TRUEnever evaluated
FALSEnever evaluated
fbw->window()-... == Qt::DialogDescription
TRUEnever evaluated
FALSEnever evaluated
0
143 return fbw->window();
never executed: return fbw->window();
0
144 return 0;
never executed: return 0;
0
145}-
146-
147QWindow *QFbScreen::topLevelAt(const QPoint & p) const-
148{-
149 foreach (QFbWindow *fbw, mWindowStack) {-
150 if (fbw->geometry().contains(p, false) && fbw->window()->isVisible())
fbw->geometry(...ains(p, false)Description
TRUEnever evaluated
FALSEnever evaluated
fbw->window()->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
151 return fbw->window();
never executed: return fbw->window();
0
152 }
never executed: end of block
0
153 return 0;
never executed: return 0;
0
154}-
155-
156void QFbScreen::setDirty(const QRect &rect)-
157{-
158 QRect intersection = rect.intersected(mGeometry);-
159 QPoint screenOffset = mGeometry.topLeft();-
160 mRepaintRegion += intersection.translated(-screenOffset); // global to local translation-
161 scheduleUpdate();-
162}
never executed: end of block
0
163-
164void QFbScreen::scheduleUpdate()-
165{-
166 if (!mUpdatePending) {
!mUpdatePendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
167 mUpdatePending = true;-
168 QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));-
169 }
never executed: end of block
0
170}
never executed: end of block
0
171-
172void QFbScreen::setPhysicalSize(const QSize &size)-
173{-
174 mPhysicalSize = size;-
175}
never executed: end of block
0
176-
177void QFbScreen::setGeometry(const QRect &rect)-
178{-
179 delete mCompositePainter;-
180 mCompositePainter = 0;-
181 delete mScreenImage;-
182 mGeometry = rect;-
183 mScreenImage = new QImage(mGeometry.size(), mFormat);-
184 invalidateRectCache();-
185 QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry(), availableGeometry());-
186 resizeMaximizedWindows();-
187}
never executed: end of block
0
188-
189void QFbScreen::generateRects()-
190{-
191 mCachedRects.clear();-
192 QPoint screenOffset = mGeometry.topLeft();-
193 QRegion remainingScreen(mGeometry.translated(-screenOffset)); // global to local translation-
194-
195 for (int i = 0; i < mWindowStack.length(); i++) {
i < mWindowStack.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
196 if (remainingScreen.isEmpty())
remainingScreen.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
197 break;
never executed: break;
0
198#if 0-
199 if (!mWindowStack[i]->isVisible())-
200 continue;-
201 if (mWindowStack[i]->isMinimized())-
202 continue;-
203-
204 if (!mWindowStack[i]->testAttribute(Qt::WA_TranslucentBackground)) {-
205 QRect localGeometry = mWindowStack.at(i)->geometry().translated(-screenOffset); // global to local translation-
206 remainingScreen -= localGeometry;-
207 QRegion windowRegion(localGeometry);-
208 windowRegion -= remainingScreen;-
209 foreach (const QRect &rect, windowRegion.rects()) {-
210 mCachedRects += QPair<QRect, int>(rect, i);-
211 }-
212 }-
213#endif-
214 }
never executed: end of block
0
215 const QVector<QRect> remainingScreenRects = remainingScreen.rects();-
216 mCachedRects.reserve(mCachedRects.count() + remainingScreenRects.count());-
217 foreach (const QRect &rect, remainingScreenRects)-
218 mCachedRects += QPair<QRect, int>(rect, -1);
never executed: mCachedRects += QPair<QRect, int>(rect, -1);
0
219 mIsUpToDate = true;-
220}
never executed: end of block
0
221-
222QRegion QFbScreen::doRedraw()-
223{-
224 QPoint screenOffset = mGeometry.topLeft();-
225-
226 QRegion touchedRegion;-
227 if (mCursor && mCursor->isDirty() && mCursor->isOnScreen()) {
mCursorDescription
TRUEnever evaluated
FALSEnever evaluated
mCursor->isDirty()Description
TRUEnever evaluated
FALSEnever evaluated
mCursor->isOnScreen()Description
TRUEnever evaluated
FALSEnever evaluated
0
228 QRect lastCursor = mCursor->dirtyRect();-
229 mRepaintRegion += lastCursor;-
230 }
never executed: end of block
0
231 if (mRepaintRegion.isEmpty() && (!mCursor || !mCursor->isDirty())) {
mRepaintRegion.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!mCursorDescription
TRUEnever evaluated
FALSEnever evaluated
!mCursor->isDirty()Description
TRUEnever evaluated
FALSEnever evaluated
0
232 return touchedRegion;
never executed: return touchedRegion;
0
233 }-
234-
235 QVector<QRect> rects = mRepaintRegion.rects();-
236-
237 if (!mIsUpToDate)
!mIsUpToDateDescription
TRUEnever evaluated
FALSEnever evaluated
0
238 generateRects();
never executed: generateRects();
0
239-
240 if (!mCompositePainter)
!mCompositePainterDescription
TRUEnever evaluated
FALSEnever evaluated
0
241 mCompositePainter = new QPainter(mScreenImage);
never executed: mCompositePainter = new QPainter(mScreenImage);
0
242-
243 for (int rectIndex = 0; rectIndex < mRepaintRegion.rectCount(); rectIndex++) {
rectIndex < mR...on.rectCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
244 QRegion rectRegion = rects[rectIndex];-
245-
246 for (int i = 0; i < mCachedRects.length(); i++) {
i < mCachedRects.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
247 QRect screenSubRect = mCachedRects[i].first;-
248 int layer = mCachedRects[i].second;-
249 QRegion intersect = rectRegion.intersected(screenSubRect);-
250-
251 if (intersect.isEmpty())
intersect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
252 continue;
never executed: continue;
0
253-
254 rectRegion -= intersect;-
255-
256 // we only expect one rectangle, but defensive coding...-
257 foreach (const QRect &rect, intersect.rects()) {-
258 bool firstLayer = true;-
259 if (layer == -1) {
layer == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
260 mCompositePainter->setCompositionMode(QPainter::CompositionMode_Source);-
261 mCompositePainter->fillRect(rect, mScreenImage->hasAlphaChannel() ? Qt::transparent : Qt::black);-
262 firstLayer = false;-
263 layer = mWindowStack.size() - 1;-
264 }
never executed: end of block
0
265-
266 for (int layerIndex = layer; layerIndex != -1; layerIndex--) {
layerIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
267 if (!mWindowStack[layerIndex]->window()->isVisible())
!mWindowStack[...)->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
268 continue;
never executed: continue;
0
269 // if (mWindowStack[layerIndex]->isMinimized())-
270 // continue;-
271-
272 QRect windowRect = mWindowStack[layerIndex]->geometry().translated(-screenOffset);-
273 QRect windowIntersect = rect.translated(-windowRect.left(),-
274 -windowRect.top());-
275-
276-
277 QFbBackingStore *backingStore = mWindowStack[layerIndex]->backingStore();-
278-
279 if (backingStore) {
backingStoreDescription
TRUEnever evaluated
FALSEnever evaluated
0
280 backingStore->lock();-
281 mCompositePainter->drawImage(rect, backingStore->image(), windowIntersect);-
282 backingStore->unlock();-
283 }
never executed: end of block
0
284 if (firstLayer) {
firstLayerDescription
TRUEnever evaluated
FALSEnever evaluated
0
285 firstLayer = false;-
286 }
never executed: end of block
0
287 }
never executed: end of block
0
288 }
never executed: end of block
0
289 }
never executed: end of block
0
290 }
never executed: end of block
0
291-
292 QRect cursorRect;-
293 if (mCursor && (mCursor->isDirty() || mRepaintRegion.intersects(mCursor->lastPainted()))) {
mCursorDescription
TRUEnever evaluated
FALSEnever evaluated
mCursor->isDirty()Description
TRUEnever evaluated
FALSEnever evaluated
mRepaintRegion...lastPainted())Description
TRUEnever evaluated
FALSEnever evaluated
0
294 mCompositePainter->setCompositionMode(QPainter::CompositionMode_SourceOver);-
295 cursorRect = mCursor->drawCursor(*mCompositePainter);-
296 touchedRegion += cursorRect;-
297 }
never executed: end of block
0
298 touchedRegion += mRepaintRegion;-
299 mRepaintRegion = QRegion();-
300-
301-
302-
303// qDebug() << "QFbScreen::doRedraw" << mWindowStack.size() << mScreenImage->size() << touchedRegion;-
304-
305 return touchedRegion;
never executed: return touchedRegion;
0
306}-
307-
308QFbWindow *QFbScreen::windowForId(WId wid) const-
309{-
310 for (int i = 0; i < mWindowStack.count(); ++i)
i < mWindowStack.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
311 if (mWindowStack[i]->winId() == wid)
mWindowStack[i...winId() == widDescription
TRUEnever evaluated
FALSEnever evaluated
0
312 return mWindowStack[i];
never executed: return mWindowStack[i];
0
313-
314 return 0;
never executed: return 0;
0
315}-
316-
317QT_END_NAMESPACE-
318-
Source codeSwitch to Preprocessed file

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