Make the default shadow look like what it's supposed to.
svn path=/trunk/KDE/kdebase/workspace/; revision=872835
This commit is contained in:
parent
5cb4d3f0ec
commit
b969ba71b7
1 changed files with 92 additions and 76 deletions
|
@ -316,15 +316,15 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
|
||||||
// Make our own shadow as the decoration doesn't support it
|
// Make our own shadow as the decoration doesn't support it
|
||||||
int fuzzy = shadowFuzzyness;
|
int fuzzy = shadowFuzzyness;
|
||||||
// Shadow's size must be a least 2*fuzzy in both directions (or the corners will be broken)
|
// Shadow's size must be a least 2*fuzzy in both directions (or the corners will be broken)
|
||||||
int width = qMax(fuzzy*2, w->width());
|
int width = qMax( fuzzy * 2, w->width() + 2 * shadowSize );
|
||||||
int height = qMax(fuzzy*2, w->height());
|
int height = qMax( fuzzy * 2, w->height() + 2 * shadowSize );
|
||||||
double x1, y1, x2, y2;
|
double x1, y1, x2, y2;
|
||||||
int id = 0;
|
int id = 0;
|
||||||
// top-left
|
// top-left
|
||||||
x1 = 0 - fuzzy;
|
x1 = shadowXOffset - shadowSize + 0 - fuzzy;
|
||||||
y1 = 0 - fuzzy;
|
y1 = shadowYOffset - shadowSize + 0 - fuzzy;
|
||||||
x2 = 0;
|
x2 = shadowXOffset - shadowSize + 0 + fuzzy;
|
||||||
y2 = 0;
|
y2 = shadowYOffset - shadowSize + 0 + fuzzy;
|
||||||
WindowQuad topLeftQuad( mShadowQuadTypes.at( 0 ), id++ );
|
WindowQuad topLeftQuad( mShadowQuadTypes.at( 0 ), id++ );
|
||||||
topLeftQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
topLeftQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
||||||
topLeftQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
topLeftQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
||||||
|
@ -332,10 +332,10 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
|
||||||
topLeftQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
topLeftQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
||||||
quadList.append( topLeftQuad );
|
quadList.append( topLeftQuad );
|
||||||
// top
|
// top
|
||||||
x1 = 0;
|
x1 = shadowXOffset - shadowSize + 0 + fuzzy;
|
||||||
y1 = 0 - fuzzy;
|
y1 = shadowYOffset - shadowSize + 0 - fuzzy;
|
||||||
x2 = width;
|
x2 = shadowXOffset - shadowSize + width - fuzzy;
|
||||||
y2 = 0;
|
y2 = shadowYOffset - shadowSize + 0 + fuzzy;
|
||||||
WindowQuad topQuad( mShadowQuadTypes.at( 0 ), id++ );
|
WindowQuad topQuad( mShadowQuadTypes.at( 0 ), id++ );
|
||||||
topQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
topQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
||||||
topQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
topQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
||||||
|
@ -343,10 +343,10 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
|
||||||
topQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
topQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
||||||
quadList.append( topQuad );
|
quadList.append( topQuad );
|
||||||
// top-right
|
// top-right
|
||||||
x1 = width;
|
x1 = shadowXOffset - shadowSize + width - fuzzy;
|
||||||
y1 = 0 - fuzzy;
|
y1 = shadowYOffset - shadowSize + 0 - fuzzy;
|
||||||
x2 = width + fuzzy;
|
x2 = shadowXOffset - shadowSize + width + fuzzy;
|
||||||
y2 = 0;
|
y2 = shadowYOffset - shadowSize + 0 + fuzzy;
|
||||||
WindowQuad topRightQuad( mShadowQuadTypes.at( 0 ), id++ );
|
WindowQuad topRightQuad( mShadowQuadTypes.at( 0 ), id++ );
|
||||||
topRightQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
topRightQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
||||||
topRightQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
topRightQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
||||||
|
@ -354,10 +354,10 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
|
||||||
topRightQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
topRightQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
||||||
quadList.append( topRightQuad );
|
quadList.append( topRightQuad );
|
||||||
// left
|
// left
|
||||||
x1 = 0 - fuzzy;
|
x1 = shadowXOffset - shadowSize + 0 - fuzzy;
|
||||||
y1 = 0;
|
y1 = shadowYOffset - shadowSize + 0 + fuzzy;
|
||||||
x2 = 0;
|
x2 = shadowXOffset - shadowSize + 0 + fuzzy;
|
||||||
y2 = height;
|
y2 = shadowYOffset - shadowSize + height - fuzzy;
|
||||||
WindowQuad leftQuad( mShadowQuadTypes.at( 0 ), id++ );
|
WindowQuad leftQuad( mShadowQuadTypes.at( 0 ), id++ );
|
||||||
leftQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
leftQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
||||||
leftQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
leftQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
||||||
|
@ -365,10 +365,10 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
|
||||||
leftQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
leftQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
||||||
quadList.append( leftQuad );
|
quadList.append( leftQuad );
|
||||||
// center
|
// center
|
||||||
x1 = 0;
|
x1 = shadowXOffset - shadowSize + 0 + fuzzy;
|
||||||
y1 = 0;
|
y1 = shadowYOffset - shadowSize + 0 + fuzzy;
|
||||||
x2 = width;
|
x2 = shadowXOffset - shadowSize + width - fuzzy;
|
||||||
y2 = height;
|
y2 = shadowYOffset - shadowSize + height - fuzzy;
|
||||||
WindowQuad contentsQuad( mShadowQuadTypes.at( 0 ), id++ );
|
WindowQuad contentsQuad( mShadowQuadTypes.at( 0 ), id++ );
|
||||||
contentsQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
contentsQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
||||||
contentsQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
contentsQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
||||||
|
@ -376,10 +376,10 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
|
||||||
contentsQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
contentsQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
||||||
quadList.append( contentsQuad );
|
quadList.append( contentsQuad );
|
||||||
// right
|
// right
|
||||||
x1 = width;
|
x1 = shadowXOffset - shadowSize + width - fuzzy;
|
||||||
y1 = 0;
|
y1 = shadowYOffset - shadowSize + 0 + fuzzy;
|
||||||
x2 = width + fuzzy;
|
x2 = shadowXOffset - shadowSize + width + fuzzy;
|
||||||
y2 = height;
|
y2 = shadowYOffset - shadowSize + height - fuzzy;
|
||||||
WindowQuad rightQuad( mShadowQuadTypes.at( 0 ), id++ );
|
WindowQuad rightQuad( mShadowQuadTypes.at( 0 ), id++ );
|
||||||
rightQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
rightQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
||||||
rightQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
rightQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
||||||
|
@ -387,10 +387,10 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
|
||||||
rightQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
rightQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
||||||
quadList.append( rightQuad );
|
quadList.append( rightQuad );
|
||||||
// bottom-left
|
// bottom-left
|
||||||
x1 = 0 - fuzzy;
|
x1 = shadowXOffset - shadowSize + 0 - fuzzy;
|
||||||
y1 = height;
|
y1 = shadowYOffset - shadowSize + height - fuzzy;
|
||||||
x2 = 0;
|
x2 = shadowXOffset - shadowSize + 0 + fuzzy;
|
||||||
y2 = height + fuzzy;
|
y2 = shadowYOffset - shadowSize + height + fuzzy;
|
||||||
WindowQuad bottomLeftQuad( mShadowQuadTypes.at( 0 ), id++ );
|
WindowQuad bottomLeftQuad( mShadowQuadTypes.at( 0 ), id++ );
|
||||||
bottomLeftQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
bottomLeftQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
||||||
bottomLeftQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
bottomLeftQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
||||||
|
@ -398,10 +398,10 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
|
||||||
bottomLeftQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
bottomLeftQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
||||||
quadList.append( bottomLeftQuad );
|
quadList.append( bottomLeftQuad );
|
||||||
// bottom
|
// bottom
|
||||||
x1 = 0;
|
x1 = shadowXOffset - shadowSize + 0 + fuzzy;
|
||||||
y1 = height;
|
y1 = shadowYOffset - shadowSize + height - fuzzy;
|
||||||
x2 = width;
|
x2 = shadowXOffset - shadowSize + width - fuzzy;
|
||||||
y2 = height + fuzzy;
|
y2 = shadowYOffset - shadowSize + height + fuzzy;
|
||||||
WindowQuad bottomQuad( mShadowQuadTypes.at( 0 ), id++ );
|
WindowQuad bottomQuad( mShadowQuadTypes.at( 0 ), id++ );
|
||||||
bottomQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
bottomQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
||||||
bottomQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
bottomQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
||||||
|
@ -409,10 +409,10 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
|
||||||
bottomQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
bottomQuad[ 3 ] = WindowVertex( x1, y2, 0, 1 );
|
||||||
quadList.append( bottomQuad );
|
quadList.append( bottomQuad );
|
||||||
// bottom-right
|
// bottom-right
|
||||||
x1 = width;
|
x1 = shadowXOffset - shadowSize + width - fuzzy;
|
||||||
y1 = height;
|
y1 = shadowYOffset - shadowSize + height - fuzzy;
|
||||||
x2 = width + fuzzy;
|
x2 = shadowXOffset - shadowSize + width + fuzzy;
|
||||||
y2 = height + fuzzy;
|
y2 = shadowYOffset - shadowSize + height + fuzzy;
|
||||||
WindowQuad bottomRightQuad( mShadowQuadTypes.at( 0 ), id++ );
|
WindowQuad bottomRightQuad( mShadowQuadTypes.at( 0 ), id++ );
|
||||||
bottomRightQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
bottomRightQuad[ 0 ] = WindowVertex( x1, y1, 0, 0 );
|
||||||
bottomRightQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
bottomRightQuad[ 1 ] = WindowVertex( x2, y1, 1, 0 );
|
||||||
|
@ -514,49 +514,65 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c
|
||||||
{
|
{
|
||||||
// Render it!
|
// Render it!
|
||||||
// Cheat a little, assume the active and inactive shadows have identical quads
|
// Cheat a little, assume the active and inactive shadows have identical quads
|
||||||
// TODO: Opacity, saturation, brightness, etc.
|
if( effects->hasDecorationShadows() )
|
||||||
if( window->hasDecoration() &&
|
{
|
||||||
effects->shadowTextureList( ShadowBorderedActive ) == texture )
|
if( window->hasDecoration() &&
|
||||||
{ // Decorated windows
|
effects->shadowTextureList( ShadowBorderedActive ) == texture )
|
||||||
// Active shadow
|
{ // Decorated windows
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->bind();
|
// Active shadow
|
||||||
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowBorderedActive, data.opacity ));
|
mShadowTextures.at( texture ).at( quad.id() )->bind();
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowBorderedActive, data.opacity ));
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->enableNormalizedTexCoords();
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
renderGLGeometry( region, 4, verts.data(), texcoords.data() );
|
mShadowTextures.at( texture ).at( quad.id() )->enableNormalizedTexCoords();
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->disableNormalizedTexCoords();
|
renderGLGeometry( region, 4, verts.data(), texcoords.data() );
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->unbind();
|
mShadowTextures.at( texture ).at( quad.id() )->disableNormalizedTexCoords();
|
||||||
|
mShadowTextures.at( texture ).at( quad.id() )->unbind();
|
||||||
|
|
||||||
// Inactive shadow
|
// Inactive shadow
|
||||||
texture = effects->shadowTextureList( ShadowBorderedInactive );
|
texture = effects->shadowTextureList( ShadowBorderedInactive );
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->bind();
|
mShadowTextures.at( texture ).at( quad.id() )->bind();
|
||||||
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowBorderedInactive, data.opacity ));
|
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowBorderedInactive, data.opacity ));
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->enableNormalizedTexCoords();
|
mShadowTextures.at( texture ).at( quad.id() )->enableNormalizedTexCoords();
|
||||||
renderGLGeometry( region, 4, verts.data(), texcoords.data() );
|
renderGLGeometry( region, 4, verts.data(), texcoords.data() );
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->disableNormalizedTexCoords();
|
mShadowTextures.at( texture ).at( quad.id() )->disableNormalizedTexCoords();
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->unbind();
|
mShadowTextures.at( texture ).at( quad.id() )->unbind();
|
||||||
}
|
}
|
||||||
else if( effects->shadowTextureList( ShadowBorderlessActive ) == texture )
|
else if( effects->shadowTextureList( ShadowBorderlessActive ) == texture )
|
||||||
{ // Decoration-less normal windows
|
{ // Decoration-less normal windows
|
||||||
if( effects->activeWindow() == window )
|
if( effects->activeWindow() == window )
|
||||||
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowBorderlessActive, data.opacity ));
|
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowBorderlessActive, data.opacity ));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
texture = effects->shadowTextureList( ShadowBorderlessInactive );
|
texture = effects->shadowTextureList( ShadowBorderlessInactive );
|
||||||
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowBorderlessInactive, data.opacity ));
|
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowBorderlessInactive, data.opacity ));
|
||||||
|
}
|
||||||
|
mShadowTextures.at( texture ).at( quad.id() )->bind();
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
mShadowTextures.at( texture ).at( quad.id() )->enableNormalizedTexCoords();
|
||||||
|
renderGLGeometry( region, 4, verts.data(), texcoords.data() );
|
||||||
|
mShadowTextures.at( texture ).at( quad.id() )->disableNormalizedTexCoords();
|
||||||
|
mShadowTextures.at( texture ).at( quad.id() )->unbind();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Other windows
|
||||||
|
mShadowTextures.at( texture ).at( quad.id() )->bind();
|
||||||
|
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowOther, data.opacity ));
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
mShadowTextures.at( texture ).at( quad.id() )->enableNormalizedTexCoords();
|
||||||
|
renderGLGeometry( region, 4, verts.data(), texcoords.data() );
|
||||||
|
mShadowTextures.at( texture ).at( quad.id() )->disableNormalizedTexCoords();
|
||||||
|
mShadowTextures.at( texture ).at( quad.id() )->unbind();
|
||||||
}
|
}
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->bind();
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->enableNormalizedTexCoords();
|
|
||||||
renderGLGeometry( region, 4, verts.data(), texcoords.data() );
|
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->disableNormalizedTexCoords();
|
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->unbind();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Other windows
|
{ // Default shadow
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->bind();
|
mShadowTextures.at( texture ).at( quad.id() )->bind();
|
||||||
glColor4f( 1.0, 1.0, 1.0, window->shadowOpacity( ShadowOther, data.opacity ));
|
float opacity = shadowOpacity;
|
||||||
|
if( intensifyActiveShadow && window == effects->activeWindow() )
|
||||||
|
opacity = 1 - ( 1 - shadowOpacity ) * ( 1 - shadowOpacity );
|
||||||
|
glColor4f( shadowColor.redF(), shadowColor.greenF(), shadowColor.blueF(),
|
||||||
|
opacity * data.opacity);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
mShadowTextures.at( texture ).at( quad.id() )->enableNormalizedTexCoords();
|
mShadowTextures.at( texture ).at( quad.id() )->enableNormalizedTexCoords();
|
||||||
renderGLGeometry( region, 4, verts.data(), texcoords.data() );
|
renderGLGeometry( region, 4, verts.data(), texcoords.data() );
|
||||||
|
|
Loading…
Reference in a new issue