Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/x11/common/eglonxbackend.cpp
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 115 | if (error != EGL_SUCCESS && error != EGL_BAD_ATTRIBUTE) { | |||
---|---|---|---|---|---|
116 | setFailed(QStringLiteral("query surface failed")); | 116 | setFailed(QStringLiteral("query surface failed")); | ||
117 | return; | 117 | return; | ||
118 | } else { | 118 | } else { | ||
119 | surfaceHasSubPost = EGL_FALSE; | 119 | surfaceHasSubPost = EGL_FALSE; | ||
120 | } | 120 | } | ||
121 | } | 121 | } | ||
122 | } | 122 | } | ||
123 | 123 | | |||
124 | setSyncsToVBlank(false); | | |||
125 | setBlocksForRetrace(true); | 124 | setBlocksForRetrace(true); | ||
126 | if (surfaceHasSubPost) { | 125 | if (surfaceHasSubPost) { | ||
127 | qCDebug(KWIN_CORE) << "EGL implementation and surface support eglPostSubBufferNV, let's use it"; | 126 | qCDebug(KWIN_CORE) << "EGL implementation and surface support eglPostSubBufferNV, let's use it"; | ||
128 | 127 | | |||
129 | if (options->glPreferBufferSwap() != Options::NoSwapEncourage) { | | |||
130 | // check if swap interval 1 is supported | 128 | // check if swap interval 1 is supported | ||
131 | EGLint val; | 129 | EGLint val; | ||
132 | eglGetConfigAttrib(eglDisplay(), config(), EGL_MAX_SWAP_INTERVAL, &val); | 130 | eglGetConfigAttrib(eglDisplay(), config(), EGL_MAX_SWAP_INTERVAL, &val); | ||
133 | if (val >= 1) { | 131 | if (val >= 1) { | ||
134 | if (eglSwapInterval(eglDisplay(), 1)) { | 132 | if (eglSwapInterval(eglDisplay(), 1)) { | ||
135 | qCDebug(KWIN_CORE) << "Enabled v-sync"; | 133 | qCDebug(KWIN_CORE) << "Enabled v-sync"; | ||
136 | setSyncsToVBlank(true); | | |||
137 | } | 134 | } | ||
138 | } else { | 135 | } else { | ||
139 | qCWarning(KWIN_CORE) << "Cannot enable v-sync as max. swap interval is" << val; | 136 | qCWarning(KWIN_CORE) << "Cannot enable v-sync as max. swap interval is" << val; | ||
140 | } | 137 | } | ||
141 | } else { | 138 | | ||
142 | // disable v-sync | | |||
143 | eglSwapInterval(eglDisplay(), 0); | | |||
144 | } | | |||
145 | } else { | 139 | } else { | ||
146 | /* In the GLX backend, we fall back to using glCopyPixels if we have no extension providing support for partial screen updates. | 140 | /* In the GLX backend, we fall back to using glCopyPixels if we have no extension providing support for partial screen updates. | ||
147 | * However, that does not work in EGL - glCopyPixels with glDrawBuffer(GL_FRONT); does nothing. | 141 | * However, that does not work in EGL - glCopyPixels with glDrawBuffer(GL_FRONT); does nothing. | ||
148 | * Hence we need EGL to preserve the backbuffer for us, so that we can draw the partial updates on it and call | 142 | * Hence we need EGL to preserve the backbuffer for us, so that we can draw the partial updates on it and call | ||
149 | * eglSwapBuffers() for each frame. eglSwapBuffers() then does the copy (no page flip possible in this mode), | 143 | * eglSwapBuffers() for each frame. eglSwapBuffers() then does the copy (no page flip possible in this mode), | ||
150 | * which means it is slow and not synced to the v-blank. */ | 144 | * which means it is slow and not synced to the v-blank. */ | ||
151 | qCWarning(KWIN_CORE) << "eglPostSubBufferNV not supported, have to enable buffer preservation - which breaks v-sync and performance"; | 145 | qCWarning(KWIN_CORE) << "eglPostSubBufferNV not supported, have to enable buffer preservation - which breaks v-sync and performance"; | ||
152 | eglSurfaceAttrib(eglDisplay(), surface(), EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); | 146 | eglSurfaceAttrib(eglDisplay(), surface(), EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); | ||
▲ Show 20 Lines • Show All 345 Lines • Show Last 20 Lines |