From ede3791df8330ed8daae6667d025ad40219a9f5f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Jul 2018 14:49:15 +0200 Subject: Move texture uploading out of QOpenGLTextureCache This way the logic can be reused elsewhere. At the same time a standard OpenGL ES/3 way of handling BGRA is added, so we don't depend on extensions, and handling of NPOT and max size which QSGTexture will need. Change-Id: I475bc7127f44be3964fdb482c9e86a20db1fbca5 Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglfunctions.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/gui/opengl/qopenglfunctions.cpp') diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 913b289c52..4f48604a88 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #ifdef Q_OS_INTEGRITY #include @@ -424,6 +425,8 @@ static int qt_gl_resolve_extensions() extensions |= QOpenGLExtensions::NVFloatBuffer; if (extensionMatcher.match("GL_ARB_pixel_buffer_object")) extensions |= QOpenGLExtensions::PixelBufferObject; + if (extensionMatcher.match("GL_ARB_texture_swizzle") || extensionMatcher.match("GL_EXT_texture_swizzle")) + extensions |= QOpenGLExtensions::TextureSwizzle; if (ctx->isOpenGLES()) { if (format.majorVersion() >= 2) @@ -436,7 +439,8 @@ static int qt_gl_resolve_extensions() | QOpenGLExtensions::MapBufferRange | QOpenGLExtensions::FramebufferBlit | QOpenGLExtensions::FramebufferMultisample - | QOpenGLExtensions::Sized8Formats; + | QOpenGLExtensions::Sized8Formats + | QOpenGLExtensions::TextureSwizzle; } else { // Recognize features by extension name. if (extensionMatcher.match("GL_OES_packed_depth_stencil")) @@ -462,6 +466,17 @@ static int qt_gl_resolve_extensions() // We don't match GL_APPLE_texture_format_BGRA8888 here because it has different semantics. if (extensionMatcher.match("GL_IMG_texture_format_BGRA8888") || extensionMatcher.match("GL_EXT_texture_format_BGRA8888")) extensions |= QOpenGLExtensions::BGRATextureFormat; +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) + QString *deviceName = + static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("AndroidDeviceName")); + static bool wrongfullyReportsBgra8888Support = deviceName != 0 + && (deviceName->compare(QLatin1String("samsung SM-T211"), Qt::CaseInsensitive) == 0 + || deviceName->compare(QLatin1String("samsung SM-T210"), Qt::CaseInsensitive) == 0 + || deviceName->compare(QLatin1String("samsung SM-T215"), Qt::CaseInsensitive) == 0); + if (wrongfullyReportsBgra8888Support) + extensions &= ~QOpenGLExtensions::BGRATextureFormat; +#endif + if (extensionMatcher.match("GL_EXT_discard_framebuffer")) extensions |= QOpenGLExtensions::DiscardFramebuffer; if (extensionMatcher.match("GL_EXT_texture_norm16")) @@ -495,6 +510,9 @@ static int qt_gl_resolve_extensions() if (format.version() >= qMakePair(3, 2) || extensionMatcher.match("GL_ARB_geometry_shader4")) extensions |= QOpenGLExtensions::GeometryShaders; + if (format.version() >= qMakePair(3, 3)) + extensions |= QOpenGLExtensions::TextureSwizzle; + if (extensionMatcher.match("GL_ARB_map_buffer_range")) extensions |= QOpenGLExtensions::MapBufferRange; -- cgit v1.2.3