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 673 Lines • ▼ Show 20 Line(s) | |||||
708 | } | 709 | } | ||
709 | 710 | | |||
710 | void DrmOutput::transform(KWayland::Server::OutputDeviceInterface::Transform transform) | 711 | void DrmOutput::transform(KWayland::Server::OutputDeviceInterface::Transform transform) | ||
711 | { | 712 | { | ||
712 | waylandOutputDevice()->setTransform(transform); | 713 | waylandOutputDevice()->setTransform(transform); | ||
713 | using KWayland::Server::OutputDeviceInterface; | 714 | using KWayland::Server::OutputDeviceInterface; | ||
714 | using KWayland::Server::OutputInterface; | 715 | using KWayland::Server::OutputInterface; | ||
715 | auto wlOutput = waylandOutput(); | 716 | auto wlOutput = waylandOutput(); | ||
717 | m_softwareRotationAngle = 0; | ||||
716 | 718 | | |||
717 | switch (transform) { | 719 | switch (transform) { | ||
718 | case OutputDeviceInterface::Transform::Normal: | 720 | case OutputDeviceInterface::Transform::Normal: | ||
719 | if (m_primaryPlane) { | 721 | if (m_primaryPlane) { | ||
720 | m_primaryPlane->setTransformation(DrmPlane::Transformation::Rotate0); | 722 | m_primaryPlane->setTransformation(DrmPlane::Transformation::Rotate0); | ||
721 | } | 723 | } | ||
722 | if (wlOutput) { | 724 | if (wlOutput) { | ||
723 | wlOutput->setTransform(OutputInterface::Transform::Normal); | 725 | wlOutput->setTransform(OutputInterface::Transform::Normal); | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 791 | { | |||
799 | } | 801 | } | ||
800 | m_mode = connector->modes[modeIndex]; | 802 | m_mode = connector->modes[modeIndex]; | ||
801 | m_modesetRequested = true; | 803 | m_modesetRequested = true; | ||
802 | setWaylandMode(); | 804 | setWaylandMode(); | ||
803 | } | 805 | } | ||
804 | 806 | | |||
805 | QSize DrmOutput::pixelSize() const | 807 | QSize DrmOutput::pixelSize() const | ||
806 | { | 808 | { | ||
807 | return orientateSize(QSize(m_mode.hdisplay, m_mode.vdisplay)); | 809 | return QSize(m_mode.hdisplay, m_mode.vdisplay); | ||
808 | } | 810 | } | ||
809 | 811 | | |||
810 | void DrmOutput::setWaylandMode() | 812 | void DrmOutput::setWaylandMode() | ||
811 | { | 813 | { | ||
812 | AbstractOutput::setWaylandMode(QSize(m_mode.hdisplay, m_mode.vdisplay), | 814 | AbstractOutput::setWaylandMode(QSize(m_mode.hdisplay, m_mode.vdisplay), | ||
813 | refreshRateForMode(&m_mode)); | 815 | refreshRateForMode(&m_mode)); | ||
814 | } | 816 | } | ||
815 | 817 | | |||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 879 | { | |||
892 | } | 894 | } | ||
893 | m_nextPlanesFlipList.clear(); | 895 | m_nextPlanesFlipList.clear(); | ||
894 | dpmsOffHandler(); | 896 | dpmsOffHandler(); | ||
895 | 897 | | |||
896 | return true; | 898 | return true; | ||
897 | 899 | | |||
898 | } | 900 | } | ||
899 | 901 | | |||
902 | ///Copied from QPlatformScreen | ||||
903 | static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) | ||||
904 | { | ||||
905 | if (a == Qt::PrimaryOrientation) a = Qt::LandscapeOrientation; | ||||
906 | if (b == Qt::PrimaryOrientation) b = Qt::LandscapeOrientation; | ||||
907 | | ||||
908 | if (a == b) | ||||
909 | return 0; | ||||
910 | | ||||
911 | int ia = std::log2(uint(a)); | ||||
912 | int ib = std::log2(uint(b)); | ||||
913 | | ||||
914 | int delta = ia - ib; | ||||
915 | | ||||
916 | if (delta < 0) | ||||
917 | delta = delta + 4; | ||||
918 | | ||||
919 | int angles[] = { 0, 90, 180, 270 }; | ||||
920 | return angles[delta]; | ||||
921 | } | ||||
zzag: I know that you copied this code, but could we maybe re-format it accordingly to the Frameworks… | |||||
apol: I would rather not. | |||||
922 | | ||||
900 | bool DrmOutput::presentAtomically(DrmBuffer *buffer) | 923 | bool DrmOutput::presentAtomically(DrmBuffer *buffer) | ||
901 | { | 924 | { | ||
902 | if (!LogindIntegration::self()->isActiveSession()) { | 925 | if (!LogindIntegration::self()->isActiveSession()) { | ||
903 | qCWarning(KWIN_DRM) << "Logind session not active."; | 926 | qCWarning(KWIN_DRM) << "Logind session not active."; | ||
904 | return false; | 927 | return false; | ||
905 | } | 928 | } | ||
906 | 929 | | |||
907 | if (m_pageFlipPending) { | 930 | if (m_pageFlipPending) { | ||
908 | qCWarning(KWIN_DRM) << "Page not yet flipped."; | 931 | qCWarning(KWIN_DRM) << "Page not yet flipped."; | ||
909 | return false; | 932 | return false; | ||
910 | } | 933 | } | ||
911 | 934 | | |||
912 | m_primaryPlane->setNext(buffer); | 935 | m_primaryPlane->setNext(buffer); | ||
913 | m_nextPlanesFlipList << m_primaryPlane; | 936 | m_nextPlanesFlipList << m_primaryPlane; | ||
914 | 937 | | |||
915 | if (!doAtomicCommit(AtomicCommitMode::Test)) { | 938 | if (!doAtomicCommit(AtomicCommitMode::Test)) { | ||
916 | //TODO: When we use planes for layered rendering, fallback to renderer instead. Also for direct scanout? | 939 | //TODO: When we use planes for layered rendering, fallback to renderer instead. Also for direct scanout? | ||
917 | //TODO: Probably should undo setNext and reset the flip list | 940 | //TODO: Probably should undo setNext and reset the flip list | ||
918 | qCDebug(KWIN_DRM) << "Atomic test commit failed. Aborting present."; | 941 | qCDebug(KWIN_DRM) << "Atomic test commit failed. Aborting present."; | ||
919 | // go back to previous state | 942 | // go back to previous state | ||
920 | if (m_lastWorkingState.valid) { | 943 | if (m_lastWorkingState.valid) { | ||
921 | m_mode = m_lastWorkingState.mode; | 944 | m_mode = m_lastWorkingState.mode; | ||
922 | setOrientation(m_lastWorkingState.orientation); | 945 | m_softwareRotationAngle = angleBetween(m_lastWorkingState.orientation, orientation()); | ||
946 | qCDebug(KWIN_DRM) << "software rotation to" << m_softwareRotationAngle; | ||||
923 | setGlobalPos(m_lastWorkingState.globalPos); | 947 | setGlobalPos(m_lastWorkingState.globalPos); | ||
924 | if (m_primaryPlane) { | 948 | if (m_primaryPlane) { | ||
925 | m_primaryPlane->setTransformation(m_lastWorkingState.planeTransformations); | 949 | m_primaryPlane->setTransformation(m_lastWorkingState.planeTransformations); | ||
926 | } | 950 | } | ||
927 | m_modesetRequested = true; | 951 | m_modesetRequested = true; | ||
928 | // the cursor might need to get rotated | 952 | // the cursor might need to get rotated | ||
929 | updateCursor(); | 953 | updateCursor(); | ||
930 | showCursor(); | 954 | 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.