From 4fc3d507908e794e57b2c41fafc62208a6b41875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Fri, 6 Jun 2008 11:07:15 +0000 Subject: [PATCH] Properly #ifdef OpenGL-only and XRender-only stuff. svn path=/trunk/KDE/kdebase/workspace/; revision=817585 --- CMakeLists.txt | 5 +++- effects/CMakeLists.txt | 31 +++++++---------------- effects/configs_builtins.cpp | 49 ++++++++++++++++++++++-------------- effects/shadow.cpp | 3 +++ effects/shadow.h | 6 +++++ effects/showfps.cpp | 11 ++++---- effects/showfps.h | 6 +++++ lib/kwinshadereffect.cpp | 2 ++ lib/kwinshadereffect.h | 4 +++ 9 files changed, 70 insertions(+), 47 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 141e44b067..14316ee405 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,9 +46,12 @@ add_subdirectory( lib ) add_subdirectory( killer ) add_subdirectory( kcmkwin ) add_subdirectory( clients ) -add_subdirectory( effects ) add_subdirectory( data ) +if( KWIN_HAVE_COMPOSITING ) +add_subdirectory( effects ) +endif( KWIN_HAVE_COMPOSITING ) + ########### next target ############### set(kwin_KDEINIT_SRCS diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 42c16795d7..9a2bc408bf 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -47,6 +47,9 @@ SET(kwin4_effect_builtins_sources minimizeanimation.cpp presentwindows.cpp scalein.cpp + shadow.cpp + showfps.cpp + showpaint.cpp taskbarthumbnail.cpp thumbnailaside.cpp zoom.cpp @@ -66,6 +69,9 @@ install( FILES minimizeanimation.desktop presentwindows.desktop scalein.desktop + shadow.desktop + showfps.desktop + showpaint.desktop taskbarthumbnail.desktop thumbnailaside.desktop zoom.desktop @@ -80,6 +86,8 @@ SET(kwin4_effect_builtins_config_sources maketransparent_config.ui presentwindows_config.cpp shadow_config.cpp + showfps_config.cpp + showfps_config.ui thumbnailaside_config.cpp thumbnailaside_config.ui zoom_config.cpp @@ -90,6 +98,7 @@ install( FILES maketransparent_config.desktop presentwindows_config.desktop shadow_config.desktop + showfps_config.desktop thumbnailaside_config.desktop zoom_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) @@ -105,7 +114,6 @@ if(KWIN_HAVE_OPENGL_COMPOSITING) lookingglass.cpp magnifier.cpp mousemark.cpp - shadow.cpp sharpen.cpp snow.cpp trackmouse.cpp @@ -120,7 +128,6 @@ if(KWIN_HAVE_OPENGL_COMPOSITING) lookingglass.desktop magnifier.desktop mousemark.desktop - shadow.desktop sharpen.desktop snow.desktop trackmouse.desktop @@ -174,32 +181,12 @@ if(KWIN_HAVE_OPENGL_COMPOSITING) magnifier_config.desktop mousemark_config.desktop sharpen_config.desktop - showfps_config.desktop snow_config.desktop trackmouse_config.desktop wobblywindows_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) endif(KWIN_HAVE_OPENGL_COMPOSITING) -# showfps, showpaint - need xrender or opengl -if(KWIN_HAVE_OPENGL_COMPOSITING OR KWIN_HAVE_XRENDER_COMPOSITING) - SET(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources} - showfps.cpp - showpaint.cpp - ) - install( FILES - showfps.desktop - showpaint.desktop - DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) - SET(kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources} - showfps_config.cpp - showfps_config.ui - ) - install( FILES - showfps_config.desktop - DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) -endif(KWIN_HAVE_OPENGL_COMPOSITING OR KWIN_HAVE_XRENDER_COMPOSITING) - # add the plugin KWIN4_ADD_EFFECT(builtins ${kwin4_effect_builtins_sources}) KWIN4_ADD_EFFECT_CONFIG(builtins ${kwin4_effect_builtins_config_sources}) diff --git a/effects/configs_builtins.cpp b/effects/configs_builtins.cpp index 3cc26ea520..a30a57a9e0 100644 --- a/effects/configs_builtins.cpp +++ b/effects/configs_builtins.cpp @@ -21,14 +21,16 @@ along with this program. If not, see . #include -#include "shadow_config.h" -#include "presentwindows_config.h" #include "desktopgrid_config.h" -#include "maketransparent_config.h" #include "diminactive_config.h" +#include "maketransparent_config.h" +#include "presentwindows_config.h" +#include "shadow_config.h" +#include "showfps_config.h" #include "thumbnailaside_config.h" #include "zoom_config.h" + #ifdef KWIN_HAVE_OPENGL_COMPOSITING #include "coverswitch_config.h" #include "flipswitch_config.h" @@ -40,9 +42,12 @@ along with this program. If not, see . #include "snow_config.h" #include "trackmouse_config.h" #include "wobblywindows_config.h" -#ifdef KWIN_HAVE_XRENDER_COMPOSITING -#include "showfps_config.h" #endif +#ifdef KWIN_HAVE_XRENDER_COMPOSITING +// xrender-only here if any +#endif +#ifdef HAVE_CAPTURY +#include "videorecord_config.h" #endif #include @@ -52,16 +57,17 @@ along with this program. If not, see . KWIN_EFFECT_CONFIG_FACTORY #endif -#define NON_GL_PLUGINS \ +#define COMMON_PLUGINS \ registerPlugin("desktopgrid"); \ registerPlugin("diminactive"); \ registerPlugin("maketransparent"); \ registerPlugin("presentwindows"); \ registerPlugin("shadow"); \ + registerPlugin ("showfps"); \ registerPlugin("thumbnailaside"); \ registerPlugin("zoom"); -#define GL_PLUGINS \ +#define OPENGL_PLUGINS \ registerPlugin("coverswitch"); \ registerPlugin("flipswitch"); \ registerPlugin("invert"); \ @@ -71,22 +77,27 @@ KWIN_EFFECT_CONFIG_FACTORY registerPlugin("sharpen"); \ registerPlugin("snow"); \ registerPlugin("trackmouse"); \ + registerPlugin ("wobblywindows"); -#define GL_RENDER_PLUGINS \ - registerPlugin ("showfps"); \ - registerPlugin ("wobblywindows"); \ +#define XRENDER_PLUGINS +#define CAPTURY_PLUGINS \ + registerPlugin ("videorecord"); +K_PLUGIN_FACTORY_DEFINITION(EffectFactory, + COMMON_PLUGINS #ifdef KWIN_HAVE_OPENGL_COMPOSITING -K_PLUGIN_FACTORY_DEFINITION(EffectFactory, - NON_GL_PLUGINS - GL_PLUGINS + OPENGL_PLUGINS +#endif #ifdef KWIN_HAVE_XRENDER_COMPOSITING - GL_RENDER_PLUGINS + XRENDER_PLUGINS +#endif +#ifdef HAVE_CAPTURY + CAPTURY_PLUGINS #endif ) -#else -K_PLUGIN_FACTORY_DEFINITION(EffectFactory, - NON_GL_PLUGINS - ) -#endif K_EXPORT_PLUGIN(EffectFactory("kwin")) + +#undef COMMON_PLUGINS +#undef OPENGL_PLUGINS +#undef XRENDER_PLUGINS +#undef CAPTURY_PLUGINS diff --git a/effects/shadow.cpp b/effects/shadow.cpp index 7277df2f57..ee48f9f924 100644 --- a/effects/shadow.cpp +++ b/effects/shadow.cpp @@ -39,6 +39,7 @@ namespace KWin KWIN_EFFECT( shadow, ShadowEffect ) +#ifdef KWIN_HAVE_XRENDER_COMPOSITING ShadowTiles::ShadowTiles(const QPixmap& shadow) { int w = shadow.width() / 2, h = shadow.height() / 2; @@ -73,6 +74,8 @@ ShadowTiles::ShadowTiles(const QPixmap& shadow) #undef DUMP_CNR #undef DUMP_TILE +#endif + ShadowEffect::ShadowEffect() { KConfigGroup conf = effects->effectConfig("Shadow"); diff --git a/effects/shadow.h b/effects/shadow.h index 4617a6b25f..3cdda93a12 100644 --- a/effects/shadow.h +++ b/effects/shadow.h @@ -29,6 +29,7 @@ namespace KWin class GLTexture; +#ifdef KWIN_HAVE_XRENDER_COMPOSITING class ShadowTiles { public: @@ -38,6 +39,7 @@ class ShadowTiles btmLeft, btm, btmRight; QSize cornerSize; }; +#endif class ShadowEffect : public QObject, public Effect @@ -69,8 +71,12 @@ class ShadowEffect int shadowSize; bool intensifyActiveShadow; QColor shadowColor; +#ifdef KWIN_HAVE_OPENGL_COMPOSITING GLTexture* mShadowTexture; +#endif +#ifdef KWIN_HAVE_XRENDER_COMPOSITING ShadowTiles *mShadowPics; +#endif struct ShadowData { diff --git a/effects/showfps.cpp b/effects/showfps.cpp index b4be83f816..b5c92be568 100644 --- a/effects/showfps.cpp +++ b/effects/showfps.cpp @@ -50,7 +50,9 @@ const int MAX_TIME = 100; ShowFpsEffect::ShowFpsEffect() : paints_pos( 0 ) , frames_pos( 0 ) +#ifdef KWIN_HAVE_OPENGL_COMPOSITING , fpsText(0) +#endif { for( int i = 0; i < NUM_PAINTS; @@ -172,9 +174,9 @@ void ShowFpsEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data #endif } +#ifdef KWIN_HAVE_OPENGL_COMPOSITING void ShowFpsEffect::paintGL( int fps ) { -#ifdef KWIN_HAVE_OPENGL_COMPOSITING int x = this->x; int y = this->y; glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT ); @@ -223,9 +225,10 @@ void ShowFpsEffect::paintGL( int fps ) // Paint paint sizes glPopAttrib(); -#endif } +#endif +#ifdef KWIN_HAVE_XRENDER_COMPOSITING /* Differences between OpenGL and XRender: - differently specified rectangles (X: width/height, O: x2,y2) @@ -233,7 +236,6 @@ void ShowFpsEffect::paintGL( int fps ) */ void ShowFpsEffect::paintXrender( int fps ) { -#ifdef KWIN_HAVE_XRENDER_COMPOSITING Pixmap pixmap = XCreatePixmap( display(), rootWindow(), FPS_WIDTH, MAX_TIME, 32 ); XRenderPicture p( pixmap, 32 ); XFreePixmap( display(), pixmap ); @@ -264,9 +266,8 @@ void ShowFpsEffect::paintXrender( int fps ) // Paint amount of rendered pixels graph paintDrawSizeGraph( x + FPS_WIDTH + MAX_TIME, y ); - -#endif } +#endif void ShowFpsEffect::paintFPSGraph(int x, int y) { diff --git a/effects/showfps.h b/effects/showfps.h index d6a3d0bed7..40da6449b7 100644 --- a/effects/showfps.h +++ b/effects/showfps.h @@ -40,8 +40,12 @@ class ShowFpsEffect virtual void postPaintScreen(); enum { INSIDE_GRAPH, NOWHERE, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }; // fps text position private: +#ifdef KWIN_HAVE_OPENGL_COMPOSITING void paintGL( int fps ); +#endif +#ifdef KWIN_HAVE_XRENDER_COMPOSITING void paintXrender( int fps ); +#endif void paintFPSGraph(int x, int y); void paintDrawSizeGraph(int x, int y); void paintGraph( int x, int y, QList values, QList lines, bool colorize); @@ -58,7 +62,9 @@ class ShowFpsEffect int x; int y; QRect fps_rect; +#ifdef KWIN_HAVE_OPENGL_COMPOSITING GLTexture *fpsText; +#endif int textPosition; QFont textFont; QColor textColor; diff --git a/lib/kwinshadereffect.cpp b/lib/kwinshadereffect.cpp index 743707488f..f6f5583f05 100644 --- a/lib/kwinshadereffect.cpp +++ b/lib/kwinshadereffect.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . #include +#ifdef KWIN_HAVE_OPENGL_COMPOSITING namespace KWin { @@ -175,3 +176,4 @@ void ShaderEffect::postPaintScreen() } // namespace +#endif diff --git a/lib/kwinshadereffect.h b/lib/kwinshadereffect.h index e35c00f3b4..10bfeca20f 100644 --- a/lib/kwinshadereffect.h +++ b/lib/kwinshadereffect.h @@ -24,6 +24,8 @@ along with this program. If not, see . #include +#ifdef KWIN_HAVE_XRENDER_COMPOSITING + /** @addtogroup kwineffects */ /** @{ */ @@ -68,3 +70,5 @@ class KWIN_EXPORT ShaderEffect : public Effect /** @} */ #endif + +#endif