Diffstat (limited to 'noncore/multimedia/opieplayer2/xinevideowidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 35 |
1 files changed, 22 insertions, 13 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 | |||
@@ -41,12 +41,13 @@ | |||
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | 42 | ||
43 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
44 | 44 | ||
45 | #include "xinevideowidget.h" | 45 | #include "xinevideowidget.h" |
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) |
48 | 49 | ||
49 | // 180 deg rot: copy a line from src to dst reversed | 50 | // 180 deg rot: copy a line from src to dst reversed |
50 | 51 | ||
51 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 52 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
52 | { | 53 | { |
@@ -56,31 +57,31 @@ 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 | } |
59 | 60 | ||
60 | // 90 deg rot: copy a column from src to dst | 61 | // 90 deg rot: copy a column from src to dst |
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 | { |
64 | len >>= 1; | 65 | len >>= 1; |
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 | } |
69 | } | 70 | } |
70 | 71 | ||
71 | // 270 deg rot: copy a column from src to dst reversed | 72 | // 270 deg rot: copy a column from src to dst reversed |
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 | { |
75 | len >>= 1; | 76 | len >>= 1; |
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 | } |
83 | } | 84 | } |
84 | 85 | ||
85 | 86 | ||
86 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 87 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
@@ -179,12 +180,13 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
179 | case 0: memcpy ( dst + leftfill, src, framefill ); break; | 180 | case 0: memcpy ( dst + leftfill, src, framefill ); break; |
180 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 181 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
181 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 182 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
182 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 183 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
183 | default: break; | 184 | default: break; |
184 | } | 185 | } |
186 | } | ||
185 | if ( rightfill ) | 187 | if ( rightfill ) |
186 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | 188 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black |
187 | } | 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 | ||
@@ -195,12 +197,13 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
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 | } | 200 | } |
199 | } | 201 | } |
200 | } | 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 ); |
@@ -209,22 +212,27 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
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 | } | 213 | } |
211 | } | 214 | } |
212 | } | 215 | } |
213 | } | 216 | } |
214 | 217 | ||
215 | QImage *XineVideoWidget::logo ( ) const { | 218 | |
219 | QImage *XineVideoWidget::logo ( ) const | ||
220 | { | ||
216 | return m_logo; | 221 | return m_logo; |
217 | } | 222 | } |
218 | 223 | ||
219 | void XineVideoWidget::setLogo ( QImage * image ) { | 224 | |
225 | void XineVideoWidget::setLogo ( QImage* logo ) | ||
226 | { | ||
220 | delete m_logo; | 227 | delete m_logo; |
221 | m_logo = image; | 228 | m_logo = logo; |
222 | } | 229 | } |
223 | 230 | ||
224 | void XineVideoWidget::setVideoFrame ( uchar * img, int w, int h, int bpl ) { | 231 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) |
232 | { | ||
225 | bool rot90 = (( -m_rotation ) & 1 ); | 233 | bool rot90 = (( -m_rotation ) & 1 ); |
226 | 234 | ||
227 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height | 235 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height |
228 | int d = w; | 236 | int d = w; |
229 | w = h; | 237 | w = h; |
230 | h = d; | 238 | h = d; |
@@ -235,29 +243,30 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
235 | 243 | ||
236 | m_buff = img; | 244 | m_buff = img; |
237 | m_bytes_per_line_frame = bpl; | 245 | m_bytes_per_line_frame = bpl; |
238 | 246 | ||
239 | // only repaint the area that *really* needs to be repainted | 247 | // only repaint the area that *really* needs to be repainted |
240 | 248 | ||
241 | repaint (( | 249 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
242 | } | 250 | } |
243 | 251 | ||
244 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) { | 252 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
253 | { | ||
245 | QSize s = size ( ); | 254 | QSize s = size ( ); |
246 | bool fs = ( s == qApp-> desktop ( ) -> size ( )); | 255 | bool fs = ( s == qApp-> desktop ( ) -> size ( )); |
247 | 256 | ||
248 | // if we are in fullscreen mode, do not rotate the video | 257 | // if we are in fullscreen mode, do not rotate the video |
249 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | 258 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) |
250 | |||
251 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | 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*/ ) |
269 | { | ||
261 | emit clicked ( ); | 270 | emit clicked ( ); |
262 | } | 271 | } |
263 | 272 | ||