summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp151
1 files changed, 57 insertions, 94 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 8e8f139..4b69044 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -31,16 +31,17 @@
31 Boston, MA 02111-1307, USA. 31 Boston, MA 02111-1307, USA.
32 32
33*/ 33*/
34 34
35#include <qimage.h> 35#include <qimage.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qgfx_qws.h> 37#include <qgfx_qws.h>
38#include <qdirectpainter_qws.h> 38#include <qdirectpainter_qws.h>
39#include <qgfx_qws.h>
39#include <qsize.h> 40#include <qsize.h>
40 41
41#include <qpe/resource.h> 42#include <qpe/resource.h>
42 43
43#include "xinevideowidget.h" 44#include "xinevideowidget.h"
44 45
45static inline void memcpy_rev ( void *dst, void *src, size_t len ) 46static inline void memcpy_rev ( void *dst, void *src, size_t len )
46{ 47{
@@ -50,38 +51,30 @@ static inline void memcpy_rev ( void *dst, void *src, size_t len )
50 while ( len-- ) 51 while ( len-- )
51 *((short int *) dst )++ = *--((short int *) src ); 52 *((short int *) dst )++ = *--((short int *) src );
52} 53}
53 54
54static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) 55static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
55{ 56{
56 len >>= 1; 57 len >>= 1;
57 while ( len-- ) { 58 while ( len-- ) {
58 // *((char *) dst ) = *((char *) src + 1);
59 // *((char *) dst + 1) = *((char *) src );
60 // ((char *) dst ) += 2;
61
62 *((short int *) dst )++ = *((short int *) src ); 59 *((short int *) dst )++ = *((short int *) src );
63 ((char *) src ) += step; 60 ((char *) src ) += step;
64 } 61 }
65} 62}
66 63
67static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) 64static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step )
68{ 65{
69 len >>= 1; 66 len >>= 1;
70 67
71 ((char *) src ) += ( len * step ); 68 ((char *) src ) += ( len * step );
72 69
73 while ( len-- ) { 70 while ( len-- ) {
74 ((char *) src ) -= step; 71 ((char *) src ) -= step;
75 *((short int *) dst )++ = *((short int *) src ); 72 *((short int *) dst )++ = *((short int *) src );
76
77 // *((char *) dst ) = *((char *) src + 1);
78 // *((char *) dst + 1) = *((char *) src );
79 // ((char *) dst ) += 2;
80 } 73 }
81} 74}
82 75
83 76
84XineVideoWidget::XineVideoWidget( int width, 77XineVideoWidget::XineVideoWidget( int width,
85 int height, 78 int height,
86 QWidget* parent, 79 QWidget* parent,
87 const char* name ) 80 const char* name )
@@ -104,139 +97,109 @@ XineVideoWidget::~XineVideoWidget ( )
104void XineVideoWidget::clear ( ) 97void XineVideoWidget::clear ( )
105{ 98{
106 m_buff = 0; 99 m_buff = 0;
107 repaint ( false ); 100 repaint ( false );
108} 101}
109 102
110void XineVideoWidget::paintEvent ( QPaintEvent * ) 103void XineVideoWidget::paintEvent ( QPaintEvent * )
111{ 104{
112 qWarning( "painting <<<" ); 105 //qWarning( "painting <<<" );
113 if ( m_buff == 0 ) { 106 if ( m_buff == 0 ) {
114 QPainter p ( this ); 107 QPainter p ( this );
115 p. fillRect ( rect ( ), black ); 108 p. fillRect ( rect ( ), black );
116 p. drawImage ( 0, 0, *m_image ); 109 p. drawImage ( 0, 0, *m_image );
117 qWarning ( "logo\n" ); 110 //qWarning ( "logo\n" );
118 } 111 }
119 else { 112 else {
120 // qWarning ( "paintevent\n" ); 113 // qWarning ( "paintevent\n" );
121 114
122 QArray <QRect> qt_bug_workaround_clip_rects; 115 QArray <QRect> qt_bug_workaround_clip_rects;
123 116
124 { 117 {
125 QDirectPainter dp ( this ); 118 QDirectPainter dp ( this );
126 119
127 int rot = dp. transformOrientation ( ); 120 int rot = dp. transformOrientation ( );
128 121
129 uchar *fb = dp. frameBuffer ( ); 122 uchar *fb = dp. frameBuffer ( );
130 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; 123 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame;
131 124
132 QRect framerect = QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )); 125 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
133 126
134 qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); 127 qt_bug_workaround_clip_rects. resize ( dp. numRects ( ));
135 128
136 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { 129 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) {
137 const QRect &clip = dp. rect ( i ); 130 const QRect &clip = dp. rect ( i );
138 131
139 qt_bug_workaround_clip_rects [i] = clip; 132 qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
140 133
141 if ( rot == 0 || rot == 180 ) { 134 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb );
142 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); 135 uchar *src = frame;
143 uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ); 136
144 137 switch ( rot ) {
145 if ( rot == 180 ) 138 case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break;
146 src += (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ); 139 case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break;
147 140 case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break;
148 uint leftfill = 0; 141 case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break;
149 uint framefill = 0;
150 uint rightfill = 0;
151 uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
152
153 if ( clip. left ( ) < framerect. left ( ))
154 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
155 if ( clip. right ( ) > framerect. right ( ))
156 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
157
158 framefill = clipwidth - ( leftfill + rightfill );
159
160 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
161 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
162 memset ( dst, 0, clipwidth );
163 }
164 else {
165 if ( leftfill )
166 memset ( dst, 0, leftfill );
167
168 if ( framefill ) {
169 if ( rot == 0 )
170 memcpy ( dst + leftfill, src, framefill );
171 else
172 memcpy_rev ( dst + leftfill, src, framefill );
173 }
174 if ( rightfill )
175 memset ( dst + leftfill + framefill, 0, rightfill );
176 }
177
178 dst += m_bytes_per_line_fb;
179 src += ( rot == 0 ? m_bytes_per_line_frame : -m_bytes_per_line_frame );
180 }
181 } 142 }
182 else { // rot == 90 || rot == 270 143
183 uchar *dst = fb + ( clip. y ( ) * m_bytes_per_pixel ) + ( clip. x ( ) * m_bytes_per_line_fb ); 144 uint leftfill = 0;
184 uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ); 145 uint framefill = 0;
185 146 uint rightfill = 0;
186 if ( rot == 270 ) 147 uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
187 src += (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ); 148
188 149 if ( clip. left ( ) < framerect. left ( ))
189 uint leftfill = 0; 150 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
190 uint framefill = 0; 151 if ( clip. right ( ) > framerect. right ( ))
191 uint rightfill = 0; 152 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
192 uint clipwidth = clip. height ( ) * m_bytes_per_pixel; 153
193 154 framefill = clipwidth - ( leftfill + rightfill );
194 if ( clip. bottom ( ) > framerect. bottom ( )) 155
195 leftfill = (( clip. bottom ( ) - framerect. bottom ( )) * m_bytes_per_pixel ) <? clipwidth; 156 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
196 if ( clip. top ( ) < framerect. top ( )) 157 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
197 rightfill = (( framerect. top ( ) - framerect. top ( )) * m_bytes_per_pixel ) <? clipwidth; 158 memset ( dst, 0, clipwidth );
159 }
160 else {
161 if ( leftfill )
162 memset ( dst, 0, leftfill );
163
164 if ( framefill ) {
165 switch ( rot ) {
166 case 0: memcpy ( dst + leftfill, src, framefill ); break;
167 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
168 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break;
169 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
170 }
171 }
172 if ( rightfill )
173 memset ( dst + leftfill + framefill, 0, rightfill );
174 }
198 175
199 framefill = clipwidth - ( leftfill + rightfill ); 176 dst += m_bytes_per_line_fb;
200 177
201 for ( int y = clip. left ( ); y <= clip. right ( ); y++ ) { 178 switch ( rot ) {
202 if (( y < framerect. left ( )) || ( y > framerect. right ( ))) { 179 case 0: src += m_bytes_per_line_frame; break;
203 memset ( dst, 0, clipwidth ); 180 case 1: src -= m_bytes_per_pixel; break;
204 } 181 case 2: src -= m_bytes_per_line_frame; break;
205 else { 182 case 3: src += m_bytes_per_pixel; break;
206 if ( leftfill ) 183 }
207 memset ( dst, 0, leftfill );
208
209 if ( framefill ) {
210 if ( rot == 90 )
211 memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame );
212 else
213 memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame );
214 }
215 if ( rightfill )
216 memset ( dst + leftfill + framefill, 0, rightfill );
217 }
218
219 dst += m_bytes_per_line_fb;
220 src += ( rot == 270 ? -m_bytes_per_pixel : m_bytes_per_pixel );
221 }
222 } 184 }
223 } 185 }
224 } 186 }
187 //qWarning ( " ||| painting |||" );
225 { 188 {
226 // QVFB hack by MArtin Jones 189 // QVFB hack by MArtin Jones
227 QPainter p ( this ); 190 QPainter p ( this );
228 191
229 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { 192 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) {
230 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); 193 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) );
231 } 194 }
232 } 195 }
233 } 196 }
234 qWarning( "painting >>>" ); 197 //qWarning( "painting >>>" );
235} 198}
236 199
237int XineVideoWidget::height ( ) const 200int XineVideoWidget::height ( ) const
238{ 201{
239 return m_image-> height ( ); 202 return m_image-> height ( );
240} 203}
241 204
242int XineVideoWidget::width ( ) const 205int XineVideoWidget::width ( ) const