Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/x11/standalone/glxbackend.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | |||||
103 | // ----------------------------------------------------------------------- | 103 | // ----------------------------------------------------------------------- | ||
104 | 104 | | |||
105 | 105 | | |||
106 | 106 | | |||
107 | GlxBackend::GlxBackend(Display *display) | 107 | GlxBackend::GlxBackend(Display *display) | ||
108 | : OpenGLBackend() | 108 | : OpenGLBackend() | ||
109 | , m_overlayWindow(kwinApp()->platform()->createOverlayWindow()) | 109 | , m_overlayWindow(kwinApp()->platform()->createOverlayWindow()) | ||
110 | , window(None) | 110 | , window(None) | ||
111 | , fbconfig(NULL) | 111 | , fbconfig(nullptr) | ||
112 | , glxWindow(None) | 112 | , glxWindow(None) | ||
113 | , ctx(nullptr) | 113 | , ctx(nullptr) | ||
114 | , m_bufferAge(0) | 114 | , m_bufferAge(0) | ||
115 | , haveSwapInterval(false) | 115 | , haveSwapInterval(false) | ||
116 | , m_x11Display(display) | 116 | , m_x11Display(display) | ||
117 | { | 117 | { | ||
118 | // Ensures calls to glXSwapBuffers will always block until the next | 118 | // Ensures calls to glXSwapBuffers will always block until the next | ||
119 | // retrace when using the proprietary NVIDIA driver. This must be | 119 | // retrace when using the proprietary NVIDIA driver. This must be | ||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Line(s) | 178 | { | |||
266 | } else { | 266 | } else { | ||
267 | // disable v-sync (if possible) | 267 | // disable v-sync (if possible) | ||
268 | setSwapInterval(0); | 268 | setSwapInterval(0); | ||
269 | } | 269 | } | ||
270 | if (glPlatform->isVirtualBox()) { | 270 | if (glPlatform->isVirtualBox()) { | ||
271 | // VirtualBox does not support glxQueryDrawable | 271 | // VirtualBox does not support glxQueryDrawable | ||
272 | // this should actually be in kwinglutils_funcs, but QueryDrawable seems not to be provided by an extension | 272 | // this should actually be in kwinglutils_funcs, but QueryDrawable seems not to be provided by an extension | ||
273 | // and the GLPlatform has not been initialized at the moment when initGLX() is called. | 273 | // and the GLPlatform has not been initialized at the moment when initGLX() is called. | ||
274 | glXQueryDrawable = NULL; | 274 | glXQueryDrawable = nullptr; | ||
275 | } | 275 | } | ||
276 | 276 | | |||
277 | setIsDirectRendering(bool(glXIsDirect(display(), ctx))); | 277 | setIsDirectRendering(bool(glXIsDirect(display(), ctx))); | ||
278 | 278 | | |||
279 | qCDebug(KWIN_X11STANDALONE) << "Direct rendering:" << isDirectRendering(); | 279 | qCDebug(KWIN_X11STANDALONE) << "Direct rendering:" << isDirectRendering(); | ||
280 | } | 280 | } | ||
281 | 281 | | |||
282 | bool GlxBackend::checkVersion() | 282 | bool GlxBackend::checkVersion() | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 323 | if (have_robustness) { | |||
332 | candidates.emplace_back(std::move(robustLegacy)); | 332 | candidates.emplace_back(std::move(robustLegacy)); | ||
333 | } | 333 | } | ||
334 | GlxContextAttributeBuilder legacy; | 334 | GlxContextAttributeBuilder legacy; | ||
335 | legacy.setVersion(2, 1); | 335 | legacy.setVersion(2, 1); | ||
336 | candidates.emplace_back(std::move(legacy)); | 336 | candidates.emplace_back(std::move(legacy)); | ||
337 | } | 337 | } | ||
338 | for (auto it = candidates.begin(); it != candidates.end(); it++) { | 338 | for (auto it = candidates.begin(); it != candidates.end(); it++) { | ||
339 | const auto attribs = it->build(); | 339 | const auto attribs = it->build(); | ||
340 | ctx = glXCreateContextAttribsARB(display(), fbconfig, 0, true, attribs.data()); | 340 | ctx = glXCreateContextAttribsARB(display(), fbconfig, nullptr, true, attribs.data()); | ||
341 | if (ctx) { | 341 | if (ctx) { | ||
342 | qCDebug(KWIN_X11STANDALONE) << "Created GLX context with attributes:" << &(*it); | 342 | qCDebug(KWIN_X11STANDALONE) << "Created GLX context with attributes:" << &(*it); | ||
343 | break; | 343 | break; | ||
344 | } | 344 | } | ||
345 | } | 345 | } | ||
346 | } | 346 | } | ||
347 | 347 | | |||
348 | if (!ctx) | 348 | if (!ctx) | ||
349 | ctx = glXCreateNewContext(display(), fbconfig, GLX_RGBA_TYPE, NULL, direct); | 349 | ctx = glXCreateNewContext(display(), fbconfig, GLX_RGBA_TYPE, nullptr, direct); | ||
350 | 350 | | |||
351 | if (!ctx) { | 351 | if (!ctx) { | ||
352 | qCDebug(KWIN_X11STANDALONE) << "Failed to create an OpenGL context."; | 352 | qCDebug(KWIN_X11STANDALONE) << "Failed to create an OpenGL context."; | ||
353 | return false; | 353 | return false; | ||
354 | } | 354 | } | ||
355 | 355 | | |||
356 | if (!glXMakeCurrent(display(), glxWindow, ctx)) { | 356 | if (!glXMakeCurrent(display(), glxWindow, ctx)) { | ||
357 | qCDebug(KWIN_X11STANDALONE) << "Failed to make the OpenGL context current."; | 357 | qCDebug(KWIN_X11STANDALONE) << "Failed to make the OpenGL context current."; | ||
358 | glXDestroyContext(display(), ctx); | 358 | glXDestroyContext(display(), ctx); | ||
359 | ctx = 0; | 359 | ctx = nullptr; | ||
360 | return false; | 360 | return false; | ||
361 | } | 361 | } | ||
362 | 362 | | |||
363 | return true; | 363 | return true; | ||
364 | } | 364 | } | ||
365 | 365 | | |||
366 | bool GlxBackend::initBuffer() | 366 | bool GlxBackend::initBuffer() | ||
367 | { | 367 | { | ||
Show All 17 Lines | 371 | if (overlayWindow()->create()) { | |||
385 | 385 | | |||
386 | const QSize size = screens()->size(); | 386 | const QSize size = screens()->size(); | ||
387 | 387 | | |||
388 | window = xcb_generate_id(c); | 388 | window = xcb_generate_id(c); | ||
389 | xcb_create_window(c, visualDepth(visual), window, overlayWindow()->window(), | 389 | xcb_create_window(c, visualDepth(visual), window, overlayWindow()->window(), | ||
390 | 0, 0, size.width(), size.height(), 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, | 390 | 0, 0, size.width(), size.height(), 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, | ||
391 | visual, XCB_CW_COLORMAP, &colormap); | 391 | visual, XCB_CW_COLORMAP, &colormap); | ||
392 | 392 | | |||
393 | glxWindow = glXCreateWindow(display(), fbconfig, window, NULL); | 393 | glxWindow = glXCreateWindow(display(), fbconfig, window, nullptr); | ||
394 | overlayWindow()->setup(window); | 394 | overlayWindow()->setup(window); | ||
395 | } else { | 395 | } else { | ||
396 | qCCritical(KWIN_X11STANDALONE) << "Failed to create overlay window"; | 396 | qCCritical(KWIN_X11STANDALONE) << "Failed to create overlay window"; | ||
397 | return false; | 397 | return false; | ||
398 | } | 398 | } | ||
399 | 399 | | |||
400 | return true; | 400 | return true; | ||
401 | } | 401 | } | ||
▲ Show 20 Lines • Show All 478 Lines • ▼ Show 20 Line(s) | 875 | if (m_glxpixmap != None) { | |||
880 | m_glxpixmap = None; | 880 | m_glxpixmap = None; | ||
881 | } | 881 | } | ||
882 | } | 882 | } | ||
883 | 883 | | |||
884 | void GlxTexture::onDamage() | 884 | void GlxTexture::onDamage() | ||
885 | { | 885 | { | ||
886 | if (options->isGlStrictBinding() && m_glxpixmap) { | 886 | if (options->isGlStrictBinding() && m_glxpixmap) { | ||
887 | glXReleaseTexImageEXT(display(), m_glxpixmap, GLX_FRONT_LEFT_EXT); | 887 | glXReleaseTexImageEXT(display(), m_glxpixmap, GLX_FRONT_LEFT_EXT); | ||
888 | glXBindTexImageEXT(display(), m_glxpixmap, GLX_FRONT_LEFT_EXT, NULL); | 888 | glXBindTexImageEXT(display(), m_glxpixmap, GLX_FRONT_LEFT_EXT, nullptr); | ||
889 | } | 889 | } | ||
890 | GLTexturePrivate::onDamage(); | 890 | GLTexturePrivate::onDamage(); | ||
891 | } | 891 | } | ||
892 | 892 | | |||
893 | bool GlxTexture::loadTexture(xcb_pixmap_t pixmap, const QSize &size, xcb_visualid_t visual) | 893 | bool GlxTexture::loadTexture(xcb_pixmap_t pixmap, const QSize &size, xcb_visualid_t visual) | ||
894 | { | 894 | { | ||
895 | if (pixmap == XCB_NONE || size.isEmpty() || visual == XCB_NONE) | 895 | if (pixmap == XCB_NONE || size.isEmpty() || visual == XCB_NONE) | ||
896 | return false; | 896 | return false; | ||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |