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 652 Lines • ▼ Show 20 Line(s) | |||||
687 | } | 688 | } | ||
688 | 689 | | |||
689 | void DrmOutput::transform(KWayland::Server::OutputDeviceInterface::Transform transform) | 690 | void DrmOutput::transform(KWayland::Server::OutputDeviceInterface::Transform transform) | ||
690 | { | 691 | { | ||
691 | waylandOutputDevice()->setTransform(transform); | 692 | waylandOutputDevice()->setTransform(transform); | ||
692 | using KWayland::Server::OutputDeviceInterface; | 693 | using KWayland::Server::OutputDeviceInterface; | ||
693 | using KWayland::Server::OutputInterface; | 694 | using KWayland::Server::OutputInterface; | ||
694 | auto wlOutput = waylandOutput(); | 695 | auto wlOutput = waylandOutput(); | ||
696 | m_softwareRotationAngle = 0; | ||||
695 | 697 | | |||
696 | switch (transform) { | 698 | switch (transform) { | ||
697 | case OutputDeviceInterface::Transform::Normal: | 699 | case OutputDeviceInterface::Transform::Normal: | ||
698 | if (m_primaryPlane) { | 700 | if (m_primaryPlane) { | ||
699 | m_primaryPlane->setTransformation(DrmPlane::Transformation::Rotate0); | 701 | m_primaryPlane->setTransformation(DrmPlane::Transformation::Rotate0); | ||
700 | } | 702 | } | ||
701 | if (wlOutput) { | 703 | if (wlOutput) { | ||
702 | wlOutput->setTransform(OutputInterface::Transform::Normal); | 704 | wlOutput->setTransform(OutputInterface::Transform::Normal); | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 770 | { | |||
778 | } | 780 | } | ||
779 | m_mode = connector->modes[modeIndex]; | 781 | m_mode = connector->modes[modeIndex]; | ||
780 | m_modesetRequested = true; | 782 | m_modesetRequested = true; | ||
781 | setWaylandMode(); | 783 | setWaylandMode(); | ||
782 | } | 784 | } | ||
783 | 785 | | |||
784 | QSize DrmOutput::pixelSize() const | 786 | QSize DrmOutput::pixelSize() const | ||
785 | { | 787 | { | ||
786 | return orientateSize(QSize(m_mode.hdisplay, m_mode.vdisplay)); | 788 | return QSize(m_mode.hdisplay, m_mode.vdisplay); | ||
787 | } | 789 | } | ||
788 | 790 | | |||
789 | void DrmOutput::setWaylandMode() | 791 | void DrmOutput::setWaylandMode() | ||
790 | { | 792 | { | ||
791 | AbstractOutput::setWaylandMode(QSize(m_mode.hdisplay, m_mode.vdisplay), | 793 | AbstractOutput::setWaylandMode(QSize(m_mode.hdisplay, m_mode.vdisplay), | ||
792 | refreshRateForMode(&m_mode)); | 794 | refreshRateForMode(&m_mode)); | ||
793 | } | 795 | } | ||
794 | 796 | | |||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 858 | { | |||
871 | } | 873 | } | ||
872 | m_nextPlanesFlipList.clear(); | 874 | m_nextPlanesFlipList.clear(); | ||
873 | dpmsOffHandler(); | 875 | dpmsOffHandler(); | ||
874 | 876 | | |||
875 | return true; | 877 | return true; | ||
876 | 878 | | |||
877 | } | 879 | } | ||
878 | 880 | | |||
881 | ///Copied from QPlatformScreen | ||||
882 | static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) | ||||
883 | { | ||||
884 | if (a == Qt::PrimaryOrientation) a = Qt::LandscapeOrientation; | ||||
885 | if (b == Qt::PrimaryOrientation) b = Qt::LandscapeOrientation; | ||||
886 | | ||||
887 | if (a == b) | ||||
888 | return 0; | ||||
889 | | ||||
890 | int ia = std::log2(uint(a)); | ||||
891 | int ib = std::log2(uint(b)); | ||||
892 | | ||||
893 | int delta = ia - ib; | ||||
894 | | ||||
895 | if (delta < 0) | ||||
896 | delta = delta + 4; | ||||
897 | | ||||
898 | int angles[] = { 0, 90, 180, 270 }; | ||||
899 | return angles[delta]; | ||||
900 | } | ||||
zzag: I know that you copied this code, but could we maybe re-format it accordingly to the Frameworks… | |||||
apol: I would rather not. | |||||
901 | | ||||
879 | bool DrmOutput::presentAtomically(DrmBuffer *buffer) | 902 | bool DrmOutput::presentAtomically(DrmBuffer *buffer) | ||
880 | { | 903 | { | ||
881 | if (!LogindIntegration::self()->isActiveSession()) { | 904 | if (!LogindIntegration::self()->isActiveSession()) { | ||
882 | qCWarning(KWIN_DRM) << "Logind session not active."; | 905 | qCWarning(KWIN_DRM) << "Logind session not active."; | ||
883 | return false; | 906 | return false; | ||
884 | } | 907 | } | ||
885 | 908 | | |||
886 | if (m_pageFlipPending) { | 909 | if (m_pageFlipPending) { | ||
887 | qCWarning(KWIN_DRM) << "Page not yet flipped."; | 910 | qCWarning(KWIN_DRM) << "Page not yet flipped."; | ||
888 | return false; | 911 | return false; | ||
889 | } | 912 | } | ||
890 | 913 | | |||
891 | m_primaryPlane->setNext(buffer); | 914 | m_primaryPlane->setNext(buffer); | ||
892 | m_nextPlanesFlipList << m_primaryPlane; | 915 | m_nextPlanesFlipList << m_primaryPlane; | ||
893 | 916 | | |||
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()); | ||
902 | setGlobalPos(m_lastWorkingState.globalPos); | 925 | setGlobalPos(m_lastWorkingState.globalPos); | ||
903 | if (m_primaryPlane) { | 926 | if (m_primaryPlane) { | ||
904 | m_primaryPlane->setTransformation(m_lastWorkingState.planeTransformations); | 927 | m_primaryPlane->setTransformation(m_lastWorkingState.planeTransformations); | ||
905 | } | 928 | } | ||
906 | m_modesetRequested = true; | 929 | m_modesetRequested = true; | ||
907 | // the cursor might need to get rotated | 930 | // the cursor might need to get rotated | ||
908 | updateCursor(); | 931 | updateCursor(); | ||
909 | showCursor(); | 932 | 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.