Diffstat (limited to 'noncore/multimedia/opieplayer2/xinevideowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 151 |
1 files changed, 80 insertions, 71 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 9b26d41..1d88cea 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -3,3 +3,3 @@ | |||
3 | This file is part of the Opie Project | 3 | This file is part of the Opie Project |
4 | 4 | ||
5 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 5 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
@@ -30,3 +30,3 @@ | |||
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
@@ -46,2 +46,3 @@ | |||
46 | 46 | ||
47 | |||
47 | // 0 deg rot: copy a line from src to dst (use libc memcpy) | 48 | // 0 deg rot: copy a line from src to dst (use libc memcpy) |
@@ -52,3 +53,3 @@ static inline void memcpy_rev ( void *dst, void *src, size_t len ) | |||
52 | { | 53 | { |
53 | ((char *) src) += len; | 54 | ((char *) src ) += len; |
54 | 55 | ||
@@ -56,3 +57,3 @@ static inline void memcpy_rev ( void *dst, void *src, size_t len ) | |||
56 | while ( len-- ) | 57 | while ( len-- ) |
57 | *((short int *) dst) ++ = *--((short int *) src); | 58 | *((short int *) dst )++ = *--((short int *) src ); |
58 | } | 59 | } |
@@ -61,3 +62,3 @@ static inline void memcpy_rev ( void *dst, void *src, size_t len ) | |||
61 | 62 | ||
62 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t linestep ) | 63 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) |
63 | { | 64 | { |
@@ -65,4 +66,4 @@ static inline void memcpy_step ( void *dst, void *src, size_t len, size_t linest | |||
65 | while ( len-- ) { | 66 | while ( len-- ) { |
66 | *((short int *) dst) ++ = *((short int *) src); | 67 | *((short int *) dst )++ = *((short int *) src ); |
67 | ((char * ) src) += linestep; | 68 | ((char *) src ) += step; |
68 | } | 69 | } |
@@ -72,3 +73,3 @@ static inline void memcpy_step ( void *dst, void *src, size_t len, size_t linest | |||
72 | 73 | ||
73 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t linestep ) | 74 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) |
74 | { | 75 | { |
@@ -76,7 +77,7 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t li | |||
76 | 77 | ||
77 | ((char *) src) += ( len * linestep ); | 78 | ((char *) src ) += ( len * step ); |
78 | 79 | ||
79 | while ( len-- ) { | 80 | while ( len-- ) { |
80 | ((char *) src) -= linestep; | 81 | ((char *) src ) -= step; |
81 | *((short int *) dst) ++ = *((short int *) src); | 82 | *((short int *) dst )++ = *((short int *) src ); |
82 | } | 83 | } |
@@ -86,3 +87,3 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t li | |||
86 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 87 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
87 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 88 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
88 | { | 89 | { |
@@ -90,7 +91,7 @@ XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | |||
90 | 91 | ||
91 | m_logo = 0; | 92 | m_logo = 0; |
92 | m_buff = 0; | 93 | m_buff = 0; |
93 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 94 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
94 | m_bytes_per_pixel = ( qt_screen-> depth ( ) + 7 ) / 8; | 95 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
95 | m_rotation = 0; | 96 | m_rotation = 0; |
96 | } | 97 | } |
@@ -159,5 +160,5 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
159 | if ( clip. left ( ) < framerect. left ( )) | 160 | if ( clip. left ( ) < framerect. left ( )) |
160 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) < ? clipwidth; | 161 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
161 | if ( clip. right ( ) > framerect. right ( )) | 162 | if ( clip. right ( ) > framerect. right ( )) |
162 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) < ? clipwidth; | 163 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
163 | 164 | ||
@@ -184,80 +185,88 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
184 | } | 185 | } |
185 | if ( rightfill ) | ||
186 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | ||
187 | } | 186 | } |
187 | if ( rightfill ) | ||
188 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | ||
189 | } | ||
188 | 190 | ||
189 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer | 191 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer |
190 | 192 | ||
191 | // advance one "line" in the xine frame data | 193 | // advance one "line" in the xine frame data |
192 | switch ( rot ) { | 194 | switch ( rot ) { |
193 | case 0: src += m_bytes_per_line_frame;break; | 195 | case 0: src += m_bytes_per_line_frame;break; |
194 | case 1: src -= m_bytes_per_pixel; break; | 196 | case 1: src -= m_bytes_per_pixel; break; |
195 | case 2: src -= m_bytes_per_line_frame; break; | 197 | case 2: src -= m_bytes_per_line_frame; break; |
196 | case 3: src += m_bytes_per_pixel; break; | 198 | case 3: src += m_bytes_per_pixel; break; |
197 | default: break; | 199 | default: break; |
198 | } | ||
199 | } | 200 | } |
200 | } | 201 | } |
202 | } | ||
203 | } | ||
201 | 204 | ||
202 | { | 205 | { |
203 | // QVFB hack by Martin Jones | 206 | // QVFB hack by Martin Jones |
204 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter | 207 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter |
205 | 208 | ||
206 | QPainter p ( this ); | 209 | QPainter p ( this ); |
207 | 210 | ||
208 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 211 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
209 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); | 212 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); |
210 | } | ||
211 | } | ||
212 | } | 213 | } |
213 | } | 214 | } |
215 | } | ||
216 | } | ||
214 | 217 | ||
215 | QImage *XineVideoWidget::logo ( ) const { | ||
216 | return m_logo; | ||
217 | } | ||
218 | 218 | ||
219 | void XineVideoWidget::setLogo ( QImage * image ) { | 219 | QImage *XineVideoWidget::logo ( ) const |
220 | delete m_logo; | 220 | { |
221 | m_logo = image; | 221 | return m_logo; |
222 | } | 222 | } |
223 | 223 | ||
224 | void XineVideoWidget::setVideoFrame ( uchar * img, int w, int h, int bpl ) { | ||
225 | bool rot90 = (( -m_rotation ) & 1 ); | ||
226 | 224 | ||
227 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height | 225 | void XineVideoWidget::setLogo ( QImage* logo ) |
228 | int d = w; | 226 | { |
229 | w = h; | 227 | delete m_logo; |
230 | h = d; | 228 | m_logo = logo; |
231 | } | 229 | } |
232 | 230 | ||
233 | m_lastframe = m_thisframe; | 231 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) |
234 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 232 | { |
233 | bool rot90 = (( -m_rotation ) & 1 ); | ||
235 | 234 | ||
236 | m_buff = img; | 235 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height |
237 | m_bytes_per_line_frame = bpl; | 236 | int d = w; |
237 | w = h; | ||
238 | h = d; | ||
239 | } | ||
238 | 240 | ||
239 | // only repaint the area that *really* needs to be repainted | 241 | m_lastframe = m_thisframe; |
242 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | ||
240 | 243 | ||
241 | repaint (( | 244 | m_buff = img; |
242 | } | 245 | m_bytes_per_line_frame = bpl; |
243 | 246 | ||
244 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) { | 247 | // only repaint the area that *really* needs to be repainted |
245 | QSize s = size ( ); | ||
246 | bool fs = ( s == qApp-> desktop ( ) -> size ( )); | ||
247 | 248 | ||
248 | // if we are in fullscreen mode, do not rotate the video | 249 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
249 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | 250 | } |
251 | |||
252 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | ||
253 | { | ||
254 | QSize s = size ( ); | ||
255 | bool fs = ( s == qApp-> desktop ( )-> size ( )); | ||
250 | 256 | ||
251 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | 257 | // if we are in fullscreen mode, do not rotate the video |
258 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | ||
259 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | ||
252 | 260 | ||
253 | if ( fs && qt_screen-> isTransformed ( )) | 261 | if ( fs && qt_screen-> isTransformed ( )) |
254 | s = qt_screen-> mapToDevice ( s ); | 262 | s = qt_screen-> mapToDevice ( s ); |
255 | 263 | ||
256 | emit videoResized ( s ); | 264 | emit videoResized ( s ); |
257 | } | 265 | } |
258 | 266 | ||
259 | 267 | ||
260 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * ) { | 268 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) |
261 | emit clicked ( ); | 269 | { |
262 | } | 270 | emit clicked(); |
271 | } | ||
263 | 272 | ||