check to see if it worths to subdivide area (aka incremental painting and

mainly used on selections / editing mode ops) or to use the original
rectangle

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=359565
This commit is contained in:
Enrico Ros 2004-11-01 14:37:15 +00:00
parent b4f6b0363c
commit 154907f8e6

View file

@ -296,18 +296,33 @@ void PageView::viewportPaintEvent( QPaintEvent * pe )
QColor selBlendColor = (selectionRect.width() > 20 || selectionRect.height() > 20) ?
palette().active().highlight() : Qt::red;
// Iterate over the regions. This optimizes a lot the cases in which
// SUMj( Region[j].area ) is less than Region.boundingRect.area )
// subdivide region into rects
QMemArray<QRect> allRects = pe->region().rects();
uint numRects = allRects.count();
// TODO: add a check to see wether to use area subdivision or not.
// preprocess rects area to see if it worths or not using subdivision
uint summedArea = 0;
for ( uint i = 0; i < numRects; i++ )
{
// set 'contentsRect' to a part of the sub-divided region
contentsRect = allRects[i].normalize().intersect( viewportRect );
contentsRect.moveBy( contentsX(), contentsY() );
if ( !contentsRect.isValid() )
continue;
const QRect & r = allRects[i];
summedArea += r.width() * r.height();
}
// very elementary check: SUMj(Region[j].area) is less than boundingRect.area
bool useSubdivision = summedArea < (0.7 * contentsRect.width() * contentsRect.height());
// iterate over the rects (only one loop if not using subdivision)
if ( !useSubdivision )
numRects = 1;
for ( uint i = 0; i < numRects; i++ )
{
if ( useSubdivision )
{
// set 'contentsRect' to a part of the sub-divided region
contentsRect = allRects[i].normalize().intersect( viewportRect );
contentsRect.moveBy( contentsX(), contentsY() );
if ( !contentsRect.isValid() )
continue;
}
if ( Settings::tempUseComposting() )
{