Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.cpp
Show All 18 Lines | |||||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "drm_output.h" | 20 | #include "drm_output.h" | ||
21 | #include "drm_backend.h" | 21 | #include "drm_backend.h" | ||
22 | #include "drm_object_plane.h" | 22 | #include "drm_object_plane.h" | ||
23 | #include "drm_object_crtc.h" | 23 | #include "drm_object_crtc.h" | ||
24 | #include "drm_object_connector.h" | 24 | #include "drm_object_connector.h" | ||
25 | 25 | | |||
26 | #include <errno.h> | 26 | #include <errno.h> | ||
27 | #include <cmath> | ||||
27 | 28 | | |||
28 | #include "composite.h" | 29 | #include "composite.h" | ||
29 | #include "logind.h" | 30 | #include "logind.h" | ||
30 | #include "logging.h" | 31 | #include "logging.h" | ||
31 | #include "main.h" | 32 | #include "main.h" | ||
32 | #include "orientation_sensor.h" | 33 | #include "orientation_sensor.h" | ||
33 | #include "screens_drm.h" | 34 | #include "screens_drm.h" | ||
34 | #include "wayland_server.h" | 35 | #include "wayland_server.h" | ||
▲ Show 20 Lines • Show All 743 Lines • ▼ Show 20 Line(s) | 769 | { | |||
778 | } | 779 | } | ||
779 | m_mode = connector->modes[modeIndex]; | 780 | m_mode = connector->modes[modeIndex]; | ||
780 | m_modesetRequested = true; | 781 | m_modesetRequested = true; | ||
781 | setWaylandMode(); | 782 | setWaylandMode(); | ||
782 | } | 783 | } | ||
783 | 784 | | |||
784 | QSize DrmOutput::pixelSize() const | 785 | QSize DrmOutput::pixelSize() const | ||
785 | { | 786 | { | ||
786 | return orientateSize(QSize(m_mode.hdisplay, m_mode.vdisplay)); | 787 | return QSize(m_mode.hdisplay, m_mode.vdisplay); | ||
787 | } | 788 | } | ||
788 | 789 | | |||
789 | void DrmOutput::setWaylandMode() | 790 | void DrmOutput::setWaylandMode() | ||
790 | { | 791 | { | ||
791 | AbstractOutput::setWaylandMode(QSize(m_mode.hdisplay, m_mode.vdisplay), | 792 | AbstractOutput::setWaylandMode(QSize(m_mode.hdisplay, m_mode.vdisplay), | ||
792 | refreshRateForMode(&m_mode)); | 793 | refreshRateForMode(&m_mode)); | ||
793 | } | 794 | } | ||
794 | 795 | | |||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 857 | { | |||
871 | } | 872 | } | ||
872 | m_nextPlanesFlipList.clear(); | 873 | m_nextPlanesFlipList.clear(); | ||
873 | dpmsOffHandler(); | 874 | dpmsOffHandler(); | ||
874 | 875 | | |||
875 | return true; | 876 | return true; | ||
876 | 877 | | |||
877 | } | 878 | } | ||
878 | 879 | | |||
880 | ///Copied from QPlatformScreen | ||||
881 | static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) | ||||
882 | { | ||||
883 | if (a == Qt::PrimaryOrientation) a = Qt::LandscapeOrientation; | ||||
884 | if (b == Qt::PrimaryOrientation) b = Qt::LandscapeOrientation; | ||||
885 | | ||||
886 | if (a == b) | ||||
887 | return 0; | ||||
888 | | ||||
889 | int ia = std::log2(uint(a)); | ||||
890 | int ib = std::log2(uint(b)); | ||||
891 | | ||||
892 | int delta = ia - ib; | ||||
893 | | ||||
894 | if (delta < 0) | ||||
895 | delta = delta + 4; | ||||
896 | | ||||
897 | int angles[] = { 0, 90, 180, 270 }; | ||||
898 | return angles[delta]; | ||||
899 | } | ||||
zzag: I know that you copied this code, but could we maybe re-format it accordingly to the Frameworks… | |||||
apol: I would rather not. | |||||
900 | | ||||
879 | bool DrmOutput::presentAtomically(DrmBuffer *buffer) | 901 | bool DrmOutput::presentAtomically(DrmBuffer *buffer) | ||
880 | { | 902 | { | ||
881 | if (!LogindIntegration::self()->isActiveSession()) { | 903 | if (!LogindIntegration::self()->isActiveSession()) { | ||
882 | qCWarning(KWIN_DRM) << "Logind session not active."; | 904 | qCWarning(KWIN_DRM) << "Logind session not active."; | ||
883 | return false; | 905 | return false; | ||
884 | } | 906 | } | ||
885 | 907 | | |||
886 | if (m_pageFlipPending) { | 908 | if (m_pageFlipPending) { | ||
887 | qCWarning(KWIN_DRM) << "Page not yet flipped."; | 909 | qCWarning(KWIN_DRM) << "Page not yet flipped."; | ||
888 | return false; | 910 | return false; | ||
889 | } | 911 | } | ||
890 | 912 | | |||
891 | m_primaryPlane->setNext(buffer); | 913 | m_primaryPlane->setNext(buffer); | ||
892 | m_nextPlanesFlipList << m_primaryPlane; | 914 | m_nextPlanesFlipList << m_primaryPlane; | ||
893 | 915 | | |||
916 | m_softwareRotationAngle = 0; | ||||
894 | if (!doAtomicCommit(AtomicCommitMode::Test)) { | 917 | if (!doAtomicCommit(AtomicCommitMode::Test)) { | ||
895 | //TODO: When we use planes for layered rendering, fallback to renderer instead. Also for direct scanout? | 918 | //TODO: When we use planes for layered rendering, fallback to renderer instead. Also for direct scanout? | ||
896 | //TODO: Probably should undo setNext and reset the flip list | 919 | //TODO: Probably should undo setNext and reset the flip list | ||
897 | qCDebug(KWIN_DRM) << "Atomic test commit failed. Aborting present."; | 920 | qCDebug(KWIN_DRM) << "Atomic test commit failed. Aborting present."; | ||
898 | // go back to previous state | 921 | // go back to previous state | ||
899 | if (m_lastWorkingState.valid) { | 922 | if (m_lastWorkingState.valid) { | ||
900 | m_mode = m_lastWorkingState.mode; | 923 | m_mode = m_lastWorkingState.mode; | ||
901 | setOrientation(m_lastWorkingState.orientation); | 924 | m_softwareRotationAngle = angleBetween(m_lastWorkingState.orientation, orientation()); | ||
925 | qDebug() << "setting software rotation to" << m_softwareRotationAngle; | ||||
902 | setGlobalPos(m_lastWorkingState.globalPos); | 926 | setGlobalPos(m_lastWorkingState.globalPos); | ||
903 | if (m_primaryPlane) { | 927 | if (m_primaryPlane) { | ||
904 | m_primaryPlane->setTransformation(m_lastWorkingState.planeTransformations); | 928 | m_primaryPlane->setTransformation(m_lastWorkingState.planeTransformations); | ||
905 | } | 929 | } | ||
906 | m_modesetRequested = true; | 930 | m_modesetRequested = true; | ||
907 | // the cursor might need to get rotated | 931 | // the cursor might need to get rotated | ||
908 | updateCursor(); | 932 | updateCursor(); | ||
909 | showCursor(); | 933 | showCursor(); | ||
▲ Show 20 Lines • Show All 259 Lines • Show Last 20 Lines |
I know that you copied this code, but could we maybe re-format it accordingly to the Frameworks coding style?
Also, it would be great to use more const.