A simple solution for alpha channel hacks - ignore them :).

The 'ignore ARGB visuals' option from Kompmgr probably doesn't make
much sense, those (usually old) apps can be run with XLIB_SKIP_ARGB_VISUALS=1 set.
Also remove the alpha clear hack used for decorations - I think decorations
instead should be fixed not to "unintentionally" have alpha set.


svn path=/trunk/KDE/kdebase/workspace/; revision=689916
This commit is contained in:
Luboš Luňák 2007-07-19 14:23:11 +00:00
parent 7273d0ddb5
commit ac42ba0b4f
3 changed files with 5 additions and 91 deletions

View file

@ -98,8 +98,6 @@ KDE 4.0 TODO
would be nice if isn't too strict would be nice if isn't too strict
/ vertex redesign [Seli] / vertex redesign [Seli]
affects alpha clear hack
- not using ARGB visuals
- handling of window pixmaps for unmapped windows [Seli] - handling of window pixmaps for unmapped windows [Seli]
- strict binding - strict binding
@ -122,13 +120,11 @@ General TODO
================================= =================================
? alpha clear hack ? alpha clear hack
+ - find out if it affects performance - some decorations have parts transparent, probably because they don't expect
+ - if yes, try to find a better way of solving the problem to have an alpha channel
! - since kompmgr has an option to make only the decoration transparent, - should be probably simply fixed in the decorations
it should be possible to do the same here - if the window has alpha and a decoration - if not feasible, code that makes non-alpha windows opaque (SceneOpenGL::Window::prepareRenderStates())
or if there should be only the decoration transparent, paint first the contents could be used to also ignore alpha channel of the decoration
and then the decoration - this should make it possible to paint the decoration
without the random alpha that is right now handled by the alpha hack
? wait for decoration repaints ? wait for decoration repaints
- it is sometimes visible that the window contents are painted first and the decoration - it is sometimes visible that the window contents are painted first and the decoration
@ -301,11 +297,6 @@ Effects TODO
probably simply write to kwinrc and use the Option class in KWin probably simply write to kwinrc and use the Option class in KWin
/ implements all effects Kompmgr could do / implements all effects Kompmgr could do
+ - all effects from the Opacity tab should be already doable
! - not usign ARGB visuals
- just clear the alpha channel in the alpha clear hack
- or do it while painting (see also the alpha clear hack todo entry)
! - the rest - should be simple
/ - shadows / - shadows
+ - tab Effects + - tab Effects
+ - fade between changes + - fade between changes

View file

@ -1047,57 +1047,12 @@ bool SceneOpenGL::Window::bindTexture()
Pixmap pix = toplevel->windowPixmap(); Pixmap pix = toplevel->windowPixmap();
if( pix == None ) if( pix == None )
return false; return false;
// HACK
// When a window uses ARGB visual and has a decoration, the decoration
// does use ARGB visual. When converting such window to a texture
// the alpha for the decoration part is broken for some reason (undefined?).
// I wasn't lucky converting KWin to use ARGB visuals for decorations,
// so instead simply set alpha in those parts to opaque.
// Without alpha_clear_copy the setting is done directly in the window
// pixmap, which seems to be ok, but let's not risk trouble right now.
// TODO check if this isn't a performance problem and how it can be done better
Client* c = dynamic_cast< Client* >( toplevel );
bool alpha_clear = c != NULL && c->hasAlpha() && !c->noBorder();
bool alpha_clear_copy = true;
bool copy_buffer = ( alpha_clear && alpha_clear_copy );
if( copy_buffer )
{
Pixmap p2 = XCreatePixmap( display(), pix, toplevel->width(), toplevel->height(), toplevel->depth());
GC gc = XCreateGC( display(), pix, 0, NULL );
XCopyArea( display(), pix, p2, gc, 0, 0, toplevel->width(), toplevel->height(), 0, 0 );
pix = p2;
XFreeGC( display(), gc );
}
if( alpha_clear )
{
XGCValues gcv;
gcv.foreground = 0xff000000;
gcv.plane_mask = 0xff000000;
GC gc = XCreateGC( display(), pix, GCPlaneMask | GCForeground, &gcv );
XFillRectangle( display(), pix, gc, 0, 0, c->width(), c->clientPos().y());
XFillRectangle( display(), pix, gc, 0, 0, c->clientPos().x(), c->height());
int tw = c->clientPos().x() + c->clientSize().width();
int th = c->clientPos().y() + c->clientSize().height();
XFillRectangle( display(), pix, gc, 0, th, c->width(), c->height() - th );
XFillRectangle( display(), pix, gc, tw, 0, c->width() - tw, c->height());
XFreeGC( display(), gc );
}
if( copy_buffer || alpha_clear )
{
glXWaitX();
texture.discard(); // it will be bound to the new temporary pixmap
}
bool success = texture.load( pix, toplevel->size(), toplevel->depth(), bool success = texture.load( pix, toplevel->size(), toplevel->depth(),
toplevel->damage()); toplevel->damage());
if( success ) if( success )
toplevel->resetDamage( toplevel->rect()); toplevel->resetDamage( toplevel->rect());
else else
kDebug( 1212 ) << "Failed to bind window" << endl; kDebug( 1212 ) << "Failed to bind window" << endl;
// if using copy_buffer, the pixmap is no longer needed (either referenced
// by GLXPixmap in the tfp case or not needed at all in non-tfp cases)
if( copy_buffer )
XFreePixmap( display(), pix );
return success; return success;
} }

View file

@ -367,39 +367,7 @@ Picture SceneXrender::Window::picture()
Pixmap pix = toplevel->windowPixmap(); Pixmap pix = toplevel->windowPixmap();
if( pix == None ) if( pix == None )
return None; return None;
// HACK the same alpha clear hack like with opengl, see there
Client* c = dynamic_cast< Client* >( toplevel );
bool alpha_clear = c != NULL && c->hasAlpha() && !c->noBorder();
#define ALPHA_CLEAR_COPY
#ifdef ALPHA_CLEAR_COPY
if( alpha_clear )
{
Pixmap p2 = XCreatePixmap( display(), pix, c->width(), c->height(), 32 );
GC gc = XCreateGC( display(), pix, 0, NULL );
XCopyArea( display(), pix, p2, gc, 0, 0, c->width(), c->height(), 0, 0 );
pix = p2;
XFreeGC( display(), gc );
}
#endif
if( alpha_clear )
{
XGCValues gcv;
gcv.foreground = 0xff000000;
gcv.plane_mask = 0xff000000;
GC gc = XCreateGC( display(), pix, GCPlaneMask | GCForeground, &gcv );
XFillRectangle( display(), pix, gc, 0, 0, c->width(), c->clientPos().y());
XFillRectangle( display(), pix, gc, 0, 0, c->clientPos().x(), c->height());
int tw = c->clientPos().x() + c->clientSize().width();
int th = c->clientPos().y() + c->clientSize().height();
XFillRectangle( display(), pix, gc, 0, th, c->width(), c->height() - th );
XFillRectangle( display(), pix, gc, tw, 0, c->width() - tw, c->height());
XFreeGC( display(), gc );
}
_picture = XRenderCreatePicture( display(), pix, format, 0, 0 ); _picture = XRenderCreatePicture( display(), pix, format, 0, 0 );
#ifdef ALPHA_CLEAR_COPY
if( alpha_clear )
XFreePixmap( display(), pix );
#endif
toplevel->resetDamage( toplevel->rect()); toplevel->resetDamage( toplevel->rect());
} }
return _picture; return _picture;