Changeset View
Changeset View
Standalone View
Standalone View
scene_opengl.cpp
Show All 40 Lines | |||||
41 | #include "lanczosfilter.h" | 41 | #include "lanczosfilter.h" | ||
42 | #include "main.h" | 42 | #include "main.h" | ||
43 | #include "overlaywindow.h" | 43 | #include "overlaywindow.h" | ||
44 | #include "screens.h" | 44 | #include "screens.h" | ||
45 | #include "decorations/decoratedclient.h" | 45 | #include "decorations/decoratedclient.h" | ||
46 | 46 | | |||
47 | #include <KWayland/Server/subcompositor_interface.h> | 47 | #include <KWayland/Server/subcompositor_interface.h> | ||
48 | #include <KWayland/Server/surface_interface.h> | 48 | #include <KWayland/Server/surface_interface.h> | ||
49 | #include <KWayland/Server/buffer_interface.h> | ||||
49 | 50 | | |||
50 | #include <array> | 51 | #include <array> | ||
51 | #include <cmath> | 52 | #include <cmath> | ||
52 | #include <unistd.h> | 53 | #include <unistd.h> | ||
53 | #include <stddef.h> | 54 | #include <stddef.h> | ||
54 | 55 | | |||
55 | #include <qpainter.h> | 56 | #include <qpainter.h> | ||
56 | #include <QDBusConnection> | 57 | #include <QDBusConnection> | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | |||||
370 | 371 | | |||
371 | void OpenGLBackend::endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) | 372 | void OpenGLBackend::endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) | ||
372 | { | 373 | { | ||
373 | Q_UNUSED(screenId) | 374 | Q_UNUSED(screenId) | ||
374 | Q_UNUSED(damage) | 375 | Q_UNUSED(damage) | ||
375 | Q_UNUSED(damagedRegion) | 376 | Q_UNUSED(damagedRegion) | ||
376 | } | 377 | } | ||
377 | 378 | | |||
379 | bool OpenGLBackend::directScanoutForScreen(int screenId, KWayland::Server::BufferInterface *buffer) | ||||
380 | { | ||||
381 | Q_UNUSED(screenId) | ||||
382 | Q_UNUSED(buffer) | ||||
383 | return false; | ||||
384 | } | ||||
385 | | ||||
378 | bool OpenGLBackend::perScreenRendering() const | 386 | bool OpenGLBackend::perScreenRendering() const | ||
379 | { | 387 | { | ||
380 | return false; | 388 | return false; | ||
381 | } | 389 | } | ||
382 | 390 | | |||
383 | /************************************************ | 391 | /************************************************ | ||
384 | * SceneOpenGL | 392 | * SceneOpenGL | ||
385 | ***********************************************/ | 393 | ***********************************************/ | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 690 | { | |||
684 | createStackingOrder(toplevels); | 692 | createStackingOrder(toplevels); | ||
685 | 693 | | |||
686 | // After this call, updateRegion will contain the damaged region in the | 694 | // After this call, updateRegion will contain the damaged region in the | ||
687 | // back buffer. This is the region that needs to be posted to repair | 695 | // back buffer. This is the region that needs to be posted to repair | ||
688 | // the front buffer. It doesn't include the additional damage returned | 696 | // the front buffer. It doesn't include the additional damage returned | ||
689 | // by prepareRenderingFrame(). validRegion is the region that has been | 697 | // by prepareRenderingFrame(). validRegion is the region that has been | ||
690 | // repainted, and may be larger than updateRegion. | 698 | // repainted, and may be larger than updateRegion. | ||
691 | QRegion updateRegion, validRegion; | 699 | QRegion updateRegion, validRegion; | ||
700 | | ||||
692 | if (m_backend->perScreenRendering()) { | 701 | if (m_backend->perScreenRendering()) { | ||
693 | // trigger start render timer | 702 | // trigger start render timer | ||
694 | m_backend->prepareRenderingFrame(); | 703 | m_backend->prepareRenderingFrame(); | ||
704 | | ||||
695 | for (int i = 0; i < screens()->count(); ++i) { | 705 | for (int i = 0; i < screens()->count(); ++i) { | ||
706 | // TODO_X: What about effects operating on the fullscreen window itself? Need to do it after pre paint phase? | ||||
707 | if (m_backend->supportsDirectFullScreenScanout() && directScanout(i)) { | ||||
708 | continue; | ||||
709 | } | ||||
710 | | ||||
711 | // TODO_X: Or use this directly (i.e. without updateBuffer() of the WindowPixmaps)? What about subsurfaces? | ||||
712 | // if (m_backend->supportsDirectFullScreenScanout() && toplevels.count() > 0) { | ||||
713 | // bool isDirectScanout = false; | ||||
714 | // for (int j = toplevels.count() - 1; 0 < j; --j) { | ||||
715 | // Toplevel *t = toplevels[j]; | ||||
716 | // AbstractClient *c = dynamic_cast<AbstractClient*>(t); | ||||
717 | // if (t->isOnScreen(i)) { | ||||
718 | // // check if opaque full screen windows | ||||
719 | // if (c && c->isFullScreen() && c->opacity() == 1.0 && !c->hasAlpha() && c->surface()) { //TODO_X: what about shm buffers? | ||||
720 | // if (KWayland::Server::BufferInterface *b = c->surface()->buffer()) { | ||||
721 | // // put wayland buffer on scanout plane | ||||
722 | // isDirectScanout = m_backend->directScanoutForScreen(i, b); | ||||
723 | // } | ||||
724 | // } | ||||
725 | // break; | ||||
726 | // } | ||||
727 | // } | ||||
728 | // if (isDirectScanout) { | ||||
729 | // continue; | ||||
730 | // } | ||||
731 | // } | ||||
732 | | ||||
696 | const QRect &geo = screens()->geometry(i); | 733 | const QRect &geo = screens()->geometry(i); | ||
697 | QRegion update; | 734 | QRegion update; | ||
698 | QRegion valid; | 735 | QRegion valid; | ||
736 | | ||||
699 | // prepare rendering makes context current on the output | 737 | // prepare rendering makes context current on the output | ||
700 | QRegion repaint = m_backend->prepareRenderingForScreen(i); | 738 | QRegion repaint = m_backend->prepareRenderingForScreen(i); | ||
739 | | ||||
701 | GLVertexBuffer::setVirtualScreenGeometry(geo); | 740 | GLVertexBuffer::setVirtualScreenGeometry(geo); | ||
702 | GLRenderTarget::setVirtualScreenGeometry(geo); | 741 | GLRenderTarget::setVirtualScreenGeometry(geo); | ||
703 | 742 | | |||
704 | const GLenum status = glGetGraphicsResetStatus(); | 743 | const GLenum status = glGetGraphicsResetStatus(); | ||
705 | if (status != GL_NO_ERROR) { | 744 | if (status != GL_NO_ERROR) { | ||
706 | handleGraphicsReset(status); | 745 | handleGraphicsReset(status); | ||
707 | return 0; | 746 | return 0; | ||
708 | } | 747 | } | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 797 | if (m_currentFence) { | |||
765 | m_currentFence = nullptr; | 804 | m_currentFence = nullptr; | ||
766 | } | 805 | } | ||
767 | 806 | | |||
768 | // do cleanup | 807 | // do cleanup | ||
769 | clearStackingOrder(); | 808 | clearStackingOrder(); | ||
770 | return m_backend->renderTime(); | 809 | return m_backend->renderTime(); | ||
771 | } | 810 | } | ||
772 | 811 | | |||
812 | bool SceneOpenGL::directScanout(int screen) | ||||
813 | { | ||||
814 | for (int j = stacking_order.count() - 1; 0 < j; --j) { | ||||
815 | Scene::Window *w = stacking_order[j]; | ||||
816 | AbstractClient *c = dynamic_cast<AbstractClient*>(w->window()); | ||||
817 | if (!c || c->isOnScreen(screen)) { | ||||
818 | // check if opaque full screen windows | ||||
819 | if (c && c->isFullScreen() && c->opacity() == 1.0 && !c->hasAlpha() && c->surface() && c->surface()->buffer()) { //TODO_X: what about shm buffers? | ||||
820 | // put wayland buffer on scanout plane | ||||
821 | OpenGLWindowPixmap *wp = w->windowPixmap<OpenGLWindowPixmap>(); | ||||
822 | wp->updateBuffer(); | ||||
823 | return m_backend->directScanoutForScreen(screen, wp->buffer().data()); | ||||
824 | } | ||||
825 | return false; | ||||
826 | } | ||||
827 | } | ||||
828 | return false; | ||||
829 | } | ||||
830 | | ||||
773 | QMatrix4x4 SceneOpenGL::transformation(int mask, const ScreenPaintData &data) const | 831 | QMatrix4x4 SceneOpenGL::transformation(int mask, const ScreenPaintData &data) const | ||
774 | { | 832 | { | ||
775 | QMatrix4x4 matrix; | 833 | QMatrix4x4 matrix; | ||
776 | 834 | | |||
777 | if (!(mask & PAINT_SCREEN_TRANSFORMED)) | 835 | if (!(mask & PAINT_SCREEN_TRANSFORMED)) | ||
778 | return matrix; | 836 | return matrix; | ||
779 | 837 | | |||
780 | matrix.translate(data.translation()); | 838 | matrix.translate(data.translation()); | ||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |