Very basic compositing with xrender.
svn path=/branches/work/kwin_composite/; revision=558481
This commit is contained in:
parent
7d67cf42c4
commit
29111875e1
5 changed files with 88 additions and 3 deletions
|
@ -16,7 +16,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR}
|
|||
########### next target ###############
|
||||
|
||||
set(kwin_KDEINIT_SRCS
|
||||
kwinadaptor.cpp
|
||||
kwinadaptor.cpp
|
||||
workspace.cpp
|
||||
client.cpp
|
||||
placement.cpp
|
||||
|
@ -60,6 +60,9 @@ endif (X11_Xcomposite_FOUND)
|
|||
if (X11_Xdamage_FOUND)
|
||||
target_link_libraries(kdeinit_kwin ${X11_Xdamage_LIB})
|
||||
endif (X11_Xdamage_FOUND)
|
||||
if (X11_Xrender_FOUND)
|
||||
target_link_libraries(kdeinit_kwin ${X11_Xrender_LIB})
|
||||
endif (X11_Xrender_FOUND)
|
||||
|
||||
install(TARGETS kdeinit_kwin DESTINATION ${LIB_INSTALL_DIR} )
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#include "unmanaged.h"
|
||||
#include "scene.h"
|
||||
#include "scene_basic.h"
|
||||
#include "scene_xrender.h"
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
@ -33,7 +34,8 @@ void Workspace::setupCompositing()
|
|||
compositeTimer.start( 20 );
|
||||
XCompositeRedirectSubwindows( display(), rootWindow(), CompositeRedirectManual );
|
||||
setDamaged();
|
||||
scene = new SceneBasic( this );
|
||||
// scene = new SceneBasic( this );
|
||||
scene = new SceneXrender( this );
|
||||
}
|
||||
|
||||
void Workspace::finishCompositing()
|
||||
|
|
|
@ -25,7 +25,6 @@ class SceneBasic
|
|||
virtual void paint();
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,10 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include "scene_xrender.h"
|
||||
|
||||
#ifdef HAVE_XRENDER
|
||||
|
||||
#include "toplevel.h"
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
||||
|
@ -17,4 +21,58 @@ namespace KWinInternal
|
|||
// SceneXrender
|
||||
//****************************************
|
||||
|
||||
SceneXrender::SceneXrender( Workspace* ws )
|
||||
: Scene( ws )
|
||||
{
|
||||
format = XRenderFindVisualFormat( display(), DefaultVisual( display(), DefaultScreen( display())));
|
||||
XRenderPictureAttributes pa;
|
||||
pa.subwindow_mode = IncludeInferiors;
|
||||
front = XRenderCreatePicture( display(), rootWindow(), format, CPSubwindowMode, &pa );
|
||||
createBuffer();
|
||||
}
|
||||
|
||||
SceneXrender::~SceneXrender()
|
||||
{
|
||||
XRenderFreePicture( display(), front );
|
||||
XRenderFreePicture( display(), buffer );
|
||||
}
|
||||
|
||||
// TODO handle xrandr changes
|
||||
|
||||
void SceneXrender::createBuffer()
|
||||
{
|
||||
if( buffer != None )
|
||||
XRenderFreePicture( display(), buffer );
|
||||
Pixmap pixmap = XCreatePixmap( display(), rootWindow(), displayWidth(), displayHeight(), QX11Info::appDepth());
|
||||
buffer = XRenderCreatePicture( display(), pixmap, format, 0, 0 );
|
||||
XFreePixmap( display(), pixmap ); // The picture owns the pixmap now
|
||||
}
|
||||
|
||||
void SceneXrender::paint()
|
||||
{
|
||||
XRenderColor col = { 0xffff, 0xffff, 0xffff, 0xffff };
|
||||
XRenderFillRectangle( display(), PictOpSrc, buffer, &col, 0, 0, displayWidth(), displayHeight());
|
||||
for( ToplevelList::ConstIterator it = windows.begin();
|
||||
it != windows.end();
|
||||
++it )
|
||||
{
|
||||
QRect r = (*it)->geometry().intersect( QRect( 0, 0, displayWidth(), displayHeight()));
|
||||
if( !r.isEmpty())
|
||||
{
|
||||
XWindowAttributes attrs;
|
||||
if( !XGetWindowAttributes( display(), (*it)->handle(), &attrs ))
|
||||
continue;
|
||||
if( XRenderPictFormat* clientFormat = XRenderFindVisualFormat( display(), attrs.visual ))
|
||||
{
|
||||
Picture picture = XRenderCreatePicture( display(), (*it)->windowPixmap(), clientFormat, 0, 0 );
|
||||
XRenderComposite( display(), PictOpSrc, picture, None, buffer, 0, 0, 0, 0,
|
||||
(*it)->x(), (*it)->y(), (*it)->width(), (*it)->height());
|
||||
}
|
||||
}
|
||||
}
|
||||
XRenderComposite( display(), PictOpSrc, buffer, None, front, 0, 0, 0, 0, 0, 0, displayWidth(), displayHeight());
|
||||
XFlush( display());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
#endif
|
||||
|
|
|
@ -11,9 +11,32 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#ifndef KWIN_SCENE_XRENDER_H
|
||||
#define KWIN_SCENE_XRENDER_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_XRENDER
|
||||
#include <X11/extensions/Xrender.h>
|
||||
|
||||
#include "scene.h"
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
||||
class SceneXrender
|
||||
: public Scene
|
||||
{
|
||||
public:
|
||||
SceneXrender( Workspace* ws );
|
||||
virtual ~SceneXrender();
|
||||
virtual void paint();
|
||||
private:
|
||||
void createBuffer();
|
||||
XRenderPictFormat* format;
|
||||
Picture front;
|
||||
Picture buffer;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue