Scaling support in ColorPicker effect
Summary: glReadPixels needs the correct location relative to the framebuffer so we need to factor in the scale as well as translation when going from compositor space. Test Plan: Ran the plasma colour picker plasmoid in windowed mode Clicked on multiple parts of a window It was right every time Reviewers: #plasma Subscribers: plasma-devel, kwin, #kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D4950
This commit is contained in:
parent
f445a99a74
commit
24c9194f4c
1 changed files with 4 additions and 1 deletions
|
@ -74,7 +74,10 @@ void ColorPickerEffect::postPaintScreen()
|
|||
if (m_scheduledPosition != QPoint(-1, -1) && (m_cachedOutputGeometry.isEmpty() || m_cachedOutputGeometry.contains(m_scheduledPosition))) {
|
||||
uint8_t data[3];
|
||||
const QRect geo = GLRenderTarget::virtualScreenGeometry();
|
||||
glReadnPixels(m_scheduledPosition.x() - geo.x(), geo.height() - geo.y() - m_scheduledPosition.y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 3, data);
|
||||
const QPoint screenPosition(m_scheduledPosition.x() - geo.x(), m_scheduledPosition.y() - geo.y());
|
||||
const QPoint texturePosition(screenPosition.x() * GLRenderTarget::virtualScreenScale(), (geo.height() - screenPosition.y()) * GLRenderTarget::virtualScreenScale());
|
||||
|
||||
glReadnPixels(texturePosition.x(), texturePosition.y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 3, data);
|
||||
QDBusConnection::sessionBus().send(m_replyMessage.createReply(QColor(data[0], data[1], data[2])));
|
||||
m_picking = false;
|
||||
m_scheduledPosition = QPoint(-1, -1);
|
||||
|
|
Loading…
Reference in a new issue