| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qbackingstore.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | class QBackingStorePrivate | - | ||||||||||||
| 7 | { | - | ||||||||||||
| 8 | public: | - | ||||||||||||
| 9 | QBackingStorePrivate(QWindow *w) | - | ||||||||||||
| 10 | : window(w) | - | ||||||||||||
| 11 | { | - | ||||||||||||
| 12 | } never executed: end of block | 0 | ||||||||||||
| 13 | - | |||||||||||||
| 14 | QWindow *window; | - | ||||||||||||
| 15 | QPlatformBackingStore *platformBackingStore; | - | ||||||||||||
| 16 | QScopedPointer<QImage> highDpiBackingstore; | - | ||||||||||||
| 17 | QRegion staticContents; | - | ||||||||||||
| 18 | QSize size; | - | ||||||||||||
| 19 | }; | - | ||||||||||||
| 20 | void QBackingStore::flush(const QRegion ®ion, QWindow *win, const QPoint &offset) | - | ||||||||||||
| 21 | { | - | ||||||||||||
| 22 | if (!win
| 0 | ||||||||||||
| 23 | win = window(); never executed: win = window(); | 0 | ||||||||||||
| 24 | if (!win->handle()
| 0 | ||||||||||||
| 25 | QMessageLogger(__FILE__, 103, __PRETTY_FUNCTION__).warning() << "QBackingStore::flush() called for " | - | ||||||||||||
| 26 | << win << " which does not have a handle."; | - | ||||||||||||
| 27 | return; never executed: return; | 0 | ||||||||||||
| 28 | } | - | ||||||||||||
| 29 | d_ptr->platformBackingStore->flush(win, QHighDpi::toNativeLocalRegion(region, win), | - | ||||||||||||
| 30 | QHighDpi::toNativeLocalPosition(offset, win)); | - | ||||||||||||
| 31 | } never executed: end of block | 0 | ||||||||||||
| 32 | - | |||||||||||||
| 33 | - | |||||||||||||
| 34 | - | |||||||||||||
| 35 | - | |||||||||||||
| 36 | - | |||||||||||||
| 37 | - | |||||||||||||
| 38 | QPaintDevice *QBackingStore::paintDevice() | - | ||||||||||||
| 39 | { | - | ||||||||||||
| 40 | QPaintDevice *device = d_ptr->platformBackingStore->paintDevice(); | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | if (QHighDpiScaling::isActive()
| 0 | ||||||||||||
| 43 | return never executed: d_ptr->highDpiBackingstore.data();return d_ptr->highDpiBackingstore.data();never executed: return d_ptr->highDpiBackingstore.data(); | 0 | ||||||||||||
| 44 | - | |||||||||||||
| 45 | return never executed: device;return device;never executed: return device; | 0 | ||||||||||||
| 46 | } | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | - | |||||||||||||
| 49 | - | |||||||||||||
| 50 | - | |||||||||||||
| 51 | QBackingStore::QBackingStore(QWindow *window) | - | ||||||||||||
| 52 | : d_ptr(new QBackingStorePrivate(window)) | - | ||||||||||||
| 53 | { | - | ||||||||||||
| 54 | d_ptr->platformBackingStore = QGuiApplicationPrivate::platformIntegration()->createPlatformBackingStore(window); | - | ||||||||||||
| 55 | } never executed: end of block | 0 | ||||||||||||
| 56 | - | |||||||||||||
| 57 | - | |||||||||||||
| 58 | - | |||||||||||||
| 59 | - | |||||||||||||
| 60 | QBackingStore::~QBackingStore() | - | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | delete d_ptr->platformBackingStore; | - | ||||||||||||
| 63 | } never executed: end of block | 0 | ||||||||||||
| 64 | - | |||||||||||||
| 65 | - | |||||||||||||
| 66 | - | |||||||||||||
| 67 | - | |||||||||||||
| 68 | - | |||||||||||||
| 69 | QWindow* QBackingStore::window() const | - | ||||||||||||
| 70 | { | - | ||||||||||||
| 71 | return never executed: d_ptr->window;return d_ptr->window;never executed: return d_ptr->window; | 0 | ||||||||||||
| 72 | } | - | ||||||||||||
| 73 | void QBackingStore::beginPaint(const QRegion ®ion) | - | ||||||||||||
| 74 | { | - | ||||||||||||
| 75 | if (d_ptr->highDpiBackingstore
| 0 | ||||||||||||
| 76 | d_ptr->highDpiBackingstore->devicePixelRatio() != d_ptr->window->devicePixelRatio()
| 0 | ||||||||||||
| 77 | resize(size()); never executed: resize(size()); | 0 | ||||||||||||
| 78 | - | |||||||||||||
| 79 | d_ptr->platformBackingStore->beginPaint(QHighDpi::toNativeLocalRegion(region, d_ptr->window)); | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | - | |||||||||||||
| 82 | - | |||||||||||||
| 83 | - | |||||||||||||
| 84 | - | |||||||||||||
| 85 | - | |||||||||||||
| 86 | - | |||||||||||||
| 87 | QPaintDevice *device = d_ptr->platformBackingStore->paintDevice(); | - | ||||||||||||
| 88 | if (QHighDpiScaling::isActive()
| 0 | ||||||||||||
| 89 | QImage *source = static_cast<QImage *>(device); | - | ||||||||||||
| 90 | const bool needsNewImage = d_ptr->highDpiBackingstore.isNull()
| 0 | ||||||||||||
| 91 | || source->data_ptr() != d_ptr->highDpiBackingstore->data_ptr()
| 0 | ||||||||||||
| 92 | || source->size() != d_ptr->highDpiBackingstore->size()
| 0 | ||||||||||||
| 93 | || source->devicePixelRatio() != d_ptr->highDpiBackingstore->devicePixelRatio()
| 0 | ||||||||||||
| 94 | if (needsNewImage
| 0 | ||||||||||||
| 95 | for (bool qt_category_enabled = lcScaling().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 189, __PRETTY_FUNCTION__, lcScaling().categoryName()).debug() << "QBackingStore::beginPaint new backingstore for" << d_ptr->window; | 0 | ||||||||||||
| 96 | for (bool qt_category_enabled = lcScaling().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 190, __PRETTY_FUNCTION__, lcScaling().categoryName()).debug() << " source size" << source->size() << "dpr" << source->devicePixelRatio(); | 0 | ||||||||||||
| 97 | d_ptr->highDpiBackingstore.reset( | - | ||||||||||||
| 98 | new QImage(source->bits(), source->width(), source->height(), source->bytesPerLine(), source->format())); | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | qreal targetDevicePixelRatio = d_ptr->window->devicePixelRatio(); | - | ||||||||||||
| 101 | d_ptr->highDpiBackingstore->setDevicePixelRatio(targetDevicePixelRatio); | - | ||||||||||||
| 102 | for (bool qt_category_enabled = lcScaling().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 196, __PRETTY_FUNCTION__, lcScaling().categoryName()).debug() <<" destination size" << d_ptr->highDpiBackingstore->size() << "dpr" << targetDevicePixelRatio; | 0 | ||||||||||||
| 103 | << "dpr" << targetDevicePixelRatio; never executed: QMessageLogger(__FILE__, 196, __PRETTY_FUNCTION__, lcScaling().categoryName()).debug() <<" destination size" << d_ptr->highDpiBackingstore->size() << "dpr" << targetDevicePixelRatio; | 0 | ||||||||||||
| 104 | } never executed: end of block | 0 | ||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||
| 106 | } never executed: end of block | 0 | ||||||||||||
| 107 | - | |||||||||||||
| 108 | - | |||||||||||||
| 109 | - | |||||||||||||
| 110 | - | |||||||||||||
| 111 | - | |||||||||||||
| 112 | - | |||||||||||||
| 113 | void QBackingStore::endPaint() | - | ||||||||||||
| 114 | { | - | ||||||||||||
| 115 | d_ptr->platformBackingStore->endPaint(); | - | ||||||||||||
| 116 | } never executed: end of block | 0 | ||||||||||||
| 117 | - | |||||||||||||
| 118 | - | |||||||||||||
| 119 | - | |||||||||||||
| 120 | - | |||||||||||||
| 121 | - | |||||||||||||
| 122 | - | |||||||||||||
| 123 | void QBackingStore::resize(const QSize &size) | - | ||||||||||||
| 124 | { | - | ||||||||||||
| 125 | d_ptr->size = size; | - | ||||||||||||
| 126 | d_ptr->platformBackingStore->resize(QHighDpi::toNativePixels(size, d_ptr->window), d_ptr->staticContents); | - | ||||||||||||
| 127 | } never executed: end of block | 0 | ||||||||||||
| 128 | - | |||||||||||||
| 129 | - | |||||||||||||
| 130 | - | |||||||||||||
| 131 | - | |||||||||||||
| 132 | QSize QBackingStore::size() const | - | ||||||||||||
| 133 | { | - | ||||||||||||
| 134 | return never executed: d_ptr->size;return d_ptr->size;never executed: return d_ptr->size; | 0 | ||||||||||||
| 135 | } | - | ||||||||||||
| 136 | - | |||||||||||||
| 137 | - | |||||||||||||
| 138 | - | |||||||||||||
| 139 | - | |||||||||||||
| 140 | - | |||||||||||||
| 141 | - | |||||||||||||
| 142 | - | |||||||||||||
| 143 | bool QBackingStore::scroll(const QRegion &area, int dx, int dy) | - | ||||||||||||
| 144 | { | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | - | |||||||||||||
| 147 | - | |||||||||||||
| 148 | const qreal nativeDx = QHighDpi::toNativePixels(qreal(dx), d_ptr->window); | - | ||||||||||||
| 149 | const qreal nativeDy = QHighDpi::toNativePixels(qreal(dy), d_ptr->window); | - | ||||||||||||
| 150 | if (qFloor(nativeDx) != nativeDx
| 0 | ||||||||||||
| 151 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 152 | - | |||||||||||||
| 153 | return never executed: d_ptr->platformBackingStore->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window),return d_ptr->platformBackingStore->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window), nativeDx, nativeDy);never executed: return d_ptr->platformBackingStore->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window), nativeDx, nativeDy); | 0 | ||||||||||||
| 154 | nativeDx, nativeDy); never executed: return d_ptr->platformBackingStore->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window), nativeDx, nativeDy); | 0 | ||||||||||||
| 155 | } | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 | - | |||||||||||||
| 158 | - | |||||||||||||
| 159 | - | |||||||||||||
| 160 | void QBackingStore::setStaticContents(const QRegion ®ion) | - | ||||||||||||
| 161 | { | - | ||||||||||||
| 162 | d_ptr->staticContents = region; | - | ||||||||||||
| 163 | } never executed: end of block | 0 | ||||||||||||
| 164 | - | |||||||||||||
| 165 | - | |||||||||||||
| 166 | - | |||||||||||||
| 167 | - | |||||||||||||
| 168 | - | |||||||||||||
| 169 | QRegion QBackingStore::staticContents() const | - | ||||||||||||
| 170 | { | - | ||||||||||||
| 171 | return never executed: d_ptr->staticContents;return d_ptr->staticContents;never executed: return d_ptr->staticContents; | 0 | ||||||||||||
| 172 | } | - | ||||||||||||
| 173 | - | |||||||||||||
| 174 | - | |||||||||||||
| 175 | - | |||||||||||||
| 176 | - | |||||||||||||
| 177 | - | |||||||||||||
| 178 | bool QBackingStore::hasStaticContents() const | - | ||||||||||||
| 179 | { | - | ||||||||||||
| 180 | return never executed: !d_ptr->staticContents.isEmpty();return !d_ptr->staticContents.isEmpty();never executed: return !d_ptr->staticContents.isEmpty(); | 0 | ||||||||||||
| 181 | } | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | void __attribute__((visibility("default"))) qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) | - | ||||||||||||
| 184 | { | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits()); | - | ||||||||||||
| 187 | - | |||||||||||||
| 188 | int lineskip = img.bytesPerLine(); | - | ||||||||||||
| 189 | int depth = img.depth() >> 3; | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | const QRect imageRect(0, 0, img.width(), img.height()); | - | ||||||||||||
| 192 | const QRect r = rect & imageRect & imageRect.translated(-offset); | - | ||||||||||||
| 193 | const QPoint p = rect.topLeft() + offset; | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | if (r.isEmpty()
| 0 | ||||||||||||
| 196 | return; never executed: return; | 0 | ||||||||||||
| 197 | - | |||||||||||||
| 198 | const uchar *src; | - | ||||||||||||
| 199 | uchar *dest; | - | ||||||||||||
| 200 | - | |||||||||||||
| 201 | if (r.top() < p.y()
| 0 | ||||||||||||
| 202 | src = mem + r.bottom() * lineskip + r.left() * depth; | - | ||||||||||||
| 203 | dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth; | - | ||||||||||||
| 204 | lineskip = -lineskip; | - | ||||||||||||
| 205 | } never executed: else {end of block | 0 | ||||||||||||
| 206 | src = mem + r.top() * lineskip + r.left() * depth; | - | ||||||||||||
| 207 | dest = mem + p.y() * lineskip + p.x() * depth; | - | ||||||||||||
| 208 | } never executed: end of block | 0 | ||||||||||||
| 209 | - | |||||||||||||
| 210 | const int w = r.width(); | - | ||||||||||||
| 211 | int h = r.height(); | - | ||||||||||||
| 212 | const int bytes = w * depth; | - | ||||||||||||
| 213 | - | |||||||||||||
| 214 | - | |||||||||||||
| 215 | if (offset.y() == 0
| 0 | ||||||||||||
| 216 | do { | - | ||||||||||||
| 217 | ::memmove(dest, src, bytes); | - | ||||||||||||
| 218 | dest += lineskip; | - | ||||||||||||
| 219 | src += lineskip; | - | ||||||||||||
| 220 | } never executed: while (--end of block
| 0 | ||||||||||||
| 221 | } never executed: else {end of block | 0 | ||||||||||||
| 222 | do { | - | ||||||||||||
| 223 | ::memcpy(dest, src, bytes); | - | ||||||||||||
| 224 | dest += lineskip; | - | ||||||||||||
| 225 | src += lineskip; | - | ||||||||||||
| 226 | } never executed: while (--end of block
| 0 | ||||||||||||
| 227 | } never executed: end of block | 0 | ||||||||||||
| 228 | } | - | ||||||||||||
| 229 | - | |||||||||||||
| 230 | - | |||||||||||||
| 231 | - | |||||||||||||
| 232 | - | |||||||||||||
| 233 | QPlatformBackingStore *QBackingStore::handle() const | - | ||||||||||||
| 234 | { | - | ||||||||||||
| 235 | return never executed: d_ptr->platformBackingStore;return d_ptr->platformBackingStore;never executed: return d_ptr->platformBackingStore; | 0 | ||||||||||||
| 236 | } | - | ||||||||||||
| 237 | - | |||||||||||||
| 238 | - | |||||||||||||
| Switch to Source code | Preprocessed file |