diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qimage.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qevent.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 31 | ||||
-rw-r--r-- | src/gui/opengl/qopengltexturehelper_p.h | 16 | ||||
-rw-r--r-- | src/gui/opengl/qopenglvertexarrayobject.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qfont.cpp | 8 |
6 files changed, 45 insertions, 18 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d33e1053c8..64dafdddc3 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4251,6 +4251,8 @@ void QImage::setAlphaChannel(const QImage &alphaChannel) } else { const QImage sourceImage = alphaChannel.convertToFormat(QImage::Format_RGB32); + if (sourceImage.isNull()) + return; const uchar *src_data = sourceImage.d->data; uchar *dest_data = d->data; for (int y=0; y<h; ++y) { diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 0a207667ad..570212966f 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -534,7 +534,7 @@ public: }; class Attribute { public: - Attribute(AttributeType t, int s, int l, QVariant val) : type(t), start(s), length(l), value(qMove(val)) {} + Attribute(AttributeType typ, int s, int l, QVariant val) : type(typ), start(s), length(l), value(qMove(val)) {} AttributeType type; int start; diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index e45a1d61ba..bcd3e830dd 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -581,6 +581,20 @@ void QPlatformWindow::invalidateSurface() { } +static QSize fixInitialSize(QSize size, const QWindow *w, + int defaultWidth, int defaultHeight) +{ + if (size.width() == 0) { + const int minWidth = w->minimumWidth(); + size.setWidth(minWidth > 0 ? minWidth : defaultWidth); + } + if (size.height() == 0) { + const int minHeight = w->minimumHeight(); + size.setHeight(minHeight > 0 ? minHeight : defaultHeight); + } + return size; +} + /*! Helper function to get initial geometry on windowing systems which do not do smart positioning and also do not provide a means of centering a @@ -593,19 +607,18 @@ void QPlatformWindow::invalidateSurface() QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeometry, int defaultWidth, int defaultHeight) { + if (!w->isTopLevel()) { + const qreal factor = QHighDpiScaling::factor(w); + const QSize size = fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor), + w, defaultWidth, defaultHeight); + return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor)); + } const QScreen *screen = effectiveScreen(w); if (!screen) return initialGeometry; QRect rect(QHighDpi::fromNativePixels(initialGeometry, w)); - if (rect.width() == 0) { - const int minWidth = w->minimumWidth(); - rect.setWidth(minWidth > 0 ? minWidth : defaultWidth); - } - if (rect.height() == 0) { - const int minHeight = w->minimumHeight(); - rect.setHeight(minHeight > 0 ? minHeight : defaultHeight); - } - if (w->isTopLevel() && qt_window_private(const_cast<QWindow*>(w))->positionAutomatic + rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight)); + if (qt_window_private(const_cast<QWindow*>(w))->positionAutomatic && w->type() != Qt::Popup) { const QRect availableGeometry = screen->availableGeometry(); // Center unless the geometry ( + unknown window frame) is too large for the screen). diff --git a/src/gui/opengl/qopengltexturehelper_p.h b/src/gui/opengl/qopengltexturehelper_p.h index a255672602..6b26527269 100644 --- a/src/gui/opengl/qopengltexturehelper_p.h +++ b/src/gui/opengl/qopengltexturehelper_p.h @@ -76,6 +76,14 @@ QT_BEGIN_NAMESPACE #define GL_TEXTURE_COMPARE_FUNC 0x884D #endif +// use GL_APICALL only on Android + __clang__ +#if !defined(Q_OS_ANDROID) || !defined(__clang__) +# undef GL_APICALL +# define GL_APICALL +#elif !defined(GL_APICALL) +# define GL_APICALL +#endif + class QOpenGLContext; class QOpenGLTextureHelper @@ -754,15 +762,15 @@ private: // OpenGL 1.3 void (QOPENGLF_APIENTRYP GetCompressedTexImage)(GLenum target, GLint level, GLvoid *img); void (QOPENGLF_APIENTRYP CompressedTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); - void (QOPENGLF_APIENTRYP CompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); + GL_APICALL void (QOPENGLF_APIENTRYP CompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); void (QOPENGLF_APIENTRYP CompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); void (QOPENGLF_APIENTRYP CompressedTexImage1D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); - void (QOPENGLF_APIENTRYP CompressedTexImage2D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); + GL_APICALL void (QOPENGLF_APIENTRYP CompressedTexImage2D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); void (QOPENGLF_APIENTRYP CompressedTexImage3D)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); - void (QOPENGLF_APIENTRYP ActiveTexture)(GLenum texture); + GL_APICALL void (QOPENGLF_APIENTRYP ActiveTexture)(GLenum texture); // OpenGL 3.0 - void (QOPENGLF_APIENTRYP GenerateMipmap)(GLenum target); + GL_APICALL void (QOPENGLF_APIENTRYP GenerateMipmap)(GLenum target); // OpenGL 3.2 void (QOPENGLF_APIENTRYP TexImage3DMultisample)(GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 6753064a60..babe52aa83 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -358,9 +358,11 @@ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() Q_D(QOpenGLVertexArrayObject); QOpenGLContext *oldContext = 0; + QSurface *oldContextSurface = 0; QScopedPointer<QOffscreenSurface> offscreenSurface; if (d->context && ctx && d->context != ctx) { oldContext = ctx; + oldContextSurface = ctx->surface(); // Cannot just make the current surface current again with another context. // The format may be incompatible and some platforms (iOS) may impose // restrictions on using a window with different contexts. Create an @@ -380,7 +382,7 @@ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() destroy(); if (oldContext) { - if (!oldContext->makeCurrent(oldContext->surface())) + if (!oldContext->makeCurrent(oldContextSurface)) qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context"); } } diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 828dbc318c..12631b3a73 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -76,7 +76,9 @@ QT_BEGIN_NAMESPACE - +#ifndef QFONTCACHE_DECREASE_TRIGGER_LIMIT +# define QFONTCACHE_DECREASE_TRIGGER_LIMIT 256 +#endif bool QFontDef::exactMatch(const QFontDef &other) const { @@ -2800,7 +2802,7 @@ void QFontCache::insertEngineData(const QFontDef &def, QFontEngineData *engineDa engineData->ref.ref(); // Decrease now rather than waiting - if (total_cost > min_cost * 2) + if (total_cost > min_cost * 2 && engineDataCache.size() >= QFONTCACHE_DECREASE_TRIGGER_LIMIT) decreaseCache(); engineDataCache.insert(def, engineData); @@ -2849,7 +2851,7 @@ void QFontCache::insertEngine(const Key &key, QFontEngine *engine, bool insertMu #endif engine->ref.ref(); // Decrease now rather than waiting - if (total_cost > min_cost * 2) + if (total_cost > min_cost * 2 && engineCache.size() >= QFONTCACHE_DECREASE_TRIGGER_LIMIT) decreaseCache(); Engine data(engine); |