More checks that quads are split only in pre-paint and transformed

only in paint.


svn path=/trunk/KDE/kdebase/workspace/; revision=689945
This commit is contained in:
Luboš Luňák 2007-07-19 16:11:27 +00:00
parent 023ebc47b1
commit 56eeb84acc
4 changed files with 41 additions and 14 deletions

View file

@ -316,7 +316,10 @@ EffectWindowGroup::~EffectWindowGroup()
WindowQuad WindowQuad::makeSubQuad( float x1, float y1, float x2, float y2 ) const WindowQuad WindowQuad::makeSubQuad( float x1, float y1, float x2, float y2 ) const
{ {
assert( x1 < x2 && y1 < y2 && x1 >= left() && x2 <= right() && y1 >= top() && y2 <= bottom()); assert( x1 < x2 && y1 < y2 && x1 >= left() && x2 <= right() && y1 >= top() && y2 <= bottom());
checkUntransformed(); #ifndef NDEBUG
if( isTransformed())
kFatal( 1212 ) << "Splitting quads is allowed only in pre-paint calls!" << endl;
#endif
WindowQuad ret( *this ); WindowQuad ret( *this );
// vertices are clockwise starting from topleft // vertices are clockwise starting from topleft
ret.verts[ 0 ].px = x1; ret.verts[ 0 ].px = x1;
@ -373,6 +376,10 @@ WindowQuadList WindowQuadList::splitAtX( float x ) const
WindowQuadList ret; WindowQuadList ret;
foreach( WindowQuad quad, *this ) foreach( WindowQuad quad, *this )
{ {
#ifndef NDEBUG
if( quad.isTransformed())
kFatal( 1212 ) << "Splitting quads is allowed only in pre-paint calls!" << endl;
#endif
bool wholeleft = true; bool wholeleft = true;
bool wholeright = true; bool wholeright = true;
for( int i = 0; for( int i = 0;
@ -400,6 +407,10 @@ WindowQuadList WindowQuadList::splitAtY( float y ) const
WindowQuadList ret; WindowQuadList ret;
foreach( WindowQuad quad, *this ) foreach( WindowQuad quad, *this )
{ {
#ifndef NDEBUG
if( quad.isTransformed())
kFatal( 1212 ) << "Splitting quads is allowed only in pre-paint calls!" << endl;
#endif
bool wholetop = true; bool wholetop = true;
bool wholebottom = true; bool wholebottom = true;
for( int i = 0; for( int i = 0;
@ -433,6 +444,10 @@ WindowQuadList WindowQuadList::makeGrid( int maxquadsize ) const
float bottom = first().bottom(); float bottom = first().bottom();
foreach( WindowQuad quad, *this ) foreach( WindowQuad quad, *this )
{ {
#ifndef NDEBUG
if( quad.isTransformed())
kFatal( 1212 ) << "Splitting quads is allowed only in pre-paint calls!" << endl;
#endif
left = qMin( left, quad.left()); left = qMin( left, quad.left());
right = qMax( right, quad.right()); right = qMax( right, quad.right());
top = qMin( top, quad.top()); top = qMin( top, quad.top());

View file

@ -400,7 +400,6 @@ class KWIN_EXPORT WindowQuad
WindowVertex& operator[]( int index ); WindowVertex& operator[]( int index );
const WindowVertex& operator[]( int index ) const; const WindowVertex& operator[]( int index ) const;
bool decoration() const; bool decoration() const;
// these 8 work only with untransformed quads
float left() const; float left() const;
float right() const; float right() const;
float top() const; float top() const;
@ -410,9 +409,9 @@ class KWIN_EXPORT WindowQuad
float originalTop() const; float originalTop() const;
float originalBottom() const; float originalBottom() const;
bool smoothNeeded() const; bool smoothNeeded() const;
bool isTransformed() const;
private: private:
friend class WindowQuadList; friend class WindowQuadList;
void checkUntransformed() const;
WindowVertex verts[ 4 ]; WindowVertex verts[ 4 ];
WindowQuadType type; // 0 - contents, 1 - decoration WindowQuadType type; // 0 - contents, 1 - decoration
}; };
@ -590,38 +589,36 @@ bool WindowQuad::decoration() const
} }
inline inline
void WindowQuad::checkUntransformed() const bool WindowQuad::isTransformed() const
{ {
assert( verts[ 0 ].py == verts[ 1 ].py && verts[ 2 ].py == verts[ 3 ].py return !( verts[ 0 ].px == verts[ 0 ].ox && verts[ 0 ].py == verts[ 0 ].oy
&& verts[ 0 ].px == verts[ 3 ].px && verts[ 1 ].px == verts[ 2 ].px ); && verts[ 1 ].px == verts[ 1 ].ox && verts[ 1 ].py == verts[ 1 ].oy
&& verts[ 2 ].px == verts[ 2 ].ox && verts[ 2 ].py == verts[ 2 ].oy
&& verts[ 3 ].px == verts[ 3 ].ox && verts[ 3 ].py == verts[ 3 ].oy );
} }
inline inline
float WindowQuad::left() const float WindowQuad::left() const
{ {
checkUntransformed(); return qMin( verts[ 0 ].px, qMin( verts[ 1 ].px, qMin( verts[ 2 ].px, verts[ 3 ].px )));
return verts[ 0 ].px;
} }
inline inline
float WindowQuad::right() const float WindowQuad::right() const
{ {
checkUntransformed(); return qMax( verts[ 0 ].px, qMax( verts[ 1 ].px, qMax( verts[ 2 ].px, verts[ 3 ].px )));
return verts[ 2 ].px;
} }
inline inline
float WindowQuad::top() const float WindowQuad::top() const
{ {
checkUntransformed(); return qMin( verts[ 0 ].py, qMin( verts[ 1 ].py, qMin( verts[ 2 ].py, verts[ 3 ].py )));
return verts[ 0 ].py;
} }
inline inline
float WindowQuad::bottom() const float WindowQuad::bottom() const
{ {
checkUntransformed(); return qMax( verts[ 0 ].py, qMax( verts[ 1 ].py, qMax( verts[ 2 ].py, verts[ 3 ].py )));
return verts[ 2 ].py;
} }
inline inline

View file

@ -178,6 +178,11 @@ void Scene::paintGenericScreen( int orig_mask, ScreenPaintData )
data.quads = w->buildQuads(); data.quads = w->buildQuads();
// preparation step // preparation step
effects->prePaintWindow( effectWindow( w ), data, time_diff ); effects->prePaintWindow( effectWindow( w ), data, time_diff );
#ifndef NDEBUG
foreach( WindowQuad q, data.quads )
if( q.isTransformed())
kFatal( 1212 ) << "Pre-paint calls are not allowed to transform quads!" << endl;
#endif
if( !w->isPaintingEnabled()) if( !w->isPaintingEnabled())
continue; continue;
phase2.append( Phase2Data( w, infiniteRegion(), data.mask, data.quads )); phase2.append( Phase2Data( w, infiniteRegion(), data.mask, data.quads ));
@ -214,6 +219,11 @@ void Scene::paintSimpleScreen( int orig_mask, QRegion region )
data.quads = w->buildQuads(); data.quads = w->buildQuads();
// preparation step // preparation step
effects->prePaintWindow( effectWindow( w ), data, time_diff ); effects->prePaintWindow( effectWindow( w ), data, time_diff );
#ifndef NDEBUG
foreach( WindowQuad q, data.quads )
if( q.isTransformed())
kFatal( 1212 ) << "Pre-paint calls are not allowed to transform quads!" << endl;
#endif
if( !w->isPaintingEnabled()) if( !w->isPaintingEnabled())
continue; continue;
data.paint -= allclips; // make sure to avoid already clipped areas data.paint -= allclips; // make sure to avoid already clipped areas

View file

@ -214,6 +214,11 @@ void SceneXrender::paintTransformedScreen( int orig_mask )
data.quads = w->buildQuads(); data.quads = w->buildQuads();
// preparation step // preparation step
effects->prePaintWindow( effectWindow( w ), data, time_diff ); effects->prePaintWindow( effectWindow( w ), data, time_diff );
#ifndef NDEBUG
foreach( WindowQuad q, data.quads )
if( q.isTransformed())
kFatal( 1212 ) << "Pre-paint calls are not allowed to transform quads!" << endl;
#endif
if( !w->isPaintingEnabled()) if( !w->isPaintingEnabled())
continue; continue;
data.paint -= allclips; // make sure to avoid already clipped areas data.paint -= allclips; // make sure to avoid already clipped areas