Changeset View
Changeset View
Standalone View
Standalone View
effects/screenshot/screenshot.cpp
Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Line(s) | 122 | { | |||
---|---|---|---|---|---|
153 | xcb_flush(c); | 153 | xcb_flush(c); | ||
154 | xcb_free_gc(c, gc); | 154 | xcb_free_gc(c, gc); | ||
155 | 155 | | |||
156 | return pixmap; | 156 | return pixmap; | ||
157 | } | 157 | } | ||
158 | 158 | | |||
159 | void ScreenShotEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data) | 159 | void ScreenShotEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data) | ||
160 | { | 160 | { | ||
161 | m_rotation = data.screenRotation(); | ||||
161 | m_cachedOutputGeometry = data.outputGeometry(); | 162 | m_cachedOutputGeometry = data.outputGeometry(); | ||
162 | effects->paintScreen(mask, region, data); | 163 | effects->paintScreen(mask, region, data); | ||
163 | } | 164 | } | ||
164 | 165 | | |||
165 | void ScreenShotEffect::postPaintScreen() | 166 | void ScreenShotEffect::postPaintScreen() | ||
166 | { | 167 | { | ||
167 | effects->postPaintScreen(); | 168 | effects->postPaintScreen(); | ||
168 | if (m_scheduledScreenshot) { | 169 | if (m_scheduledScreenshot) { | ||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 278 | #endif | |||
282 | if (!m_scheduledGeometry.isNull()) { | 283 | if (!m_scheduledGeometry.isNull()) { | ||
283 | if (!m_cachedOutputGeometry.isNull()) { | 284 | if (!m_cachedOutputGeometry.isNull()) { | ||
284 | // special handling for per-output geometry rendering | 285 | // special handling for per-output geometry rendering | ||
285 | const QRect intersection = m_scheduledGeometry.intersected(m_cachedOutputGeometry); | 286 | const QRect intersection = m_scheduledGeometry.intersected(m_cachedOutputGeometry); | ||
286 | if (intersection.isEmpty()) { | 287 | if (intersection.isEmpty()) { | ||
287 | // doesn't intersect, not going onto this screenshot | 288 | // doesn't intersect, not going onto this screenshot | ||
288 | return; | 289 | return; | ||
289 | } | 290 | } | ||
290 | const QImage img = blitScreenshot(intersection); | 291 | | ||
292 | auto correctedIntersection = intersection; | ||||
293 | if (m_rotation != 0 && m_rotation != 180) | ||||
294 | correctedIntersection = correctedIntersection.transposed(); | ||||
295 | QImage img = blitScreenshot(correctedIntersection); | ||||
296 | if (m_rotation) | ||||
297 | img = img.transformed(QTransform().rotate(m_rotation), Qt::SmoothTransformation); | ||||
298 | | ||||
291 | if (img.size() == m_scheduledGeometry.size()) { | 299 | if (img.size() == m_scheduledGeometry.size()) { | ||
292 | // we are done | 300 | // we are done | ||
293 | sendReplyImage(img); | 301 | sendReplyImage(img); | ||
294 | return; | 302 | return; | ||
295 | } | 303 | } | ||
296 | if (m_multipleOutputsImage.isNull()) { | 304 | if (m_multipleOutputsImage.isNull()) { | ||
297 | m_multipleOutputsImage = QImage(m_scheduledGeometry.size(), QImage::Format_ARGB32); | 305 | m_multipleOutputsImage = QImage(m_scheduledGeometry.size(), QImage::Format_ARGB32); | ||
298 | m_multipleOutputsImage.fill(Qt::transparent); | 306 | m_multipleOutputsImage.fill(Qt::transparent); | ||
▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Line(s) | |||||
608 | { | 616 | { | ||
609 | QImage img; | 617 | QImage img; | ||
610 | if (effects->isOpenGLCompositing()) | 618 | if (effects->isOpenGLCompositing()) | ||
611 | { | 619 | { | ||
612 | img = QImage(geometry.size(), QImage::Format_ARGB32); | 620 | img = QImage(geometry.size(), QImage::Format_ARGB32); | ||
613 | if (GLRenderTarget::blitSupported() && !GLPlatform::instance()->isGLES()) { | 621 | if (GLRenderTarget::blitSupported() && !GLPlatform::instance()->isGLES()) { | ||
614 | GLTexture tex(GL_RGBA8, geometry.width(), geometry.height()); | 622 | GLTexture tex(GL_RGBA8, geometry.width(), geometry.height()); | ||
615 | GLRenderTarget target(tex); | 623 | GLRenderTarget target(tex); | ||
616 | target.blitFromFramebuffer(geometry); | 624 | target.blitFromFramebuffer(geometry, {}, GL_LINEAR, m_rotation == 90 || m_rotation == 270); | ||
617 | // copy content from framebuffer into image | 625 | // copy content from framebuffer into image | ||
618 | tex.bind(); | 626 | tex.bind(); | ||
619 | glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); | 627 | glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); | ||
620 | tex.unbind(); | 628 | tex.unbind(); | ||
621 | } else { | 629 | } else { | ||
622 | glReadPixels(0, 0, img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); | 630 | glReadPixels(0, 0, img.width(), img.height(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); | ||
623 | } | 631 | } | ||
624 | ScreenShotEffect::convertFromGLImage(img, geometry.width(), geometry.height()); | 632 | ScreenShotEffect::convertFromGLImage(img, geometry.width(), geometry.height()); | ||
Show All 18 Lines | |||||
643 | 651 | | |||
644 | void ScreenShotEffect::grabPointerImage(QImage& snapshot, int offsetx, int offsety) | 652 | void ScreenShotEffect::grabPointerImage(QImage& snapshot, int offsetx, int offsety) | ||
645 | { | 653 | { | ||
646 | const auto cursor = effects->cursorImage(); | 654 | const auto cursor = effects->cursorImage(); | ||
647 | if (cursor.image().isNull()) | 655 | if (cursor.image().isNull()) | ||
648 | return; | 656 | return; | ||
649 | 657 | | |||
650 | QPainter painter(&snapshot); | 658 | QPainter painter(&snapshot); | ||
659 | painter.rotate(-m_rotation); | ||||
651 | painter.drawImage(effects->cursorPos() - cursor.hotSpot() - QPoint(offsetx, offsety), cursor.image()); | 660 | painter.drawImage(effects->cursorPos() - cursor.hotSpot() - QPoint(offsetx, offsety), cursor.image()); | ||
652 | } | 661 | } | ||
653 | 662 | | |||
654 | void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h) | 663 | void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h) | ||
655 | { | 664 | { | ||
656 | // from QtOpenGL/qgl.cpp | 665 | // from QtOpenGL/qgl.cpp | ||
657 | // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 666 | // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | ||
658 | // see http://qt.gitorious.org/qt/qt/blobs/master/src/opengl/qgl.cpp | 667 | // see http://qt.gitorious.org/qt/qt/blobs/master/src/opengl/qgl.cpp | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |