summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/xinevideowidget.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/xinevideowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 3e28e54..bc95d86 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -120,89 +120,92 @@ void XineVideoWidget::paintEvent ( QPaintEvent * )
120 QDirectPainter dp ( this ); 120 QDirectPainter dp ( this );
121 121
122 int rot = dp. transformOrientation ( ) + m_rotation; 122 int rot = dp. transformOrientation ( ) + m_rotation;
123 123
124 uchar *fb = dp. frameBuffer ( ); 124 uchar *fb = dp. frameBuffer ( );
125 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; 125 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame;
126 126
127 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 127 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
128 128
129 qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); 129 qt_bug_workaround_clip_rects. resize ( dp. numRects ( ));
130 130
131 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { 131 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) {
132 const QRect &clip = dp. rect ( i ); 132 const QRect &clip = dp. rect ( i );
133 133
134 qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 134 qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
135 135
136 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); 136 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb );
137 uchar *src = frame; 137 uchar *src = frame;
138 138
139 switch ( rot ) { 139 switch ( rot ) {
140 case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; 140 case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break;
141 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; 141 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;
142 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; 142 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;
143 case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; 143 case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break;
144 default: break;
144 } 145 }
145 146
146 uint leftfill = 0; 147 uint leftfill = 0;
147 uint framefill = 0; 148 uint framefill = 0;
148 uint rightfill = 0; 149 uint rightfill = 0;
149 uint clipwidth = clip. width ( ) * m_bytes_per_pixel; 150 uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
150 151
151 if ( clip. left ( ) < framerect. left ( )) 152 if ( clip. left ( ) < framerect. left ( ))
152 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; 153 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
153 if ( clip. right ( ) > framerect. right ( )) 154 if ( clip. right ( ) > framerect. right ( ))
154 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; 155 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
155 156
156 framefill = clipwidth - ( leftfill + rightfill ); 157 framefill = clipwidth - ( leftfill + rightfill );
157 158
158 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { 159 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
159 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { 160 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
160 memset ( dst, 0, clipwidth ); 161 memset ( dst, 0, clipwidth );
161 } 162 }
162 else { 163 else {
163 if ( leftfill ) 164 if ( leftfill )
164 memset ( dst, 0, leftfill ); 165 memset ( dst, 0, leftfill );
165 166
166 if ( framefill ) { 167 if ( framefill ) {
167 switch ( rot ) { 168 switch ( rot ) {
168 case 0: memcpy ( dst + leftfill, src, framefill ); break; 169 case 0: memcpy ( dst + leftfill, src, framefill ); break;
169 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; 170 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
170 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; 171 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break;
171 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; 172 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
173 default: break;
172 } 174 }
173 } 175 }
174 if ( rightfill ) 176 if ( rightfill )
175 memset ( dst + leftfill + framefill, 0, rightfill ); 177 memset ( dst + leftfill + framefill, 0, rightfill );
176 } 178 }
177 179
178 dst += m_bytes_per_line_fb; 180 dst += m_bytes_per_line_fb;
179 181
180 switch ( rot ) { 182 switch ( rot ) {
181 case 0: src += m_bytes_per_line_frame; break; 183 case 0: src += m_bytes_per_line_frame; break;
182 case 1: src -= m_bytes_per_pixel; break; 184 case 1: src -= m_bytes_per_pixel; break;
183 case 2: src -= m_bytes_per_line_frame; break; 185 case 2: src -= m_bytes_per_line_frame; break;
184 case 3: src += m_bytes_per_pixel; break; 186 case 3: src += m_bytes_per_pixel; break;
187 default: break;
185 } 188 }
186 } 189 }
187 } 190 }
188 } 191 }
189 //qWarning ( " ||| painting |||" ); 192 //qWarning ( " ||| painting |||" );
190 { 193 {
191 // QVFB hack by MArtin Jones 194 // QVFB hack by MArtin Jones
192 QPainter p ( this ); 195 QPainter p ( this );
193 196
194 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { 197 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) {
195 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); 198 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) );
196 } 199 }
197 } 200 }
198 } 201 }
199 //qWarning( "painting >>>" ); 202 //qWarning( "painting >>>" );
200} 203}
201 204
202 205
203void XineVideoWidget::setImage ( QImage* image ) 206void XineVideoWidget::setImage ( QImage* image )
204{ 207{
205 delete m_image; 208 delete m_image;
206 m_image = image; 209 m_image = image;
207} 210}
208 211
@@ -223,48 +226,48 @@ void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl )
223 226
224 m_buff = img; 227 m_buff = img;
225 m_bytes_per_line_frame = bpl; 228 m_bytes_per_line_frame = bpl;
226 229
227 repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); 230 repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false );
228} 231}
229 232
230void XineVideoWidget::resizeEvent ( QResizeEvent * ) 233void XineVideoWidget::resizeEvent ( QResizeEvent * )
231{ 234{
232 QSize s = size ( ); 235 QSize s = size ( );
233 bool fs = ( s == qApp-> desktop ( )-> size ( )); 236 bool fs = ( s == qApp-> desktop ( )-> size ( ));
234 237
235 m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; 238 m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0;
236 239
237 if ( fs && qt_screen-> isTransformed ( )) { 240 if ( fs && qt_screen-> isTransformed ( )) {
238 s = qt_screen-> mapToDevice ( s ); 241 s = qt_screen-> mapToDevice ( s );
239 } 242 }
240 243
241// qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); 244// qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation );
242 245
243 emit videoResized ( s ); 246 emit videoResized ( s );
244} 247}
245 248
246 249
247void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) 250void XineVideoWidget::mousePressEvent ( QMouseEvent * /*me*/ )
248{ 251{
249 QWidget *p = parentWidget ( ); 252 QWidget *p = parentWidget ( );
250 253
251 if ( p ) { 254 if ( p ) {
252 // QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); 255 // QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( ));
253 256
254 // QApplication::sendEvent ( p, &pme ); 257 // QApplication::sendEvent ( p, &pme );
255 // emit clicked(); 258 // emit clicked();
256 } 259 }
257} 260}
258 261
259void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) 262void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ )
260{ 263{
261 QWidget *p = parentWidget ( ); 264 QWidget *p = parentWidget ( );
262 265
263 if ( p ) { 266 if ( p ) {
264 // QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); 267 // QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( ));
265 268
266 // QApplication::sendEvent ( p, &pme ); 269 // QApplication::sendEvent ( p, &pme );
267 emit clicked(); 270 emit clicked();
268 } 271 }
269} 272}
270 273