summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-01 08:51:18 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-01 10:03:21 +0200
commit3cb7302480390e5149a9cf6f49ac1ca94ef63f97 (patch)
tree831134f1053214ab0d5ba4d406cf7b860ed7c578 /src/gui
parent2ff1557937c398a7fb5cc7ba120e7ca3b5eacd36 (diff)
parentf24cc53cc27d8ed4be4c1d0d2df059dd6a6909a9 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/widgets/itemviews/qabstractitemview.cpp src/widgets/itemviews/qabstractitemview_p.h Change-Id: I54589b1365103cb1749186af92aab03a49c94b64
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimage.cpp42
-rw-r--r--src/gui/image/qpixmap.cpp6
-rw-r--r--src/gui/opengl/qopengldebug.cpp40
-rw-r--r--src/gui/painting/qbackingstore.cpp15
-rw-r--r--src/gui/text/qfontengine_ft.cpp5
5 files changed, 76 insertions, 32 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 64dafdddc3..de02e9a1dd 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -841,17 +841,6 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm
d->cleanupFunction = cleanupFunction;
d->cleanupInfo = cleanupInfo;
- switch (format) {
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- d->colortable.resize(2);
- d->colortable[0] = QColor(Qt::black).rgba();
- d->colortable[1] = QColor(Qt::white).rgba();
- break;
- default:
- break;
- }
-
return d;
}
@@ -2250,21 +2239,30 @@ QRgb QImage::pixel(int x, int y) const
}
const uchar *s = d->data + y * d->bytes_per_line;
- switch(d->format) {
+
+ int index = -1;
+ switch (d->format) {
case Format_Mono:
- return d->colortable.at((*(s + (x >> 3)) >> (~x & 7)) & 1);
+ index = (*(s + (x >> 3)) >> (~x & 7)) & 1;
+ break;
case Format_MonoLSB:
- return d->colortable.at((*(s + (x >> 3)) >> (x & 7)) & 1);
+ index = (*(s + (x >> 3)) >> (x & 7)) & 1;
+ break;
case Format_Indexed8:
- {
- int index = (int)s[x];
- if (index < d->colortable.size()) {
- return d->colortable.at(index);
- } else {
- qWarning("QImage::pixel: color table index %d out of range.", index);
- return 0;
- }
+ index = s[x];
+ break;
+ default:
+ break;
+ }
+ if (index >= 0) { // Indexed format
+ if (index >= d->colortable.size()) {
+ qWarning("QImage::pixel: color table index %d out of range.", index);
+ return 0;
}
+ return d->colortable.at(index);
+ }
+
+ switch (d->format) {
case Format_RGB32:
return 0xff000000 | reinterpret_cast<const QRgb *>(s)[x];
case Format_ARGB32: // Keep old behaviour.
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 09d23c0084..59d6dc12c6 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -1418,10 +1418,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
QPixmap using the fromImage(). If this is too expensive an
operation, you can use QBitmap::fromImage() instead.
- The QPixmap class also supports conversion to and from HICON:
- the toWinHICON() function creates a HICON equivalent to the
- QPixmap, and returns the HICON handle. The fromWinHICON()
- function returns a QPixmap that is equivalent to the given icon.
+ To convert a QPixmap to and from HICON you can use the QtWinExtras
+ functions QtWin::toHICON() and QtWin::fromHICON() respectively.
\section1 Pixmap Transformations
diff --git a/src/gui/opengl/qopengldebug.cpp b/src/gui/opengl/qopengldebug.cpp
index 24aa6094dd..f6c3af37dd 100644
--- a/src/gui/opengl/qopengldebug.cpp
+++ b/src/gui/opengl/qopengldebug.cpp
@@ -42,6 +42,7 @@
#include <QtCore/qvarlengtharray.h>
#include <QtGui/qopengl.h>
#include <QtGui/qopenglfunctions.h>
+#include <QtGui/qoffscreensurface.h>
#include "qopengldebug.h"
@@ -1287,8 +1288,41 @@ void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Source
*/
void QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed()
{
+ Q_ASSERT(context);
+
+ // Re-make our context current somehow, otherwise stopLogging will fail.
+
+ // Save the current context and its surface in case we need to set them back
+ QOpenGLContext *currentContext = QOpenGLContext::currentContext();
+ QSurface *currentSurface = 0;
+
+ QScopedPointer<QOffscreenSurface> offscreenSurface;
+
+ if (context != currentContext) {
+ // Make our old context current on a temporary surface
+ if (currentContext)
+ currentSurface = currentContext->surface();
+
+ offscreenSurface.reset(new QOffscreenSurface);
+ offscreenSurface->setFormat(context->format());
+ offscreenSurface->create();
+ if (!context->makeCurrent(offscreenSurface.data()))
+ qWarning("QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed(): could not make the owning GL context current for cleanup");
+ }
+
Q_Q(QOpenGLDebugLogger);
q->stopLogging();
+
+ if (offscreenSurface) {
+ // We did change the current context: set it back
+ if (currentContext)
+ currentContext->makeCurrent(currentSurface);
+ else
+ context->doneCurrent();
+ }
+
+ QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));
+ context = 0;
initialized = false;
}
@@ -1494,6 +1528,12 @@ void QOpenGLDebugLogger::stopLogging()
if (!d->isLogging)
return;
+ QOpenGLContext *currentContext = QOpenGLContext::currentContext();
+ if (!currentContext || currentContext != d->context) {
+ qWarning("QOpenGLDebugLogger::stopLogging(): attempting to stop logging with the wrong OpenGL context current");
+ return;
+ }
+
d->isLogging = false;
d->glDebugMessageCallback(d->oldDebugCallbackFunction, d->oldDebugCallbackParameter);
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 801397751b..e3d18512dd 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -236,11 +236,16 @@ QSize QBackingStore::size() const
*/
bool QBackingStore::scroll(const QRegion &area, int dx, int dy)
{
- Q_UNUSED(area);
- Q_UNUSED(dx);
- Q_UNUSED(dy);
-
- return d_ptr->platformBackingStore->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window), QHighDpi::toNativePixels(dx, d_ptr->window), QHighDpi::toNativePixels(dy, d_ptr->window));
+ // Disable scrolling for non-integer scroll deltas. For this case
+ // the the existing rendered pixels can't be re-used, and we return
+ // false to signal that a repaint is needed.
+ const qreal nativeDx = QHighDpi::toNativePixels(qreal(dx), d_ptr->window);
+ const qreal nativeDy = QHighDpi::toNativePixels(qreal(dy), d_ptr->window);
+ if (qFloor(nativeDx) != nativeDx || qFloor(nativeDy) != nativeDy)
+ return false;
+
+ return d_ptr->platformBackingStore->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window),
+ nativeDx, nativeDy);
}
/*!
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 26ed81a091..51b1418bc3 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1849,7 +1849,10 @@ static inline QImage alphaMapFromGlyphData(QFontEngineFT::Glyph *glyph, QFontEng
Q_UNREACHABLE();
};
- return QImage(static_cast<const uchar *>(glyph->data), glyph->width, glyph->height, bytesPerLine, format);
+ QImage img(static_cast<const uchar *>(glyph->data), glyph->width, glyph->height, bytesPerLine, format);
+ if (format == QImage::Format_Mono)
+ img.setColor(1, QColor(Qt::white).rgba()); // Expands color table to 2 items; item 0 set to transparent.
+ return img;
}
QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixelPosition,