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 | |||
@@ -35,58 +35,59 @@ | |||
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qgfx_qws.h> | 36 | #include <qgfx_qws.h> |
37 | #include <qdirectpainter_qws.h> | 37 | #include <qdirectpainter_qws.h> |
38 | #include <qgfx_qws.h> | 38 | #include <qgfx_qws.h> |
39 | #include <qsize.h> | 39 | #include <qsize.h> |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
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 | { |
53 | ((char *) src) += len; | 54 | ((char *) src) += len; |
54 | 55 | ||
55 | len >>= 1; | 56 | len >>= 1; |
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 ) |
87 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 88 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
88 | { | 89 | { |
89 | setBackgroundMode ( NoBackground ); | 90 | setBackgroundMode ( NoBackground ); |
90 | 91 | ||
91 | m_logo = 0; | 92 | m_logo = 0; |
92 | m_buff = 0; | 93 | m_buff = 0; |
@@ -173,91 +174,99 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
173 | memset ( dst, 0, leftfill ); // "left" border -> black | 174 | memset ( dst, 0, leftfill ); // "left" border -> black |
174 | 175 | ||
175 | if ( framefill ) { // blit in the video frame | 176 | if ( framefill ) { // blit in the video frame |
176 | // see above for an explanation of the different memcpys | 177 | // see above for an explanation of the different memcpys |
177 | 178 | ||
178 | switch ( rot ) { | 179 | switch ( rot ) { |
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 | ||
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 | } | 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 ); |
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 | } | 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; |
231 | } | 239 | } |
232 | 240 | ||
233 | m_lastframe = m_thisframe; | 241 | m_lastframe = m_thisframe; |
234 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 242 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
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 | ||