summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2021-12-06 17:52:20 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-02-25 10:43:42 +0100
commitaca2261dc55ec2d51efbc9186f455b066d374670 (patch)
tree6eac2e9dbf1918ffe57932999bec2d1d654a831d
parent5013891c8cf5b1d0f2cb2cadf406d558dfd59d71 (diff)
downloadqtwebengine-chromium-aca2261dc55ec2d51efbc9186f455b066d374670.tar.gz
Use wglSetPixelFormat directly only if in software mode
For opengl32sw.dll we call wgl* functions directly as gdi32full.dll would call opengl32.dll instead of opengl32sw.dll. However do not call wglSetPixelFormat directly if opengl32.dll is loaded instead of opengl32sw.dll as this might brake internal state of opengl32.dll. Task-number: QTBUG-95568 Change-Id: I39ec95a69f8f58ddb910f1b612f007f1d9e4ba30 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 1df82e89295161ecff60a0140169ffbd057bca40) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--chromium/ui/gl/gl_surface_wgl.cc42
1 files changed, 22 insertions, 20 deletions
diff --git a/chromium/ui/gl/gl_surface_wgl.cc b/chromium/ui/gl/gl_surface_wgl.cc
index 5b53a71d0fb..e496c308d46 100644
--- a/chromium/ui/gl/gl_surface_wgl.cc
+++ b/chromium/ui/gl/gl_surface_wgl.cc
@@ -13,6 +13,7 @@
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_wgl_api_implementation.h"
+#include "ui/gl/init/gl_initializer.h"
namespace gl {
@@ -74,7 +75,7 @@ class DisplayWGL {
module_handle_);
}
- bool Init() {
+ bool Init(bool software_rendering) {
// We must initialize a GL context before we can bind to extension entry
// points. This requires the device context for a window.
if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
@@ -127,27 +128,28 @@ class DisplayWGL {
return false;
}
-#ifdef TOOLKIT_QT
- // wglSetPixelFormat needs to be called instead of SetPixelFormat to allow a differently
- // named software GL implementation library to set up its internal data.
- // The windows gdi.dll SetPixelFormat call directly calls into the stock opengl32.dll,
- // instead of opengl32sw.dll for example.
- typedef BOOL (WINAPI *wglSetPixelFormatProc)(HDC, int, const PIXELFORMATDESCRIPTOR *);
- wglSetPixelFormatProc wglSetPixelFormatFn =
- reinterpret_cast<wglSetPixelFormatProc>(
- GetGLProcAddress("wglSetPixelFormat"));
-
- if (!wglSetPixelFormatFn(device_context_,
-
-#else
- if (!SetPixelFormat(device_context_,
-#endif
- pixel_format_,
- &kPixelFormatDescriptor)) {
+ bool result = false;
+ if (software_rendering) {
+ // wglSetPixelFormat needs to be called instead of SetPixelFormat to allow
+ // a differently named software GL implementation library to set up its
+ // internal data. The windows gdi.dll SetPixelFormat call directly calls
+ // into the stock opengl32.dll, instead of opengl32sw.dll for example.
+ typedef BOOL(WINAPI * wglSetPixelFormatProc)(
+ HDC, int, const PIXELFORMATDESCRIPTOR*);
+ wglSetPixelFormatProc wglSetPixelFormatFn =
+ reinterpret_cast<wglSetPixelFormatProc>(
+ GetGLProcAddress("wglSetPixelFormat"));
+
+ result = wglSetPixelFormatFn(device_context_, pixel_format_,
+ &kPixelFormatDescriptor);
+ } else {
+ result = SetPixelFormat(device_context_, pixel_format_,
+ &kPixelFormatDescriptor);
+ }
+ if (!result) {
LOG(ERROR) << "Unable to set the pixel format for temporary GL context.";
return false;
}
-
return true;
}
@@ -185,7 +187,7 @@ bool GLSurfaceWGL::InitializeOneOff() {
DCHECK(g_wgl_display == NULL);
std::unique_ptr<DisplayWGL> wgl_display(new DisplayWGL);
- if (!wgl_display->Init())
+ if (!wgl_display->Init(init::usingSoftwareDynamicGL()))
return false;
g_wgl_display = wgl_display.release();