From c5c318a342a51bc79118d34ea9847af786351c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 6 Jan 2011 12:27:33 +0100 Subject: [PATCH] Screenshot Effect ported to GLES --- effects/CMakeLists.txt | 2 +- effects/screenshot/screenshot.cpp | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index a6a1961e9c..6a4adad51d 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -94,6 +94,7 @@ if( KWIN_HAVE_OPENGL_COMPOSITING ) include( flipswitch/CMakeLists.txt ) include( glide/CMakeLists.txt ) include( mousemark/CMakeLists.txt ) + include( screenshot/CMakeLists.txt ) include( sheet/CMakeLists.txt ) include( snaphelper/CMakeLists.txt ) include( trackmouse/CMakeLists.txt ) @@ -105,7 +106,6 @@ if( KWIN_HAVE_OPENGL_COMPOSITING AND NOT KWIN_HAVE_OPENGLES_COMPOSITING ) include( invert/CMakeLists.txt ) include( lookingglass/CMakeLists.txt ) include( magnifier/CMakeLists.txt ) - include( screenshot/CMakeLists.txt ) include( sharpen/CMakeLists.txt ) include( snow/CMakeLists.txt ) include( startupfeedback/CMakeLists.txt ) diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp index 3d6bd4505c..03ddeab7ea 100644 --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -112,22 +112,14 @@ void ScreenShotEffect::postPaintScreen() // render window into offscreen texture int mask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT; effects->pushRenderTarget( target ); + glClearColor(0.0, 0.0, 0.0, 0.0); glClear( GL_COLOR_BUFFER_BIT ); + glClearColor(0.0, 0.0, 0.0, 1.0); effects->drawWindow( m_scheduledScreenshot, mask, QRegion( 0, 0, width, height ), d ); - // Create a scratch texture and copy the rendered window into it - GLTexture* tex = new GLTexture( width, height ); - tex->setFilter( GL_LINEAR ); - tex->setWrapMode( GL_CLAMP_TO_EDGE ); - tex->bind(); - - glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, offscreenTexture->height() - height, width, height ); - effects->popRenderTarget(); - // copy content from GL texture into image + // copy content from framebuffer into image QImage img( QSize( width, height ), QImage::Format_ARGB32 ); - tex->bind(); - glGetTexImage( GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits() ); - tex->unbind(); - delete tex; + glReadPixels(0, offscreenTexture->height() - height, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits()); + effects->popRenderTarget(); ScreenShotEffect::convertFromGLImage( img, width, height ); if( m_type & INCLUDE_CURSOR ) {