Verified Commit f892c951 authored by ivan tkachenko's avatar ivan tkachenko
Browse files

effects/colorpicker: Fix off-by-one error during coordinates conversion

Due to this bug color picker used to not only select one pixel higher
than it should (which is quite negligible), but also returned garbage
value for the topmost row of pixels (when you push the cursor against
the top edge of the screen).

FIXED-IN: 5.24.7, 5.25.5, 5.26
parent 2fa4a4c4
Pipeline #215382 passed with stage
in 13 minutes and 13 seconds
......@@ -57,10 +57,11 @@ void ColorPickerEffect::paintScreen(int mask, const QRegion &region, ScreenPaint
const QRect geo = effects->renderTargetRect();
if (m_scheduledPosition != QPoint(-1, -1) && geo.contains(m_scheduledPosition)) {
uint8_t data[4];
constexpr GLsizei PIXEL_SIZE = 1;
const QPoint screenPosition(m_scheduledPosition.x() - geo.x(), m_scheduledPosition.y() - geo.y());
const QPoint texturePosition(screenPosition.x() * effects->renderTargetScale(), (geo.height() - screenPosition.y()) * effects->renderTargetScale());
const QPoint texturePosition(screenPosition.x() * effects->renderTargetScale(), (geo.height() - screenPosition.y() - PIXEL_SIZE) * effects->renderTargetScale());
glReadnPixels(texturePosition.x(), texturePosition.y(), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 4, data);
glReadnPixels(texturePosition.x(), texturePosition.y(), PIXEL_SIZE, PIXEL_SIZE, GL_RGBA, GL_UNSIGNED_BYTE, 4, data);
QDBusConnection::sessionBus().send(m_replyMessage.createReply(QColor(data[0], data[1], data[2])));
m_picking = false;
m_scheduledPosition = QPoint(-1, -1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment