diff options
author | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2015-05-13 12:42:46 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2015-05-13 12:42:46 +0200 |
commit | 8524853227c753b5cfa14184a086ec0acff3930a (patch) | |
tree | 808fab49e65286a4b4416a8462bb78fc188dfeac /src/gui/opengl | |
parent | d5a6c1613b52ebc015aa85a46c1387909d435926 (diff) | |
parent | bf06924f3ffd22747c93a720caa501d8478dcbe6 (diff) |
Merge branch 'wip/highdpi' of git://code.qt.io/qt/qtbase into dev-highdpi
Conflicts:
src/plugins/platforms/xcb/qxcbscreen.cpp
src/plugins/platforms/xcb/qxcbwindow.cpp
Diffstat (limited to 'src/gui/opengl')
-rw-r--r-- | src/gui/opengl/qopengl.cpp | 42 | ||||
-rw-r--r-- | src/gui/opengl/qopengl.h | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopengl_p.h | 24 | ||||
-rw-r--r-- | src/gui/opengl/qopenglext.h | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopengltexture.cpp | 10 | ||||
-rw-r--r-- | src/gui/opengl/qopengltexturehelper.cpp | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopenglversionfunctions.h | 3 |
7 files changed, 67 insertions, 18 deletions
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index 61d0614724..c8d33df4ba 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -36,6 +36,7 @@ #include "qopenglcontext.h" #include "qopenglfunctions.h" +#include "qoffscreensurface.h" #include <QtCore/QDebug> #include <QtCore/QJsonDocument> @@ -89,8 +90,8 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() } /* Helpers to read out the list of features matching a device from - * a Chromium driver bug list of the format using a subset of keys - * (namely, matching by gl_vendor RegExp is not implemented): + * a Chromium driver bug list. Note that not all keys are supported and + * some may behave differently: gl_vendor is a substring match instead of regex. { "entries": [ { @@ -291,14 +292,14 @@ static bool matches(const QJsonObject &object, const QJsonValue vendorV = object.value(vendorIdKey()); if (vendorV.isString()) { - if (gpu.vendorId != vendorV.toString().toUInt(Q_NULLPTR, /* base */ 0)) - return false; + if (gpu.vendorId != vendorV.toString().toUInt(Q_NULLPTR, /* base */ 0)) + return false; } else { if (object.contains(glVendorKey())) { - qWarning().nospace() << "Id " << object.value(idKey()).toInt() - << ": Matching by " << glVendorKey() << " is not implemented."; - return false; - } + const QByteArray glVendorV = object.value(glVendorKey()).toString().toUtf8(); + if (!gpu.glVendor.contains(glVendorV)) + return false; + } } if (gpu.deviceId) { @@ -447,5 +448,30 @@ QSet<QString> QOpenGLConfig::gpuFeatures(const Gpu &gpu, const QString &fileName return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), fileName); } +QOpenGLConfig::Gpu QOpenGLConfig::Gpu::fromContext() +{ + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QScopedPointer<QOpenGLContext> tmpContext; + QScopedPointer<QOffscreenSurface> tmpSurface; + if (!ctx) { + tmpContext.reset(new QOpenGLContext); + if (!tmpContext->create()) { + qWarning("QOpenGLConfig::Gpu::fromContext: Failed to create temporary context"); + return QOpenGLConfig::Gpu(); + } + tmpSurface.reset(new QOffscreenSurface); + tmpSurface->setFormat(tmpContext->format()); + tmpSurface->create(); + tmpContext->makeCurrent(tmpSurface.data()); + } + + QOpenGLConfig::Gpu gpu; + ctx = QOpenGLContext::currentContext(); + const GLubyte *p = ctx->functions()->glGetString(GL_VENDOR); + if (p) + gpu.glVendor = QByteArray(reinterpret_cast<const char *>(p)); + + return gpu; +} QT_END_NAMESPACE diff --git a/src/gui/opengl/qopengl.h b/src/gui/opengl/qopengl.h index a70bd79997..72abce760d 100644 --- a/src/gui/opengl/qopengl.h +++ b/src/gui/opengl/qopengl.h @@ -221,7 +221,7 @@ typedef unsigned long long int uint64_t; typedef long int int32_t; typedef long long int int64_t; typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) +#elif defined(_WIN32) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1600)) #include <stdint.h> #elif defined(_WIN32) typedef __int32 int32_t; diff --git a/src/gui/opengl/qopengl_p.h b/src/gui/opengl/qopengl_p.h index e04ae05120..980e02aea6 100644 --- a/src/gui/opengl/qopengl_p.h +++ b/src/gui/opengl/qopengl_p.h @@ -74,16 +74,34 @@ private: class Q_GUI_EXPORT QOpenGLConfig { public: - struct Gpu { + struct Q_GUI_EXPORT Gpu { Gpu() : vendorId(0), deviceId(0) {} - bool isValid() const { return deviceId; } + bool isValid() const { return deviceId || !glVendor.isEmpty(); } bool equals(const Gpu &other) const { - return vendorId == other.vendorId && deviceId == other.deviceId && driverVersion == other.driverVersion; + return vendorId == other.vendorId && deviceId == other.deviceId && driverVersion == other.driverVersion + && glVendor == other.glVendor; } uint vendorId; uint deviceId; QVersionNumber driverVersion; + QByteArray glVendor; + + static Gpu fromDevice(uint vendorId, uint deviceId, QVersionNumber driverVersion) { + Gpu gpu; + gpu.vendorId = vendorId; + gpu.deviceId = deviceId; + gpu.driverVersion = driverVersion; + return gpu; + } + + static Gpu fromGLVendor(const QByteArray &glVendor) { + Gpu gpu; + gpu.glVendor = glVendor; + return gpu; + } + + static Gpu fromContext(); }; static QSet<QString> gpuFeatures(const Gpu &gpu, diff --git a/src/gui/opengl/qopenglext.h b/src/gui/opengl/qopenglext.h index 36bad4ce28..72316ca496 100644 --- a/src/gui/opengl/qopenglext.h +++ b/src/gui/opengl/qopenglext.h @@ -1399,7 +1399,7 @@ typedef unsigned long long int uint64_t; typedef long int int32_t; typedef long long int int64_t; typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) +#elif defined(_WIN32) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1600)) #include <stdint.h> #elif defined(_WIN32) typedef __int32 int32_t; diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 9bc9926b70..baa702a982 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -120,7 +120,8 @@ QOpenGLTexturePrivate::QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarge swizzleMask[2] = QOpenGLTexture::BlueValue; swizzleMask[3] = QOpenGLTexture::AlphaValue; - wrapModes[0] = wrapModes[1] = wrapModes[2] = QOpenGLTexture::ClampToEdge; + wrapModes[0] = wrapModes[1] = wrapModes[2] = target == QOpenGLTexture::TargetRectangle + ? QOpenGLTexture::ClampToEdge : QOpenGLTexture::Repeat; } QOpenGLTexturePrivate::~QOpenGLTexturePrivate() @@ -215,7 +216,8 @@ void QOpenGLTexturePrivate::destroy() swizzleMask[2] = QOpenGLTexture::BlueValue; swizzleMask[3] = QOpenGLTexture::AlphaValue; - wrapModes[0] = wrapModes[1] = wrapModes[2] = QOpenGLTexture::ClampToEdge; + wrapModes[0] = wrapModes[1] = wrapModes[2] = target == QOpenGLTexture::TargetRectangle + ? QOpenGLTexture::ClampToEdge : QOpenGLTexture::Repeat; } void QOpenGLTexturePrivate::bind() @@ -1393,7 +1395,7 @@ QOpenGLTexture::WrapMode QOpenGLTexturePrivate::wrapMode(QOpenGLTexture::Coordin case QOpenGLTexture::DirectionT: case QOpenGLTexture::DirectionR: - qWarning("QOpenGLTexture::setWrapMode() direction not valid for this texture target"); + qWarning("QOpenGLTexture::wrapMode() direction not valid for this texture target"); return QOpenGLTexture::Repeat; } break; @@ -1413,7 +1415,7 @@ QOpenGLTexture::WrapMode QOpenGLTexturePrivate::wrapMode(QOpenGLTexture::Coordin return wrapModes[1]; case QOpenGLTexture::DirectionR: - qWarning("QOpenGLTexture::setWrapMode() direction not valid for this texture target"); + qWarning("QOpenGLTexture::wrapMode() direction not valid for this texture target"); return QOpenGLTexture::Repeat; } break; diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index 3635a7dd1b..440fdad081 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -179,7 +179,7 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) GetTexParameteriv = ::glGetTexParameteriv; GetTexParameterfv = ::glGetTexParameterfv; GetTexImage = 0; - TexImage2D = ::glTexImage2D; + TexImage2D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(::glTexImage2D); TexImage1D = 0; TexParameteriv = ::glTexParameteriv; TexParameteri = ::glTexParameteri; diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h index fcf665f97e..2fd3b9dab9 100644 --- a/src/gui/opengl/qopenglversionfunctions.h +++ b/src/gui/opengl/qopenglversionfunctions.h @@ -47,7 +47,10 @@ #ifndef QT_NO_OPENGL +#if QT_DEPRECATED_SINCE(5, 5) #include <QtCore/qhash.h> +#endif +#include <QtCore/qhashfunctions.h> #include <QtCore/qpair.h> #include <QtGui/qopengl.h> |