diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-10-20 19:12:23 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-10-20 19:12:25 +0200 |
commit | 3361fcbc28be96262d22fd2b024c85fbcbc61462 (patch) | |
tree | 48976f337b3885971dc1976b9a27cec5e7dfa2ec /src/gui | |
parent | dc612acdc6577594c8f61345cea2de549d7aae34 (diff) | |
parent | 5e342f6f041208d142d97202f61179d7163eb773 (diff) |
Merge remote-tracking branch 'origin/5.4' into dev
Change-Id: If7e51514ed6832750e3ad967e4d322ccf920d2bb
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qclipboard.cpp | 11 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 11 | ||||
-rw-r--r-- | src/gui/kernel/qoffscreensurface.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext_p.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qopenglwindow.cpp | 17 | ||||
-rw-r--r-- | src/gui/kernel/qplatformmenu.h | 5 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 12 | ||||
-rw-r--r-- | src/gui/opengl/opengl.pri | 1 | ||||
-rw-r--r-- | src/gui/opengl/qopenglpaintdevice.cpp | 31 | ||||
-rw-r--r-- | src/gui/opengl/qopenglpaintdevice.h | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopenglpaintdevice_p.h | 81 | ||||
-rw-r--r-- | src/gui/opengl/qopenglpaintengine.cpp | 5 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 3 | ||||
-rw-r--r-- | src/gui/text/qfont.cpp | 3 |
15 files changed, 145 insertions, 58 deletions
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index ec9a8fdcf0..5be9f19b3e 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -463,9 +463,14 @@ const QMimeData* QClipboard::mimeData(Mode mode) const void QClipboard::setMimeData(QMimeData* src, Mode mode) { QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); - if (!clipboard->supportsMode(mode)) return; - - clipboard->setMimeData(src,mode); + if (!clipboard->supportsMode(mode)) { + if (src != 0) { + qWarning("Data set on unsupported clipboard mode. QMimeData object will be deleted."); + src->deleteLater(); + } + } else { + clipboard->setMimeData(src,mode); + } } /*! diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f99f28d6e0..a8539e8013 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -897,12 +897,11 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, when keys are pressed or released. A key event contains a special accept flag that indicates whether - the receiver will handle the key event. You should call ignore() - if the key press or release event is not handled by your widget. - A key event is propagated up the parent widget chain until a - widget accepts it with accept() or an event filter consumes it. - Key events for multimedia keys are ignored by default. You should - call accept() if your widget handles those events. + the receiver will handle the key event. This flag is set by default, + so there is no need to call accept() when acting on a key event. + Calling ignore() on a key event will propagate it to the parent widget. + The event is propagated up the parent widget chain until a widget + accepts it or an event filter consumes it. The QWidget::setEnable() function can be used to enable or disable mouse and keyboard events for a widget. diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index 56c4fbbf8b..5cf77de5d8 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -64,6 +64,12 @@ QT_BEGIN_NAMESPACE typically use a pixel buffer (pbuffer). If the platform doesn't implement or support offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally. + \note Due to the fact that QOffscreenSurface is backed by a QWindow on some platforms, + cross-platform applications must ensure that create() is only called on the main (GUI) + thread. The QOffscreenSurface is then safe to be used with + \l{QOpenGLContext::makeCurrent()}{makeCurrent()} on other threads, but the + initialization and destruction must always happen on the main (GUI) thread. + \note In order to create an offscreen surface that is guaranteed to be compatible with a given context and window, make sure to set the format to the context's or the window's actual format, that is, the QSurfaceFormat returned from @@ -152,6 +158,8 @@ QOffscreenSurface::SurfaceType QOffscreenSurface::surfaceType() const Call destroy() to free the platform resources if necessary. + \note Some platforms require this function to be called on the main (GUI) thread. + \sa destroy() */ void QOffscreenSurface::create() diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 51b4a6a079..07a7c601fa 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -350,16 +350,6 @@ QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context return previous; } -void QOpenGLContextPrivate::setGlobalShareContext(QOpenGLContext *context) -{ - qt_gl_set_global_share_context(context); -} - -QOpenGLContext *QOpenGLContextPrivate::globalShareContext() -{ - return qt_gl_global_share_context(); -} - int QOpenGLContextPrivate::maxTextureSize() { if (max_texture_size != -1) diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 7c45737d0a..d5a3126176 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -241,9 +241,6 @@ public: static QOpenGLContext *setCurrentContext(QOpenGLContext *context); - static void setGlobalShareContext(QOpenGLContext *context); - static QOpenGLContext *globalShareContext(); - int maxTextureSize(); static QOpenGLContextPrivate *get(QOpenGLContext *context) diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index 2b6692c461..158fb248dc 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -211,8 +211,11 @@ public: context->makeCurrent(q); } + const int deviceWidth = q->width() * q->devicePixelRatio(); + const int deviceHeight = q->height() * q->devicePixelRatio(); + const QSize deviceSize(deviceWidth, deviceHeight); if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { - if (!fbo || fbo->size() != q->size() * q->devicePixelRatio()) { + if (!fbo || fbo->size() != deviceSize) { QOpenGLFramebufferObjectFormat fboFormat; fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); if (q->requestedFormat().samples() > 0) { @@ -221,15 +224,13 @@ public: else qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling"); } - fbo.reset(new QOpenGLFramebufferObject(q->size() * q->devicePixelRatio(), fboFormat)); + fbo.reset(new QOpenGLFramebufferObject(deviceSize, fboFormat)); markWindowAsDirty(); } } else { markWindowAsDirty(); } - const int deviceWidth = q->width() * q->devicePixelRatio(); - const int deviceHeight = q->height() * q->devicePixelRatio(); paintDevice->setSize(QSize(deviceWidth, deviceHeight)); paintDevice->setDevicePixelRatio(q->devicePixelRatio()); context->functions()->glViewport(0, 0, deviceWidth, deviceHeight); @@ -252,11 +253,13 @@ public: context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject()); if (updateBehavior == QOpenGLWindow::PartialUpdateBlit && hasFboBlit) { + const int deviceWidth = q->width() * q->devicePixelRatio(); + const int deviceHeight = q->height() * q->devicePixelRatio(); QOpenGLExtensions extensions(context.data()); extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle()); extensions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->defaultFramebufferObject()); - extensions.glBlitFramebuffer(0, 0, q->width(), q->height(), - 0, 0, q->width(), q->height(), + extensions.glBlitFramebuffer(0, 0, deviceWidth, deviceHeight, + 0, 0, deviceWidth, deviceHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); } else if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) { @@ -591,7 +594,7 @@ int QOpenGLWindow::metric(PaintDeviceMetric metric) const break; case PdmDevicePixelRatio: if (d->paintDevice) - return d->paintDevice->devicePixelRatio(); + return devicePixelRatio(); break; default: break; diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h index c832de0be6..0093ef1538 100644 --- a/src/gui/kernel/qplatformmenu.h +++ b/src/gui/kernel/qplatformmenu.h @@ -108,11 +108,6 @@ public: virtual void setFont(const QFont &font) { Q_UNUSED(font); } virtual void setMenuType(MenuType type) { Q_UNUSED(type); } - virtual void showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item) - { - showPopup(parentWindow, QRect(pos, QSize()), item); - } - virtual void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) { Q_UNUSED(parentWindow); diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index d03a3f7be8..bd95a8614f 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -201,9 +201,13 @@ bool QWindowSystemInterface::tryHandleShortcutEvent(QWindow *w, ulong timestamp, #ifndef QT_NO_SHORTCUT QGuiApplicationPrivate::modifier_buttons = mods; + QObject *focus = w->focusObject(); + if (!focus) + focus = w; + QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, text, autorep, count); qevent.setTimestamp(timestamp); - return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent); + return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(focus, &qevent); #else Q_UNUSED(w) Q_UNUSED(timestamp) @@ -231,9 +235,13 @@ bool QWindowSystemInterface::tryHandleExtendedShortcutEvent(QWindow *w, ulong ti #ifndef QT_NO_SHORTCUT QGuiApplicationPrivate::modifier_buttons = mods; + QObject *focus = w->focusObject(); + if (!focus) + focus = w; + QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count); qevent.setTimestamp(timestamp); - return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent); + return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(focus, &qevent); #else Q_UNUSED(w) Q_UNUSED(timestamp) diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index f82401c973..adf5428c49 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -11,6 +11,7 @@ contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) { opengl/qopenglframebufferobject.h \ opengl/qopenglframebufferobject_p.h \ opengl/qopenglpaintdevice.h \ + opengl/qopenglpaintdevice_p.h \ opengl/qopenglbuffer.h \ opengl/qopenglshaderprogram.h \ opengl/qopenglextensions_p.h \ diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index 59bca6efdf..e908fd8e91 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -35,6 +35,7 @@ #include <qpaintengine.h> #include <qthreadstorage.h> +#include <private/qopenglpaintdevice_p.h> #include <private/qobject_p.h> #include <private/qopenglcontext_p.h> #include <private/qopenglframebufferobject_p.h> @@ -98,23 +99,6 @@ QT_BEGIN_NAMESPACE */ -class QOpenGLPaintDevicePrivate -{ -public: - QOpenGLPaintDevicePrivate(const QSize &size); - - QSize size; - QOpenGLContext *ctx; - - qreal dpmx; - qreal dpmy; - qreal devicePixelRatio; - - bool flipped; - - QPaintEngine *engine; -}; - /*! Constructs a QOpenGLPaintDevice. @@ -152,6 +136,14 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height) } /*! + \internal + */ +QOpenGLPaintDevice::QOpenGLPaintDevice(QOpenGLPaintDevicePrivate *dd) + : d_ptr(dd) +{ +} + +/*! Destroys the QOpenGLPaintDevice. */ @@ -355,7 +347,10 @@ bool QOpenGLPaintDevice::paintFlipped() const frame buffer object or context when different QOpenGLPaintDevice instances are issuing draw calls alternately. - QPainter::beginNativePainting will also trigger this method. + \l{QPainter::beginNativePainting()}{beginNativePainting()} will also trigger + this method. + + The default implementation does nothing. */ void QOpenGLPaintDevice::ensureActiveTarget() { diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h index e1be9b525d..dda3bfe43f 100644 --- a/src/gui/opengl/qopenglpaintdevice.h +++ b/src/gui/opengl/qopenglpaintdevice.h @@ -44,7 +44,6 @@ QT_BEGIN_NAMESPACE - class QOpenGLPaintDevicePrivate; class Q_GUI_EXPORT QOpenGLPaintDevice : public QPaintDevice @@ -54,6 +53,7 @@ public: QOpenGLPaintDevice(); explicit QOpenGLPaintDevice(const QSize &size); QOpenGLPaintDevice(int width, int height); + QOpenGLPaintDevice(QOpenGLPaintDevicePrivate *dd); virtual ~QOpenGLPaintDevice(); int devType() const { return QInternal::OpenGL; } diff --git a/src/gui/opengl/qopenglpaintdevice_p.h b/src/gui/opengl/qopenglpaintdevice_p.h new file mode 100644 index 0000000000..0b01129a84 --- /dev/null +++ b/src/gui/opengl/qopenglpaintdevice_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENGL_PAINTDEVICE_P_H +#define QOPENGL_PAINTDEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Qt OpenGL classes. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include <qopenglpaintdevice.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLContext; +class QPaintEngine; + +class Q_GUI_EXPORT QOpenGLPaintDevicePrivate +{ +public: + QOpenGLPaintDevicePrivate(const QSize &size); + virtual ~QOpenGLPaintDevicePrivate() { } + + static QOpenGLPaintDevicePrivate *get(QOpenGLPaintDevice *dev) { return dev->d_func(); } + + virtual void beginPaint() { } + virtual void endPaint() { } + +public: + QSize size; + QOpenGLContext *ctx; + + qreal dpmx; + qreal dpmy; + qreal devicePixelRatio; + + bool flipped; + + QPaintEngine *engine; +}; + +QT_END_NAMESPACE + +#endif // QOPENGL_PAINTDEVICE_P_H diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 21bc4a95e8..c490726359 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -59,6 +59,7 @@ #include "qopenglgradientcache_p.h" #include "qopengltexturecache_p.h" #include "qopenglpaintengine_p.h" +#include "qopenglpaintdevice_p.h" #include <string.h> //for memcpy #include <qmath.h> @@ -1994,6 +1995,8 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev) d->ctx = QOpenGLContext::currentContext(); d->ctx->d_func()->active_engine = this; + QOpenGLPaintDevicePrivate::get(d->device)->beginPaint(); + d->funcs.initializeOpenGLFunctions(); for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) @@ -2044,6 +2047,8 @@ bool QOpenGL2PaintEngineEx::end() { Q_D(QOpenGL2PaintEngineEx); + QOpenGLPaintDevicePrivate::get(d->device)->endPaint(); + QOpenGLContext *ctx = d->ctx; d->funcs.glUseProgram(0); d->transferMode(BrushDrawingMode); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 12c7929047..34e22a30b8 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2597,8 +2597,7 @@ QRegion QPainter::clipRegion() const extern QPainterPath qt_regionToPath(const QRegion ®ion); /*! - Returns the currently clip as a path. Note that the clip path is - given in logical coordinates. + Returns the current clip path in logical coordinates. \warning QPainter does not store the combined clip explicitly as this is handled by the underlying QPaintEngine, so the path is diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 9caebc6ec6..54fcbac308 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1452,7 +1452,8 @@ qreal QFont::letterSpacing() const Letter spacing changes the default spacing between individual letters in the font. The spacing between the letters can be - made smaller as well as larger. + made smaller as well as larger either in percentage of the + character width or in pixels, depending on the selected spacing type. \sa letterSpacing(), letterSpacingType(), setWordSpacing() */ |