Contents of /trunk/qt/patches/qt-3.3.4-flickerfree_qiconview_buffered.patch
Parent Directory | Revision Log
Revision 153 -
(show annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 3347 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 3347 byte(s)
-import
1 | Buffered QIconView. |
2 | |
3 | For every QIconView this patch creates a backbuffer where the image will |
4 | grow up (aka will be painted) before blitting the results to the screen. |
5 | This solves the konqueror flickering problems at its roots. There are |
6 | some more bugs that make conqueror repaint without reason.. patches |
7 | will follow. |
8 | Enrico Ros <eros.kde@email.it> |
9 | |
10 | --- src.orig/iconview/qiconview.cpp 2004-03-24 15:58:05.000000000 +0000 |
11 | +++ src/iconview/qiconview.cpp 2004-03-30 16:23:32.521253280 +0000 |
12 | @@ -211,6 +211,7 @@ |
13 | QIconViewItem *currentItem, *tmpCurrentItem, *highlightedItem, |
14 | *startDragItem, *pressedItem, *selectAnchor, *renamingItem; |
15 | QRect *rubber; |
16 | + QPixmap *backBuffer; |
17 | QTimer *scrollTimer, *adjustTimer, *updateTimer, *inputTimer, |
18 | *fullRedrawTimer; |
19 | int rastX, rastY, spacing; |
20 | @@ -2731,6 +2732,7 @@ |
21 | d->currentItem = 0; |
22 | d->highlightedItem = 0; |
23 | d->rubber = 0; |
24 | + d->backBuffer = 0; |
25 | d->scrollTimer = 0; |
26 | d->startDragItem = 0; |
27 | d->tmpCurrentItem = 0; |
28 | @@ -2883,6 +2885,8 @@ |
29 | delete item; |
30 | item = tmp; |
31 | } |
32 | + delete d->backBuffer; |
33 | + d->backBuffer = 0; |
34 | delete d->fm; |
35 | d->fm = 0; |
36 | #ifndef QT_NO_TOOLTIP |
37 | @@ -4845,6 +4849,47 @@ |
38 | #endif |
39 | |
40 | /*! |
41 | + This function grabs all paintevents that otherwise would have been |
42 | + processed by the QScrollView::viewportPaintEvent(). Here we use a |
43 | + doublebuffer to reduce 'on-paint' flickering on QIconView |
44 | + (and of course its childs). |
45 | + |
46 | + \sa QScrollView::viewportPaintEvent(), QIconView::drawContents() |
47 | +*/ |
48 | + |
49 | +void QIconView::bufferedPaintEvent( QPaintEvent* pe ) |
50 | +{ |
51 | + QWidget* vp = viewport(); |
52 | + QRect r = pe->rect() & vp->rect(); |
53 | + int ex = r.x() + contentsX(); |
54 | + int ey = r.y() + contentsY(); |
55 | + int ew = r.width(); |
56 | + int eh = r.height(); |
57 | + |
58 | + if ( !d->backBuffer ) |
59 | + d->backBuffer = new QPixmap(vp->size()); |
60 | + if ( d->backBuffer->size() != vp->size() ) { |
61 | + //Resize function (with hysteesis). Uses a good compromise between memory |
62 | + //consumption and speed (number) of resizes. |
63 | + float newWidth = (float)vp->width(); |
64 | + float newHeight = (float)vp->height(); |
65 | + if ( newWidth > d->backBuffer->width() || newHeight > d->backBuffer->height() ) |
66 | + { |
67 | + newWidth *= 1.1892; |
68 | + newHeight *= 1.1892; |
69 | + d->backBuffer->resize( (int)newWidth, (int)newHeight ); |
70 | + } else if ( 1.5*newWidth < d->backBuffer->width() || 1.5*newHeight < d->backBuffer->height() ) |
71 | + d->backBuffer->resize( (int)newWidth, (int)newHeight ); |
72 | + } |
73 | + |
74 | + QPainter p; |
75 | + p.begin(d->backBuffer, vp); |
76 | + drawContentsOffset(&p, contentsX(), contentsY(), ex, ey, ew, eh); |
77 | + p.end(); |
78 | + bitBlt(vp, r.x(), r.y(), d->backBuffer, r.x(), r.y(), ew, eh); |
79 | +} |
80 | + |
81 | +/*! |
82 | \reimp |
83 | */ |
84 | |
85 | @@ -5627,7 +5676,7 @@ |
86 | if ( !d->rubber ) |
87 | drawDragShapes( d->oldDragPos ); |
88 | } |
89 | - viewportPaintEvent( (QPaintEvent*)e ); |
90 | + bufferedPaintEvent( (QPaintEvent*)e ); |
91 | if ( d->dragging ) { |
92 | if ( !d->rubber ) |
93 | drawDragShapes( d->oldDragPos ); |
94 | --- src.orig/iconview/qiconview.h 2004-03-30 16:00:47.605751976 +0000 |
95 | +++ src/iconview/qiconview.h 2003-05-16 13:02:38.000000000 +0000 |
96 | @@ -445,6 +445,7 @@ |
97 | void contentsDropEvent( QDropEvent *e ); |
98 | #endif |
99 | |
100 | + void bufferedPaintEvent( QPaintEvent* ); |
101 | void resizeEvent( QResizeEvent* e ); |
102 | void keyPressEvent( QKeyEvent *e ); |
103 | void focusInEvent( QFocusEvent *e ); |