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