Changeset View
Changeset View
Standalone View
Standalone View
effects/screenshot/screenshot.cpp
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 74 | { | |||
---|---|---|---|---|---|
84 | // TODO: byte order might need swapping | 84 | // TODO: byte order might need swapping | ||
85 | xcb_free_pixmap(c, xpix); | 85 | xcb_free_pixmap(c, xpix); | ||
86 | return img.copy(); | 86 | return img.copy(); | ||
87 | } | 87 | } | ||
88 | #endif | 88 | #endif | ||
89 | 89 | | |||
90 | void ScreenShotEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data) | 90 | void ScreenShotEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data) | ||
91 | { | 91 | { | ||
92 | m_rotation = data.screenRotation(); | ||||
92 | m_cachedOutputGeometry = data.outputGeometry(); | 93 | m_cachedOutputGeometry = data.outputGeometry(); | ||
93 | effects->paintScreen(mask, region, data); | 94 | effects->paintScreen(mask, region, data); | ||
94 | } | 95 | } | ||
95 | 96 | | |||
96 | void ScreenShotEffect::postPaintScreen() | 97 | void ScreenShotEffect::postPaintScreen() | ||
97 | { | 98 | { | ||
98 | effects->postPaintScreen(); | 99 | effects->postPaintScreen(); | ||
99 | if (m_scheduledScreenshot) { | 100 | if (m_scheduledScreenshot) { | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 218 | #endif | |||
222 | if (!m_scheduledGeometry.isNull()) { | 223 | if (!m_scheduledGeometry.isNull()) { | ||
223 | if (!m_cachedOutputGeometry.isNull()) { | 224 | if (!m_cachedOutputGeometry.isNull()) { | ||
224 | // special handling for per-output geometry rendering | 225 | // special handling for per-output geometry rendering | ||
225 | const QRect intersection = m_scheduledGeometry.intersected(m_cachedOutputGeometry); | 226 | const QRect intersection = m_scheduledGeometry.intersected(m_cachedOutputGeometry); | ||
226 | if (intersection.isEmpty()) { | 227 | if (intersection.isEmpty()) { | ||
227 | // doesn't intersect, not going onto this screenshot | 228 | // doesn't intersect, not going onto this screenshot | ||
228 | return; | 229 | return; | ||
229 | } | 230 | } | ||
230 | const QImage img = blitScreenshot(intersection); | 231 | | ||
232 | auto correctedIntersection = intersection; | ||||
233 | if (m_rotation != 0 && m_rotation != 180) | ||||
234 | correctedIntersection = correctedIntersection.transposed(); | ||||
235 | QImage img = blitScreenshot(correctedIntersection); | ||||
236 | if (m_rotation) | ||||
237 | img = img.transformed(QTransform().rotate(m_rotation), Qt::SmoothTransformation); | ||||
238 | | ||||
231 | if (img.size() == m_scheduledGeometry.size()) { | 239 | if (img.size() == m_scheduledGeometry.size()) { | ||
232 | // we are done | 240 | // we are done | ||
233 | sendReplyImage(img); | 241 | sendReplyImage(img); | ||
234 | return; | 242 | return; | ||
235 | } | 243 | } | ||
236 | if (m_multipleOutputsImage.isNull()) { | 244 | if (m_multipleOutputsImage.isNull()) { | ||
237 | m_multipleOutputsImage = QImage(m_scheduledGeometry.size(), QImage::Format_ARGB32); | 245 | m_multipleOutputsImage = QImage(m_scheduledGeometry.size(), QImage::Format_ARGB32); | ||
238 | m_multipleOutputsImage.fill(Qt::transparent); | 246 | m_multipleOutputsImage.fill(Qt::transparent); | ||
▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Line(s) | |||||
548 | { | 556 | { | ||
549 | QImage img; | 557 | QImage img; | ||
550 | if (effects->isOpenGLCompositing()) | 558 | if (effects->isOpenGLCompositing()) | ||
551 | { | 559 | { | ||
552 | img = QImage(geometry.size(), QImage::Format_ARGB32); | 560 | img = QImage(geometry.size(), QImage::Format_ARGB32); | ||
553 | if (GLRenderTarget::blitSupported() && !GLPlatform::instance()->isGLES()) { | 561 | if (GLRenderTarget::blitSupported() && !GLPlatform::instance()->isGLES()) { | ||
554 | GLTexture tex(GL_RGBA8, geometry.width(), geometry.height()); | 562 | GLTexture tex(GL_RGBA8, geometry.width(), geometry.height()); | ||
555 | GLRenderTarget target(tex); | 563 | GLRenderTarget target(tex); | ||
556 | target.blitFromFramebuffer(geometry); | 564 | target.blitFromFramebuffer(geometry, {}, GL_LINEAR, m_rotation == 90 || m_rotation == 270); | ||
557 | // copy content from framebuffer into image | 565 | // copy content from framebuffer into image | ||
558 | tex.bind(); | 566 | tex.bind(); | ||
559 | glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); | 567 | glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); | ||
560 | tex.unbind(); | 568 | tex.unbind(); | ||
561 | } else { | 569 | } else { | ||
562 | glReadPixels(0, 0, img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); | 570 | glReadPixels(0, 0, img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); | ||
563 | } | 571 | } | ||
564 | ScreenShotEffect::convertFromGLImage(img, geometry.width(), geometry.height()); | 572 | ScreenShotEffect::convertFromGLImage(img, geometry.width(), geometry.height()); | ||
Show All 18 Lines | |||||
583 | 591 | | |||
584 | void ScreenShotEffect::grabPointerImage(QImage& snapshot, int offsetx, int offsety) | 592 | void ScreenShotEffect::grabPointerImage(QImage& snapshot, int offsetx, int offsety) | ||
585 | { | 593 | { | ||
586 | const auto cursor = effects->cursorImage(); | 594 | const auto cursor = effects->cursorImage(); | ||
587 | if (cursor.image().isNull()) | 595 | if (cursor.image().isNull()) | ||
588 | return; | 596 | return; | ||
589 | 597 | | |||
590 | QPainter painter(&snapshot); | 598 | QPainter painter(&snapshot); | ||
599 | painter.rotate(-m_rotation); | ||||
591 | painter.drawImage(effects->cursorPos() - cursor.hotSpot() - QPoint(offsetx, offsety), cursor.image()); | 600 | painter.drawImage(effects->cursorPos() - cursor.hotSpot() - QPoint(offsetx, offsety), cursor.image()); | ||
592 | } | 601 | } | ||
593 | 602 | | |||
594 | void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h) | 603 | void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h) | ||
595 | { | 604 | { | ||
596 | // from QtOpenGL/qgl.cpp | 605 | // from QtOpenGL/qgl.cpp | ||
597 | // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 606 | // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | ||
598 | // see http://qt.gitorious.org/qt/qt/blobs/master/src/opengl/qgl.cpp | 607 | // see http://qt.gitorious.org/qt/qt/blobs/master/src/opengl/qgl.cpp | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |