| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/fbconvenience/qfbscreen.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | QFbScreen::QFbScreen() : mUpdatePending(false), mCursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), mCompositePainter(0), mIsUpToDate(false) | - | ||||||||||||||||||
| 8 | { | - | ||||||||||||||||||
| 9 | } never executed:  end of block | 0 | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | QFbScreen::~QFbScreen() | - | ||||||||||||||||||
| 12 | { | - | ||||||||||||||||||
| 13 | delete mCompositePainter; | - | ||||||||||||||||||
| 14 | delete mScreenImage; | - | ||||||||||||||||||
| 15 | } never executed:  end of block | 0 | ||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | void QFbScreen::initializeCompositor() | - | ||||||||||||||||||
| 18 | { | - | ||||||||||||||||||
| 19 | mScreenImage = new QImage(mGeometry.size(), mFormat); | - | ||||||||||||||||||
| 20 | scheduleUpdate(); | - | ||||||||||||||||||
| 21 | } never executed:  end of block | 0 | ||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | bool QFbScreen::event(QEvent *event) | - | ||||||||||||||||||
| 24 | { | - | ||||||||||||||||||
| 25 |     if (event->type() == QEvent::UpdateRequest
  | 0 | ||||||||||||||||||
| 26 | doRedraw(); | - | ||||||||||||||||||
| 27 | mUpdatePending = false; | - | ||||||||||||||||||
| 28 |         return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||
| 29 | } | - | ||||||||||||||||||
| 30 |     return never executed:   QObject::event(event);return QObject::event(event);never executed:  return QObject::event(event); | 0 | ||||||||||||||||||
| 31 | } | - | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | void QFbScreen::addWindow(QFbWindow *window) | - | ||||||||||||||||||
| 34 | { | - | ||||||||||||||||||
| 35 | mWindowStack.prepend(window); | - | ||||||||||||||||||
| 36 |     if (!mPendingBackingStores.isEmpty()
  | 0 | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 |         for (int i = 0; i < mPendingBackingStores.size()
  | 0 | ||||||||||||||||||
| 39 | QFbBackingStore *bs = mPendingBackingStores.at(i); | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 |             if (bs->window() == window->window()
  | 0 | ||||||||||||||||||
| 43 | window->setBackingStore(bs); | - | ||||||||||||||||||
| 44 | mPendingBackingStores.removeAt(i); | - | ||||||||||||||||||
| 45 |                 break; never executed:  break; | 0 | ||||||||||||||||||
| 46 | } | - | ||||||||||||||||||
| 47 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 48 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 49 | invalidateRectCache(); | - | ||||||||||||||||||
| 50 | setDirty(window->geometry()); | - | ||||||||||||||||||
| 51 | QWindow *w = topWindow(); | - | ||||||||||||||||||
| 52 | QWindowSystemInterface::handleWindowActivated(w); | - | ||||||||||||||||||
| 53 | topWindowChanged(w); | - | ||||||||||||||||||
| 54 | } never executed:  end of block | 0 | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | void QFbScreen::removeWindow(QFbWindow *window) | - | ||||||||||||||||||
| 57 | { | - | ||||||||||||||||||
| 58 | mWindowStack.removeOne(window); | - | ||||||||||||||||||
| 59 | invalidateRectCache(); | - | ||||||||||||||||||
| 60 | setDirty(window->geometry()); | - | ||||||||||||||||||
| 61 | QWindow *w = topWindow(); | - | ||||||||||||||||||
| 62 | QWindowSystemInterface::handleWindowActivated(w); | - | ||||||||||||||||||
| 63 | topWindowChanged(w); | - | ||||||||||||||||||
| 64 | } never executed:  end of block | 0 | ||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | void QFbScreen::raise(QFbWindow *window) | - | ||||||||||||||||||
| 67 | { | - | ||||||||||||||||||
| 68 | int index = mWindowStack.indexOf(window); | - | ||||||||||||||||||
| 69 |     if (index <= 0
  | 0 | ||||||||||||||||||
| 70 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 71 | mWindowStack.move(index, 0); | - | ||||||||||||||||||
| 72 | invalidateRectCache(); | - | ||||||||||||||||||
| 73 | setDirty(window->geometry()); | - | ||||||||||||||||||
| 74 | QWindow *w = topWindow(); | - | ||||||||||||||||||
| 75 | QWindowSystemInterface::handleWindowActivated(w); | - | ||||||||||||||||||
| 76 | topWindowChanged(w); | - | ||||||||||||||||||
| 77 | } never executed:  end of block | 0 | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | void QFbScreen::lower(QFbWindow *window) | - | ||||||||||||||||||
| 80 | { | - | ||||||||||||||||||
| 81 | int index = mWindowStack.indexOf(window); | - | ||||||||||||||||||
| 82 |     if (index == -1
 
  | 0 | ||||||||||||||||||
| 83 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 84 | mWindowStack.move(index, mWindowStack.size() - 1); | - | ||||||||||||||||||
| 85 | invalidateRectCache(); | - | ||||||||||||||||||
| 86 | setDirty(window->geometry()); | - | ||||||||||||||||||
| 87 | QWindow *w = topWindow(); | - | ||||||||||||||||||
| 88 | QWindowSystemInterface::handleWindowActivated(w); | - | ||||||||||||||||||
| 89 | topWindowChanged(w); | - | ||||||||||||||||||
| 90 | } never executed:  end of block | 0 | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | QWindow *QFbScreen::topWindow() const | - | ||||||||||||||||||
| 93 | { | - | ||||||||||||||||||
| 94 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(mWindowStack)>::type> _container_((mWindowStack)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QFbWindow *fbw = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||
| 95 |         if (fbw->window()->type() == Qt::Window
 
  | 0 | ||||||||||||||||||
| 96 |             return never executed:   fbw->window();return fbw->window();never executed:  return fbw->window(); | 0 | ||||||||||||||||||
| 97 |     return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 98 | } | - | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | QWindow *QFbScreen::topLevelAt(const QPoint & p) const | - | ||||||||||||||||||
| 101 | { | - | ||||||||||||||||||
| 102 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(mWindowStack)>::type> _container_((mWindowStack)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QFbWindow *fbw = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
| 103 |         if (fbw->geometry().contains(p, false)
 
  | 0 | ||||||||||||||||||
| 104 |             return never executed:   fbw->window();return fbw->window();never executed:  return fbw->window(); | 0 | ||||||||||||||||||
| 105 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 106 |     return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 107 | } | - | ||||||||||||||||||
| 108 | - | |||||||||||||||||||
| 109 | void QFbScreen::setDirty(const QRect &rect) | - | ||||||||||||||||||
| 110 | { | - | ||||||||||||||||||
| 111 | QRect intersection = rect.intersected(mGeometry); | - | ||||||||||||||||||
| 112 | QPoint screenOffset = mGeometry.topLeft(); | - | ||||||||||||||||||
| 113 | mRepaintRegion += intersection.translated(-screenOffset); | - | ||||||||||||||||||
| 114 | scheduleUpdate(); | - | ||||||||||||||||||
| 115 | } never executed:  end of block | 0 | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | void QFbScreen::scheduleUpdate() | - | ||||||||||||||||||
| 118 | { | - | ||||||||||||||||||
| 119 |     if (!mUpdatePending
  | 0 | ||||||||||||||||||
| 120 | mUpdatePending = true; | - | ||||||||||||||||||
| 121 | QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); | - | ||||||||||||||||||
| 122 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 123 | } never executed:  end of block | 0 | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | void QFbScreen::setPhysicalSize(const QSize &size) | - | ||||||||||||||||||
| 126 | { | - | ||||||||||||||||||
| 127 | mPhysicalSize = size; | - | ||||||||||||||||||
| 128 | } never executed:  end of block | 0 | ||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | void QFbScreen::setGeometry(const QRect &rect) | - | ||||||||||||||||||
| 131 | { | - | ||||||||||||||||||
| 132 | delete mCompositePainter; | - | ||||||||||||||||||
| 133 | mCompositePainter = 0; | - | ||||||||||||||||||
| 134 | delete mScreenImage; | - | ||||||||||||||||||
| 135 | mGeometry = rect; | - | ||||||||||||||||||
| 136 | mScreenImage = new QImage(mGeometry.size(), mFormat); | - | ||||||||||||||||||
| 137 | invalidateRectCache(); | - | ||||||||||||||||||
| 138 | QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry(), availableGeometry()); | - | ||||||||||||||||||
| 139 | resizeMaximizedWindows(); | - | ||||||||||||||||||
| 140 | } never executed:  end of block | 0 | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | void QFbScreen::generateRects() | - | ||||||||||||||||||
| 143 | { | - | ||||||||||||||||||
| 144 | mCachedRects.clear(); | - | ||||||||||||||||||
| 145 | QPoint screenOffset = mGeometry.topLeft(); | - | ||||||||||||||||||
| 146 | QRegion remainingScreen(mGeometry.translated(-screenOffset)); | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 |     for (int i = 0; i < mWindowStack.length()
  | 0 | ||||||||||||||||||
| 149 |         if (remainingScreen.isEmpty()
  | 0 | ||||||||||||||||||
| 150 |             break; never executed:  break; | 0 | ||||||||||||||||||
| 151 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 152 | const QVector<QRect> remainingScreenRects = remainingScreen.rects(); | - | ||||||||||||||||||
| 153 | mCachedRects.reserve(mCachedRects.count() + remainingScreenRects.count()); | - | ||||||||||||||||||
| 154 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(remainingScreenRects)>::type> _container_((remainingScreenRects)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||
| 155 |         mCachedRects += QPair<QRect, int>(rect, -1); never executed:  mCachedRects += QPair<QRect, int>(rect, -1); | 0 | ||||||||||||||||||
| 156 | mIsUpToDate = true; | - | ||||||||||||||||||
| 157 | } never executed:  end of block | 0 | ||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | QRegion QFbScreen::doRedraw() | - | ||||||||||||||||||
| 160 | { | - | ||||||||||||||||||
| 161 | QPoint screenOffset = mGeometry.topLeft(); | - | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | QRegion touchedRegion; | - | ||||||||||||||||||
| 164 |     if (mCursor
 
 
  | 0 | ||||||||||||||||||
| 165 | QRect lastCursor = mCursor->dirtyRect(); | - | ||||||||||||||||||
| 166 | mRepaintRegion += lastCursor; | - | ||||||||||||||||||
| 167 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 168 |     if (mRepaintRegion.isEmpty()
 
 
  | 0 | ||||||||||||||||||
| 169 |         return never executed:   touchedRegion;return touchedRegion;never executed:  return touchedRegion; | 0 | ||||||||||||||||||
| 170 | } | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | QVector<QRect> rects = mRepaintRegion.rects(); | - | ||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 |     if (!mIsUpToDate
  | 0 | ||||||||||||||||||
| 175 |         generateRects(); never executed:  generateRects(); | 0 | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 |     if (!mCompositePainter
  | 0 | ||||||||||||||||||
| 178 |         mCompositePainter = new QPainter(mScreenImage); never executed:  mCompositePainter = new QPainter(mScreenImage); | 0 | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 |     for (int rectIndex = 0; rectIndex < mRepaintRegion.rectCount()
  | 0 | ||||||||||||||||||
| 181 | QRegion rectRegion = rects[rectIndex]; | - | ||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 |         for (int i = 0; i < mCachedRects.length()
  | 0 | ||||||||||||||||||
| 184 | QRect screenSubRect = mCachedRects[i].first; | - | ||||||||||||||||||
| 185 | int layer = mCachedRects[i].second; | - | ||||||||||||||||||
| 186 | QRegion intersect = rectRegion.intersected(screenSubRect); | - | ||||||||||||||||||
| 187 | - | |||||||||||||||||||
| 188 |             if (intersect.isEmpty()
  | 0 | ||||||||||||||||||
| 189 |                 continue; never executed:  continue; | 0 | ||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | rectRegion -= intersect; | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(intersect.rects())>::type> _container_((intersect.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||
| 195 | bool firstLayer = true; | - | ||||||||||||||||||
| 196 |                 if (layer == -1
  | 0 | ||||||||||||||||||
| 197 | mCompositePainter->setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||
| 198 | mCompositePainter->fillRect(rect, mScreenImage->hasAlphaChannel() ? Qt::transparent : Qt::black); | - | ||||||||||||||||||
| 199 | firstLayer = false; | - | ||||||||||||||||||
| 200 | layer = mWindowStack.size() - 1; | - | ||||||||||||||||||
| 201 |                 } never executed:  end of block | 0 | ||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 |                 for (int layerIndex = layer; layerIndex != -1
  | 0 | ||||||||||||||||||
| 204 |                     if (!mWindowStack[layerIndex]->window()->isVisible()
  | 0 | ||||||||||||||||||
| 205 |                         continue; never executed:  continue; | 0 | ||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | QRect windowRect = mWindowStack[layerIndex]->geometry().translated(-screenOffset); | - | ||||||||||||||||||
| 210 | QRect windowIntersect = rect.translated(-windowRect.left(), | - | ||||||||||||||||||
| 211 | -windowRect.top()); | - | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | - | |||||||||||||||||||
| 214 | QFbBackingStore *backingStore = mWindowStack[layerIndex]->backingStore(); | - | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 |                     if (backingStore
  | 0 | ||||||||||||||||||
| 217 | backingStore->lock(); | - | ||||||||||||||||||
| 218 | mCompositePainter->drawImage(rect, backingStore->image(), windowIntersect); | - | ||||||||||||||||||
| 219 | backingStore->unlock(); | - | ||||||||||||||||||
| 220 |                     } never executed:  end of block | 0 | ||||||||||||||||||
| 221 |                     if (firstLayer
  | 0 | ||||||||||||||||||
| 222 | firstLayer = false; | - | ||||||||||||||||||
| 223 |                     } never executed:  end of block | 0 | ||||||||||||||||||
| 224 |                 } never executed:  end of block | 0 | ||||||||||||||||||
| 225 |             } never executed:  end of block | 0 | ||||||||||||||||||
| 226 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 227 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | QRect cursorRect; | - | ||||||||||||||||||
| 230 |     if (mCursor
 
 
  | 0 | ||||||||||||||||||
| 231 | mCompositePainter->setCompositionMode(QPainter::CompositionMode_SourceOver); | - | ||||||||||||||||||
| 232 | cursorRect = mCursor->drawCursor(*mCompositePainter); | - | ||||||||||||||||||
| 233 | touchedRegion += cursorRect; | - | ||||||||||||||||||
| 234 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 235 | touchedRegion += mRepaintRegion; | - | ||||||||||||||||||
| 236 | mRepaintRegion = QRegion(); | - | ||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 |     return never executed:   touchedRegion;return touchedRegion;never executed:  return touchedRegion; | 0 | ||||||||||||||||||
| 243 | } | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | QFbWindow *QFbScreen::windowForId(WId wid) const | - | ||||||||||||||||||
| 246 | { | - | ||||||||||||||||||
| 247 |     for (int i = 0; i < mWindowStack.count()
  | 0 | ||||||||||||||||||
| 248 |         if (mWindowStack[i]->winId() == wid
  | 0 | ||||||||||||||||||
| 249 |             return never executed:   mWindowStack[i];return mWindowStack[i];never executed:  return mWindowStack[i]; | 0 | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 |     return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 252 | } | - | ||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |