-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 1ac9277..9e86041 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -164,141 +164,143 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
164 | 164 | ||
165 | { | 165 | { |
166 | QDirectPainter dp ( this ); | 166 | QDirectPainter dp ( this ); |
167 | 167 | ||
168 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation | 168 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation |
169 | 169 | ||
170 | uchar *fb = dp. frameBuffer ( ); | 170 | uchar *fb = dp. frameBuffer ( ); |
171 | uchar *frame = m_buff; | 171 | uchar *frame = m_buff; |
172 | 172 | ||
173 | // where is the video frame in fb coordinates | 173 | // where is the video frame in fb coordinates |
174 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 174 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
175 | 175 | ||
176 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 176 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
177 | 177 | ||
178 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 178 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { |
179 | const QRect &clip = dp. rect ( i ); | 179 | const QRect &clip = dp. rect ( i ); |
180 | 180 | ||
181 | qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 181 | qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
182 | 182 | ||
183 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb | 183 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb |
184 | uchar *src = frame; | 184 | uchar *src = frame; |
185 | 185 | ||
186 | // Adjust the start the source data based on the rotation (xine frame) | 186 | // Adjust the start the source data based on the rotation (xine frame) |
187 | switch ( rot ) { | 187 | switch ( rot ) { |
188 | case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; | 188 | case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; |
189 | 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; | 189 | 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; |
190 | 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; | 190 | 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; |
191 | case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; | 191 | case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; |
192 | default: break; | 192 | default: break; |
193 | } | 193 | } |
194 | 194 | ||
195 | // all of the following widths/heights are fb relative (0deg rotation) | 195 | // all of the following widths/heights are fb relative (0deg rotation) |
196 | 196 | ||
197 | uint leftfill = 0; // black border on the "left" side of the video frame | 197 | uint leftfill = 0; // black border on the "left" side of the video frame |
198 | uint framefill = 0; // "width" of the video frame | 198 | uint framefill = 0; // "width" of the video frame |
199 | uint rightfill = 0; // black border on the "right" side of the video frame | 199 | uint rightfill = 0; // black border on the "right" side of the video frame |
200 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect | 200 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect |
201 | 201 | ||
202 | if ( clip. left ( ) < framerect. left ( )) | 202 | if ( clip. left ( ) < framerect. left ( )) |
203 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | 203 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
204 | if ( clip. right ( ) > framerect. right ( )) | 204 | if ( clip. right ( ) > framerect. right ( )) |
205 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | 205 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
206 | 206 | ||
207 | framefill = clipwidth - ( leftfill + rightfill ); | 207 | framefill = clipwidth - ( leftfill + rightfill ); |
208 | 208 | ||
209 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 209 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
210 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 210 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
211 | // "above" or "below" the video -> black | 211 | // "above" or "below" the video -> black |
212 | memset ( dst, 0, clipwidth ); | 212 | memset ( dst, 0, clipwidth ); |
213 | } | 213 | } |
214 | else { | 214 | else { |
215 | if ( leftfill ) | 215 | if ( leftfill ) |
216 | memset ( dst, 0, leftfill ); // "left" border -> black | 216 | memset ( dst, 0, leftfill ); // "left" border -> black |
217 | 217 | ||
218 | if ( framefill ) { // blit in the video frame | 218 | if ( framefill ) { // blit in the video frame |
219 | // see above for an explanation of the different memcpys | 219 | // see above for an explanation of the different memcpys |
220 | 220 | ||
221 | switch ( rot ) { | 221 | switch ( rot ) { |
222 | case 0: memcpy ( dst + leftfill, src, framefill & ~1 ); break; | 222 | case 0: memcpy ( dst + leftfill, src, framefill & ~1 ); break; |
223 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 223 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
224 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 224 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
225 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 225 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
226 | default: break; | 226 | default: break; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | if ( rightfill ) | 229 | if ( rightfill ) |
230 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | 230 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black |
231 | } | 231 | } |
232 | 232 | ||
233 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer | 233 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer |
234 | 234 | ||
235 | // advance one "line" in the xine frame data | 235 | // advance one "line" in the xine frame data |
236 | switch ( rot ) { | 236 | switch ( rot ) { |
237 | case 0: src += m_bytes_per_line_frame;break; | 237 | case 0: src += m_bytes_per_line_frame;break; |
238 | case 1: src -= m_bytes_per_pixel; break; | 238 | case 1: src -= m_bytes_per_pixel; break; |
239 | case 2: src -= m_bytes_per_line_frame; break; | 239 | case 2: src -= m_bytes_per_line_frame; break; |
240 | case 3: src += m_bytes_per_pixel; break; | 240 | case 3: src += m_bytes_per_pixel; break; |
241 | default: break; | 241 | default: break; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | { | 247 | { |
248 | // QVFB hack by Martin Jones | 248 | // QVFB hack by Martin Jones |
249 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter | 249 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter |
250 | 250 | ||
251 | QPainter p ( this ); | 251 | QPainter p ( this ); |
252 | 252 | ||
253 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 253 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
254 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); | 254 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | QImage *XineVideoWidget::logo ( ) const | 261 | QImage *XineVideoWidget::logo ( ) const |
262 | { | 262 | { |
263 | return m_logo; | 263 | return m_logo; |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | void XineVideoWidget::setLogo ( QImage* logo ) | 267 | void XineVideoWidget::setLogo ( QImage* logo ) |
268 | { | 268 | { |
269 | delete m_logo; | 269 | delete m_logo; |
270 | m_logo = logo; | 270 | m_logo = logo; |
271 | } | 271 | } |
272 | 272 | ||
273 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) | 273 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) |
274 | { | 274 | { |
275 | bool rot90 = (( -m_rotation ) & 1 ); | 275 | bool rot90 = (( -m_rotation ) & 1 ); |
276 | 276 | ||
277 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height | 277 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height |
278 | int d = w; | 278 | int d = w; |
279 | w = h; | 279 | w = h; |
280 | h = d; | 280 | h = d; |
281 | } | 281 | } |
282 | 282 | ||
283 | m_lastframe = m_thisframe; | 283 | m_lastframe = m_thisframe; |
284 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 284 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
285 | 285 | ||
286 | m_buff = img; | 286 | m_buff = img; |
287 | m_bytes_per_line_frame = bpl; | 287 | m_bytes_per_line_frame = bpl; |
288 | 288 | ||
289 | // only repaint the area that *really* needs to be repainted | 289 | // only repaint the area that *really* needs to be repainted |
290 | 290 | ||
291 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 291 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
292 | // ensure that we always have a valid frame! | ||
293 | m_buff = 0; | ||
292 | } | 294 | } |
293 | 295 | ||
294 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 296 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
295 | { | 297 | { |
296 | emit videoResized( videoSize() ); | 298 | emit videoResized( videoSize() ); |
297 | } | 299 | } |
298 | 300 | ||
299 | 301 | ||
300 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) | 302 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) |
301 | { | 303 | { |
302 | emit clicked(); | 304 | emit clicked(); |
303 | } | 305 | } |
304 | 306 | ||