Commit 154907f8 authored by Enrico Ros's avatar Enrico Ros
Browse files

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
parent b4f6b036
......@@ -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() )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment