Changeset View
Standalone View
plugins/platforms/drm/drm_output.cpp
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
91 | void DrmOutput::moveCursor(const QPoint &globalPos) | 91 | void DrmOutput::moveCursor(const QPoint &globalPos) | ||
92 | { | 92 | { | ||
93 | const QPoint p = globalPos - m_globalPos; | 93 | const QPoint p = globalPos - m_globalPos; | ||
94 | drmModeMoveCursor(m_backend->fd(), m_crtcId, p.x(), p.y()); | 94 | drmModeMoveCursor(m_backend->fd(), m_crtcId, p.x(), p.y()); | ||
95 | } | 95 | } | ||
96 | 96 | | |||
97 | QSize DrmOutput::size() const | 97 | QSize DrmOutput::size() const | ||
98 | { | 98 | { | ||
99 | return QSize(m_mode.hdisplay, m_mode.vdisplay); | 99 | return QSize(m_mode.hdisplay, m_mode.vdisplay) / m_scale; | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | QRect DrmOutput::geometry() const | 102 | QRect DrmOutput::geometry() const | ||
103 | { | 103 | { | ||
104 | return QRect(m_globalPos, size()); | 104 | return QRect(m_globalPos, size()); | ||
romangg: Instead of dividing on every call, declare new private variable `QSize m_scaledSize = pixelSize… | |||||
davidedmundson: What benefit will that have? | |||||
geometry() is called several times per frame. We can optimize here when we don't do the division every time (maybe the compiler already does the saving, I don't know). Also this way we can make sure, that the subsequent rounding is not fluctuating from one frame to another. romangg: geometry() is called several times per frame. We can optimize here when we don't do the… | |||||
It's good design to not have member variables that can ever be in a corrupt state, it reduces chance for bugs being introduced later, which is why I'm against changing it. Dividing two integers is not going to make any performance difference whatsoever and an int divided by an int will result in the same every single time. davidedmundson: It's good design to not have member variables that can ever be in a corrupt state, it reduces… | |||||
Ok, fine with me. Can you now expand the testing parameter from the other Diff, so it's possible to use it in DRM mode? I tried to set a hard coded value in DrmOutput::setScale in order to test different scale factors, but the results were garbage, so I think (hope) that this hard coding doesn't set the scale factors elsewhere correctly and the testing parameter is necessary. romangg: Ok, fine with me. Can you now expand the testing parameter from the other Diff, so it's… | |||||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | qreal DrmOutput::scale() const | ||||
108 | { | ||||
109 | return m_scale; | ||||
110 | } | ||||
111 | | ||||
112 | | ||||
107 | static KWayland::Server::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode) | 113 | static KWayland::Server::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode) | ||
108 | { | 114 | { | ||
109 | using namespace KWayland::Server; | 115 | using namespace KWayland::Server; | ||
110 | switch (mode) { | 116 | switch (mode) { | ||
111 | case DrmOutput::DpmsMode::On: | 117 | case DrmOutput::DpmsMode::On: | ||
112 | return OutputInterface::DpmsMode::On; | 118 | return OutputInterface::DpmsMode::On; | ||
113 | case DrmOutput::DpmsMode::Standby: | 119 | case DrmOutput::DpmsMode::Standby: | ||
114 | return OutputInterface::DpmsMode::Standby; | 120 | return OutputInterface::DpmsMode::Standby; | ||
▲ Show 20 Lines • Show All 495 Lines • ▼ Show 20 Line(s) | 614 | { | |||
610 | if (m_waylandOutput) { | 616 | if (m_waylandOutput) { | ||
611 | m_waylandOutput->setGlobalPosition(pos); | 617 | m_waylandOutput->setGlobalPosition(pos); | ||
612 | } | 618 | } | ||
613 | if (m_waylandOutputDevice) { | 619 | if (m_waylandOutputDevice) { | ||
614 | m_waylandOutputDevice->setGlobalPosition(pos); | 620 | m_waylandOutputDevice->setGlobalPosition(pos); | ||
615 | } | 621 | } | ||
616 | } | 622 | } | ||
617 | 623 | | |||
624 | void DrmOutput::setScale(qreal scale) | ||||
625 | { | ||||
626 | m_scale = scale; | ||||
627 | if (m_waylandOutput) { | ||||
628 | m_waylandOutput->setScale(scale); | ||||
629 | } | ||||
630 | if (m_waylandOutputDevice) { | ||||
631 | m_waylandOutputDevice->setScale(scale); | ||||
632 | } | ||||
633 | } | ||||
634 | | ||||
618 | void DrmOutput::setChanges(KWayland::Server::OutputChangeSet *changes) | 635 | void DrmOutput::setChanges(KWayland::Server::OutputChangeSet *changes) | ||
619 | { | 636 | { | ||
620 | m_changeset = changes; | 637 | m_changeset = changes; | ||
621 | qCDebug(KWIN_DRM) << "set changes in DrmOutput"; | 638 | qCDebug(KWIN_DRM) << "set changes in DrmOutput"; | ||
622 | commitChanges(); | 639 | commitChanges(); | ||
623 | } | 640 | } | ||
624 | 641 | | |||
625 | bool DrmOutput::commitChanges() | 642 | bool DrmOutput::commitChanges() | ||
Show All 25 Lines | 667 | if (m_changeset->positionChanged()) { | |||
651 | qCDebug(KWIN_DRM) << "Server setting position: " << m_changeset->position(); | 668 | qCDebug(KWIN_DRM) << "Server setting position: " << m_changeset->position(); | ||
652 | m_waylandOutput->setGlobalPosition(m_changeset->position()); | 669 | m_waylandOutput->setGlobalPosition(m_changeset->position()); | ||
653 | m_waylandOutputDevice->setGlobalPosition(m_changeset->position()); | 670 | m_waylandOutputDevice->setGlobalPosition(m_changeset->position()); | ||
654 | setGlobalPos(m_changeset->position()); | 671 | setGlobalPos(m_changeset->position()); | ||
655 | // may just work already! | 672 | // may just work already! | ||
656 | } | 673 | } | ||
657 | if (m_changeset->scaleChanged()) { | 674 | if (m_changeset->scaleChanged()) { | ||
658 | qCDebug(KWIN_DRM) << "Setting scale:" << m_changeset->scale(); | 675 | qCDebug(KWIN_DRM) << "Setting scale:" << m_changeset->scale(); | ||
659 | m_waylandOutputDevice->setScale(m_changeset->scale()); | 676 | setScale(m_changeset->scale()); | ||
660 | // FIXME: implement for wl_output | | |||
661 | } | 677 | } | ||
662 | return true; | 678 | return true; | ||
663 | } | 679 | } | ||
664 | 680 | | |||
665 | void DrmOutput::pageFlipped() | 681 | void DrmOutput::pageFlipped() | ||
666 | { | 682 | { | ||
667 | if (m_backend->atomicModeSetting()){ | 683 | if (m_backend->atomicModeSetting()){ | ||
668 | foreach (DrmPlane *p, m_planesFlipList) { | 684 | foreach (DrmPlane *p, m_planesFlipList) { | ||
Show All 33 Lines | 717 | if (m_blackBuffer) { | |||
702 | delete m_blackBuffer; | 718 | delete m_blackBuffer; | ||
703 | m_blackBuffer = nullptr; | 719 | m_blackBuffer = nullptr; | ||
704 | } | 720 | } | ||
705 | } | 721 | } | ||
706 | 722 | | |||
707 | bool DrmOutput::blank() | 723 | bool DrmOutput::blank() | ||
708 | { | 724 | { | ||
709 | if (!m_blackBuffer) { | 725 | if (!m_blackBuffer) { | ||
710 | m_blackBuffer = m_backend->createBuffer(size()); | 726 | m_blackBuffer = m_backend->createBuffer(size() * scale()); | ||
711 | if (!m_blackBuffer->map()) { | 727 | if (!m_blackBuffer->map()) { | ||
712 | cleanupBlackBuffer(); | 728 | cleanupBlackBuffer(); | ||
713 | return false; | 729 | return false; | ||
714 | } | 730 | } | ||
715 | m_blackBuffer->image()->fill(Qt::black); | 731 | m_blackBuffer->image()->fill(Qt::black); | ||
716 | } | 732 | } | ||
717 | // TODO: Do this atomically | 733 | // TODO: Do this atomically | ||
718 | return setModeLegacy(m_blackBuffer); | 734 | return setModeLegacy(m_blackBuffer); | ||
▲ Show 20 Lines • Show All 194 Lines • Show Last 20 Lines |
Instead of dividing on every call, declare new private variable QSize m_scaledSize = pixelSize() / scale(), and update its value only when m_mode or the scale value is changed.