From 6e314610395876e9e8fc7eabe7ad1f9bd17c0726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 3 Aug 2010 21:33:27 +0000 Subject: [PATCH] Adding a new rendering flag for painting the screen with transformed windows but without triggering full repaints. It is not always required to do a full repaint in each frame. E.g. in sliding popups the repaint areas are known and tracked. This change reduces the painting overhead to just the window area. Nevertheless I consider this change as experimental and will revert the commit in case it introduces rendering glitches. Other effects which are good candidates for this flag is wobbly windows, magic lamp, minimize or in general all effects which transform just one window. svn path=/trunk/KDE/kdebase/workspace/; revision=1158838 --- effects/slidingpopups/slidingpopups.cpp | 2 +- lib/kwineffects.h | 11 ++++++++++- scene.cpp | 4 +++- scene.h | 4 +++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 8a3ee8a595..57b1a52daf 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -48,7 +48,7 @@ SlidingPopupsEffect::~SlidingPopupsEffect() void SlidingPopupsEffect::prePaintScreen( ScreenPrePaintData& data, int time ) { if( !mAppearingWindows.isEmpty() || !mDisappearingWindows.isEmpty() ) - data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; + data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS; effects->prePaintScreen( data, time ); } diff --git a/lib/kwineffects.h b/lib/kwineffects.h index 2720844e73..24edcc74da 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -311,7 +311,16 @@ class KWIN_EXPORT Effect /** * Window will be painted with a lanczos filter. **/ - PAINT_WINDOW_LANCZOS = 1 << 8 + PAINT_WINDOW_LANCZOS = 1 << 8, + /** + * Same as PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS but does not trigger + * full repaints of the screen. If this flag is used the effect has + * to ensure by itself that the correct areas are repainted. If not + * handled correctly it will cause rendering glitches. + * Use with care! + * @since 4.6 + **/ + PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS = 1 << 9 }; /** diff --git a/scene.cpp b/scene.cpp index b775cef371..32c288ddfb 100644 --- a/scene.cpp +++ b/scene.cpp @@ -173,7 +173,8 @@ void Scene::idle() // the function that'll be eventually called by paintScreen() above void Scene::finalPaintScreen( int mask, QRegion region, ScreenPaintData& data ) { - if( mask & ( PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS )) + if( mask & ( PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS + | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS )) paintGenericScreen( mask, data ); else paintSimpleScreen( mask, region ); @@ -222,6 +223,7 @@ void Scene::paintSimpleScreen( int orig_mask, QRegion region ) // perhaps the two enums should be separated assert(( orig_mask & ( PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS + | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS | PAINT_WINDOW_TRANSLUCENT | PAINT_WINDOW_OPAQUE )) == 0 ); QHash< Window*, Phase2Data > phase2data; // Draw each opaque window top to bottom, subtracting the bounding rect of diff --git a/scene.h b/scene.h index 0d2754ee0e..e2b1e2f474 100644 --- a/scene.h +++ b/scene.h @@ -86,7 +86,9 @@ class Scene // Temporary solution since (_OPAQUE | _TRANSLUCENT) is not working currently. PAINT_DECORATION_ONLY = 1 << 7, // Window will be painted with a lanczos filter. - PAINT_WINDOW_LANCZOS = 1 << 8 + PAINT_WINDOW_LANCZOS = 1 << 8, + // same as PAINT_SCREEN_TRANSFORMED without full repainting + PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS = 1 << 9 }; // types of filtering available enum ImageFilterType { ImageFilterFast, ImageFilterGood };