Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.cpp
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 71 | { | |||
---|---|---|---|---|---|
79 | } | 79 | } | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | void DrmOutput::hideCursor() | 82 | void DrmOutput::hideCursor() | ||
83 | { | 83 | { | ||
84 | drmModeSetCursor(m_backend->fd(), m_crtc->id(), 0, 0, 0); | 84 | drmModeSetCursor(m_backend->fd(), m_crtc->id(), 0, 0, 0); | ||
85 | } | 85 | } | ||
86 | 86 | | |||
87 | void DrmOutput::showCursor(DrmBuffer *c) | 87 | void DrmOutput::showCursor(DrmDumbBuffer *c) | ||
88 | { | 88 | { | ||
89 | const QSize &s = c->size(); | 89 | const QSize &s = c->size(); | ||
90 | drmModeSetCursor(m_backend->fd(), m_crtc->id(), c->handle(), s.width(), s.height()); | 90 | drmModeSetCursor(m_backend->fd(), m_crtc->id(), c->handle(), s.width(), s.height()); | ||
91 | } | 91 | } | ||
92 | 92 | | |||
93 | void DrmOutput::moveCursor(const QPoint &globalPos) | 93 | void DrmOutput::moveCursor(const QPoint &globalPos) | ||
94 | { | 94 | { | ||
95 | const QPoint p = (globalPos - m_globalPos) * m_scale; | 95 | const QPoint p = (globalPos - m_globalPos) * m_scale; | ||
▲ Show 20 Lines • Show All 605 Lines • ▼ Show 20 Line(s) | 696 | if (!m_crtc->next()) { | |||
701 | return; | 701 | return; | ||
702 | } | 702 | } | ||
703 | m_crtc->flipBuffer(); | 703 | m_crtc->flipBuffer(); | ||
704 | } | 704 | } | ||
705 | } | 705 | } | ||
706 | 706 | | |||
707 | void DrmOutput::pageFlippedBufferRemover(DrmBuffer *oldbuffer, DrmBuffer *newbuffer) | 707 | void DrmOutput::pageFlippedBufferRemover(DrmBuffer *oldbuffer, DrmBuffer *newbuffer) | ||
708 | { | 708 | { | ||
709 | if (oldbuffer && oldbuffer->deleteAfterPageFlip() && oldbuffer != newbuffer) { | 709 | if (oldbuffer && m_backend->deleteBufferAfterPageFlip() && oldbuffer != newbuffer) { | ||
710 | delete oldbuffer; | 710 | delete oldbuffer; | ||
711 | } | 711 | } | ||
712 | } | 712 | } | ||
713 | 713 | | |||
714 | bool DrmOutput::present(DrmBuffer *buffer) | 714 | bool DrmOutput::present(DrmBuffer *buffer) | ||
715 | { | 715 | { | ||
716 | if (!buffer || buffer->bufferId() == 0) { | 716 | if (!buffer || buffer->bufferId() == 0) { | ||
717 | return false; | 717 | return false; | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 835 | if (!LogindIntegration::self()->isActiveSession()) { | |||
836 | m_crtc->setNext(buffer); | 836 | m_crtc->setNext(buffer); | ||
837 | return false; | 837 | return false; | ||
838 | } | 838 | } | ||
839 | if (m_dpmsMode != DpmsMode::On) { | 839 | if (m_dpmsMode != DpmsMode::On) { | ||
840 | return false; | 840 | return false; | ||
841 | } | 841 | } | ||
842 | 842 | | |||
843 | // Do we need to set a new mode first? | 843 | // Do we need to set a new mode first? | ||
844 | if (m_lastStride != buffer->stride() || m_lastGbm != buffer->isGbm()){ | 844 | if (!m_crtc->current() || m_crtc->current()->needsModeChange(buffer)) { | ||
845 | if (!setModeLegacy(buffer)) | 845 | if (!setModeLegacy(buffer)) { | ||
846 | return false; | 846 | return false; | ||
847 | } | 847 | } | ||
848 | } | ||||
848 | int errno_save = 0; | 849 | int errno_save = 0; | ||
849 | const bool ok = drmModePageFlip(m_backend->fd(), m_crtc->id(), buffer->bufferId(), DRM_MODE_PAGE_FLIP_EVENT, this) == 0; | 850 | const bool ok = drmModePageFlip(m_backend->fd(), m_crtc->id(), buffer->bufferId(), DRM_MODE_PAGE_FLIP_EVENT, this) == 0; | ||
850 | if (ok) { | 851 | if (ok) { | ||
851 | m_crtc->setNext(buffer); | 852 | m_crtc->setNext(buffer); | ||
852 | } else { | 853 | } else { | ||
853 | errno_save = errno; | 854 | errno_save = errno; | ||
854 | qCWarning(KWIN_DRM) << "Page flip failed:" << strerror(errno); | 855 | qCWarning(KWIN_DRM) << "Page flip failed:" << strerror(errno); | ||
855 | delete buffer; | 856 | delete buffer; | ||
856 | } | 857 | } | ||
857 | return ok; | 858 | return ok; | ||
858 | } | 859 | } | ||
859 | 860 | | |||
860 | bool DrmOutput::setModeLegacy(DrmBuffer *buffer) | 861 | bool DrmOutput::setModeLegacy(DrmBuffer *buffer) | ||
861 | { | 862 | { | ||
862 | uint32_t connId = m_conn->id(); | 863 | uint32_t connId = m_conn->id(); | ||
863 | if (drmModeSetCrtc(m_backend->fd(), m_crtc->id(), buffer->bufferId(), 0, 0, &connId, 1, &m_mode) == 0) { | 864 | if (drmModeSetCrtc(m_backend->fd(), m_crtc->id(), buffer->bufferId(), 0, 0, &connId, 1, &m_mode) == 0) { | ||
864 | m_lastStride = buffer->stride(); | | |||
865 | m_lastGbm = buffer->isGbm(); | | |||
866 | return true; | 865 | return true; | ||
867 | } else { | 866 | } else { | ||
868 | qCWarning(KWIN_DRM) << "Mode setting failed"; | 867 | qCWarning(KWIN_DRM) << "Mode setting failed"; | ||
869 | return false; | 868 | return false; | ||
870 | } | 869 | } | ||
871 | } | 870 | } | ||
872 | 871 | | |||
873 | DrmObject::AtomicReturn DrmOutput::atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable) | 872 | DrmObject::AtomicReturn DrmOutput::atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable) | ||
Show All 33 Lines |