diff options
Diffstat (limited to 'src/platformsupport/eglconvenience')
-rw-r--r-- | src/platformsupport/eglconvenience/qeglplatformcontext.cpp | 8 | ||||
-rw-r--r-- | src/platformsupport/eglconvenience/qxlibeglintegration.cpp | 17 |
2 files changed, 11 insertions, 14 deletions
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 8152f74067..34ba21afdc 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -106,6 +106,14 @@ bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface) EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface); + // shortcut: on some GPUs, eglMakeCurrent is not a cheap operation + if (eglGetCurrentContext() == m_eglContext && + eglGetCurrentDisplay() == m_eglDisplay && + eglGetCurrentSurface(EGL_READ) == eglSurface && + eglGetCurrentSurface(EGL_DRAW) == eglSurface) { + return true; + } + bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext); if (!ok) qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this); diff --git a/src/platformsupport/eglconvenience/qxlibeglintegration.cpp b/src/platformsupport/eglconvenience/qxlibeglintegration.cpp index 58f24c0a04..80453816fc 100644 --- a/src/platformsupport/eglconvenience/qxlibeglintegration.cpp +++ b/src/platformsupport/eglconvenience/qxlibeglintegration.cpp @@ -41,17 +41,6 @@ #include "qxlibeglintegration_p.h" -static int countBits(unsigned long mask) -{ - int count = 0; - while (mask != 0) { - if (mask & 1) - ++count; - mask >>= 1; - } - return count; -} - VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config) { VisualID visualId = 0; @@ -92,9 +81,9 @@ VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay return visualId; } - int visualRedSize = countBits(chosenVisualInfo->red_mask); - int visualGreenSize = countBits(chosenVisualInfo->green_mask); - int visualBlueSize = countBits(chosenVisualInfo->blue_mask); + int visualRedSize = qPopulationCount(chosenVisualInfo->red_mask); + int visualGreenSize = qPopulationCount(chosenVisualInfo->green_mask); + int visualBlueSize = qPopulationCount(chosenVisualInfo->blue_mask); int visualAlphaSize = -1; // Need XRender to tell us the alpha channel size bool visualMatchesConfig = false; |