Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.cpp
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Line(s) | 116 | { | |||
---|---|---|---|---|---|
122 | if (m_hasNewCursor) { | 122 | if (m_hasNewCursor) { | ||
123 | m_cursorIndex = (m_cursorIndex + 1) % 2; | 123 | m_cursorIndex = (m_cursorIndex + 1) % 2; | ||
124 | m_hasNewCursor = false; | 124 | m_hasNewCursor = false; | ||
125 | } | 125 | } | ||
126 | 126 | | |||
127 | return ret; | 127 | return ret; | ||
128 | } | 128 | } | ||
129 | 129 | | |||
130 | qreal orientationToRotation(Qt::ScreenOrientation orientation) | ||||
131 | { | ||||
132 | switch (orientation) { | ||||
133 | case Qt::PrimaryOrientation: | ||||
134 | case Qt::LandscapeOrientation: | ||||
135 | return 0.; | ||||
136 | case Qt::InvertedPortraitOrientation: | ||||
137 | return 90.; | ||||
138 | case Qt::InvertedLandscapeOrientation: | ||||
zzag: Please fix coding style. | |||||
139 | return 180.; | ||||
140 | case Qt::PortraitOrientation: | ||||
141 | return 270.; | ||||
142 | } | ||||
143 | Q_UNREACHABLE(); | ||||
144 | return 0; | ||||
145 | } | ||||
146 | | ||||
130 | void DrmOutput::updateCursor() | 147 | void DrmOutput::updateCursor() | ||
131 | { | 148 | { | ||
132 | QImage cursorImage = m_backend->softwareCursor(); | 149 | QImage cursorImage = m_backend->softwareCursor(); | ||
133 | if (cursorImage.isNull()) { | 150 | if (cursorImage.isNull()) { | ||
134 | return; | 151 | return; | ||
135 | } | 152 | } | ||
136 | m_hasNewCursor = true; | 153 | m_hasNewCursor = true; | ||
137 | QImage *c = m_cursor[m_cursorIndex]->image(); | 154 | QImage *c = m_cursor[m_cursorIndex]->image(); | ||
138 | c->fill(Qt::transparent); | 155 | c->fill(Qt::transparent); | ||
139 | c->setDevicePixelRatio(scale()); | 156 | c->setDevicePixelRatio(scale()); | ||
140 | 157 | | |||
141 | QPainter p; | 158 | QPainter p; | ||
142 | p.begin(c); | 159 | p.begin(c); | ||
143 | if (orientation() == Qt::InvertedLandscapeOrientation) { | 160 | if (orientation() != Qt::LandscapeOrientation) { | ||
144 | QMatrix4x4 matrix; | 161 | QMatrix4x4 matrix; | ||
145 | matrix.translate(cursorImage.width() / 2.0, cursorImage.height() / 2.0); | 162 | matrix.translate(cursorImage.width() / 2.0, cursorImage.height() / 2.0); | ||
146 | matrix.rotate(180.0f, 0.0f, 0.0f, 1.0f); | 163 | matrix.rotate(orientationToRotation(orientation()), 0.0f, 0.0f, 1.0f); | ||
147 | matrix.translate(-cursorImage.width() / 2.0, -cursorImage.height() / 2.0); | 164 | matrix.translate(-cursorImage.width() / 2.0, -cursorImage.height() / 2.0); | ||
148 | p.setWorldTransform(matrix.toTransform()); | 165 | p.setWorldTransform(matrix.toTransform()); | ||
149 | } | 166 | } | ||
150 | p.drawImage(QPoint(0, 0), cursorImage); | 167 | p.drawImage(QPoint(0, 0), cursorImage); | ||
151 | p.end(); | 168 | p.end(); | ||
152 | } | 169 | } | ||
153 | 170 | | |||
154 | void DrmOutput::moveCursor(const QPoint &globalPos) | 171 | void DrmOutput::moveCursor(const QPoint &globalPos) | ||
155 | { | 172 | { | ||
156 | QMatrix4x4 matrix; | 173 | QMatrix4x4 matrix; | ||
157 | QMatrix4x4 hotspotMatrix; | 174 | QMatrix4x4 hotspotMatrix; | ||
158 | if (orientation() == Qt::InvertedLandscapeOrientation) { | 175 | if (orientation() != Qt::LandscapeOrientation) { | ||
176 | auto rotation = orientationToRotation(orientation()); | ||||
159 | matrix.translate(pixelSize().width() /2.0, pixelSize().height() / 2.0); | 177 | matrix.translate(pixelSize().width() /2.0, pixelSize().height() / 2.0); | ||
160 | matrix.rotate(180.0f, 0.0f, 0.0f, 1.0f); | 178 | matrix.rotate(rotation, 0.0f, 0.0f, 1.0f); | ||
161 | matrix.translate(-pixelSize().width() /2.0, -pixelSize().height() / 2.0); | 179 | matrix.translate(-pixelSize().width() /2.0, -pixelSize().height() / 2.0); | ||
162 | const auto cursorSize = m_backend->softwareCursor().size(); | 180 | const auto cursorSize = m_backend->softwareCursor().size(); | ||
163 | hotspotMatrix.translate(cursorSize.width()/2.0, cursorSize.height()/2.0); | 181 | hotspotMatrix.translate(cursorSize.width()/2.0, cursorSize.height()/2.0); | ||
164 | hotspotMatrix.rotate(180.0f, 0.0f, 0.0f, 1.0f); | 182 | hotspotMatrix.rotate(rotation, 0.0f, 0.0f, 1.0f); | ||
165 | hotspotMatrix.translate(-cursorSize.width()/2.0, -cursorSize.height()/2.0); | 183 | hotspotMatrix.translate(-cursorSize.width()/2.0, -cursorSize.height()/2.0); | ||
166 | } | 184 | } | ||
167 | hotspotMatrix.scale(scale()); | 185 | hotspotMatrix.scale(scale()); | ||
168 | matrix.scale(scale()); | 186 | matrix.scale(scale()); | ||
169 | const auto outputGlobalPos = AbstractOutput::globalPos(); | 187 | const auto outputGlobalPos = AbstractOutput::globalPos(); | ||
170 | matrix.translate(-outputGlobalPos.x(), -outputGlobalPos.y()); | 188 | matrix.translate(-outputGlobalPos.x(), -outputGlobalPos.y()); | ||
171 | const QPoint p = matrix.map(globalPos) - hotspotMatrix.map(m_backend->softwareCursorHotspot()); | 189 | const QPoint p = matrix.map(globalPos) - hotspotMatrix.map(m_backend->softwareCursorHotspot()); | ||
172 | drmModeMoveCursor(m_backend->fd(), m_crtc->id(), p.x(), p.y()); | 190 | drmModeMoveCursor(m_backend->fd(), m_crtc->id(), p.x(), p.y()); | ||
▲ Show 20 Lines • Show All 996 Lines • Show Last 20 Lines |
Please fix coding style.