From db184813805ff1384cef98541baa9f8c79aa0cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Sun, 3 Dec 2006 13:32:52 +0000 Subject: [PATCH] XRender window scaling, based on a patch by Philip Falkner. svn path=/branches/work/kwin_composite/; revision=610133 --- scene_xrender.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/scene_xrender.cpp b/scene_xrender.cpp index 3bd2c6ba65..ca0f52b880 100644 --- a/scene_xrender.cpp +++ b/scene_xrender.cpp @@ -355,6 +355,8 @@ void SceneXrender::Window::performPaint( int mask, QRegion region, WindowPaintDa // do required transformations int x = toplevel->x(); int y = toplevel->y(); + int width = toplevel->width(); + int height = toplevel->height(); if( mask & PAINT_SCREEN_TRANSFORMED ) { x += screen_paint.xTranslate; @@ -365,17 +367,38 @@ void SceneXrender::Window::performPaint( int mask, QRegion region, WindowPaintDa x += data.xTranslate; y += data.yTranslate; } - // TODO xScale,yScale + bool transform = false; + if(( mask & PAINT_WINDOW_TRANSFORMED ) && ( data.xScale != 1 || data.yScale != 1 )) + { + XTransform xform = {{ + { XDoubleToFixed( 1 / data.xScale ), XDoubleToFixed( 0 ), XDoubleToFixed( 0 ) }, + { XDoubleToFixed( 0 ), XDoubleToFixed( 1 / data.yScale ), XDoubleToFixed( 0 ) }, + { XDoubleToFixed( 0 ), XDoubleToFixed( 0 ), XDoubleToFixed( 1 ) } + }}; + XRenderSetPictureTransform( display(), pic, &xform ); + width = (int)(width * data.xScale); + height = (int)(height * data.yScale); + transform = true; + } if( opaque ) { XRenderComposite( display(), PictOpSrc, pic, None, buffer, 0, 0, 0, 0, - x, y, toplevel->width(), toplevel->height()); + x, y, width, height); } else { Picture alpha = alphaMask( data.opacity ); XRenderComposite( display(), PictOpOver, pic, alpha, buffer, 0, 0, 0, 0, - x, y, toplevel->width(), toplevel->height()); + x, y, width, height); + } + if( transform ) + { + XTransform xform = {{ + { XDoubleToFixed( 1 ), XDoubleToFixed( 0 ), XDoubleToFixed( 0 ) }, + { XDoubleToFixed( 0 ), XDoubleToFixed( 1 ), XDoubleToFixed( 0 ) }, + { XDoubleToFixed( 0 ), XDoubleToFixed( 0 ), XDoubleToFixed( 1 ) } + }}; + XRenderSetPictureTransform( display(), pic, &xform ); } XFixesSetPictureClipRegion( display(), buffer, 0, 0, None ); }