Commit 3ec352b3 authored by Enrico Ros's avatar Enrico Ros
Browse files

Getting deeper inside the paint stuff. Bypassed drawContents(..) and

reimplemented viewportPaintEvent(..). The region seems valid here, so we
can do incremental paint for every type of operation.

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=359251
parent 2e8abb59
......@@ -98,7 +98,7 @@
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_TempUseComposite</cstring>
<cstring>kcfg_TempUseComposting</cstring>
</property>
<property name="text">
<string>USE COMPOSITE</string>
......
......@@ -69,7 +69,7 @@
</entry>
</group>
<group name="Temp" >
<entry key="TempUseComposite" type="Bool" >
<entry key="TempUseComposting" type="Bool" >
<default>false</default>
</entry>
</group>
......
......@@ -270,45 +270,42 @@ void PageView::notifyPixmapChanged( int pageNumber )
//BEGIN widget events
#include <kdebug.h>
void PageView::drawContents( QPainter * p, int cx, int cy, int cw, int ch )
void PageView::viewportPaintEvent( QPaintEvent * pe )
{
QRect r = QRect( cx, cy, cw, ch );
if ( !r.isValid() )
// create the rect into contents from the clipped screen rect
QRect contentsRect = pe->rect().intersect( viewport()->rect() );
contentsRect.moveBy( contentsX(), contentsY() );
if ( !contentsRect.isValid() )
return;
//QRegion remaining( r );
//kdDebug() << "repaint: " << r << endl;
// create the screen painter. a pixel painted ar contentsX,contentsY
// appears to the top-left corner of the scrollview.
QPainter screenPainter( viewport(), true );
screenPainter.translate( -contentsX(), -contentsY() );
if ( !Settings::tempUseComposite() )
/*
const QRegion & re = pe->region();
QMemArray<QRect> transparentRects = re.rects();
for ( uint i = 0; i < transparentRects.count(); i++ )
{
// 1) clear bg
p->fillRect( r, Qt::gray );
// 2) paint items
paintItems( p, r );
// 5) paint opaque overlays
if ( !d->mouseSelectionRect.isNull() )
{
//p->save();
p->setPen( palette().active().highlight().dark(110) );
//p->setBrush( QBrush( palette().active().highlight(), Qt::Dense4Pattern ) );
p->drawRect( d->mouseSelectionRect.normalize() );
//p->restore();
}
p->setPen( Qt::red );
p->drawRect( r );
QRect r1 = transparentRects[i];
kdDebug() << r1 << endl;
}
else
*/
//QRegion remaining( r );
if ( Settings::tempUseComposting() )
{
// create pixmap and open a painter over it
QPixmap doubleBuffer( r.size() );
QPixmap doubleBuffer( contentsRect.size() );
QPainter pixmapPainter( &doubleBuffer );
pixmapPainter.translate( -r.left(), -r.top() );
pixmapPainter.translate( -contentsRect.left(), -contentsRect.top() );
// gfx operations on pixmap (rect {left,top} is pixmap {0,0})
// 1) clear bg
pixmapPainter.fillRect( r, Qt::gray );
pixmapPainter.fillRect( contentsRect, Qt::gray );
// 2) paint items
paintItems( &pixmapPainter, r );
paintItems( &pixmapPainter, contentsRect );
// 3) pixmap manipulate
// 4) paint selections
if ( !d->mouseSelectionRect.isNull() )
......@@ -321,11 +318,29 @@ void PageView::drawContents( QPainter * p, int cx, int cy, int cw, int ch )
}
// 5) paint overlays
pixmapPainter.setPen( Qt::blue );
pixmapPainter.drawRect( r );
pixmapPainter.drawRect( contentsRect );
// finish painting and draw contents
pixmapPainter.end();
p->drawPixmap( r.left(), r.top(), doubleBuffer );
screenPainter.drawPixmap( contentsRect.left(), contentsRect.top(), doubleBuffer );
}
else // not using COMPOSTING
{
// 1) clear bg
screenPainter.fillRect( contentsRect, Qt::gray );
// 2) paint items
paintItems( &screenPainter, contentsRect );
// 5) paint opaque overlays
if ( !d->mouseSelectionRect.isNull() )
{
//screenPainter.save();
screenPainter.setPen( palette().active().highlight().dark(110) );
//screenPainter.setBrush( QBrush( palette().active().highlight(), Qt::Dense4Pattern ) );
screenPainter.drawRect( d->mouseSelectionRect.normalize() );
//screenPainter.restore();
}
screenPainter.setPen( Qt::red );
screenPainter.drawRect( contentsRect );
}
}
......
......@@ -63,7 +63,7 @@ class PageView : public QScrollView, public KPDFDocumentObserver
protected:
// main draw loop, draws pageViews on viewport
void drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph );
void viewportPaintEvent( QPaintEvent * pe );
void viewportResizeEvent( QResizeEvent* );
// mouse / keyboard events
......
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