Diffstat (limited to 'noncore/multimedia/opieplayer2/xinevideowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 95 |
1 files changed, 66 insertions, 29 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 4b69044..98446a0 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -33,21 +33,23 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <qimage.h> | 35 | #include <qimage.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qgfx_qws.h> | 37 | #include <qgfx_qws.h> |
38 | #include <qdirectpainter_qws.h> | 38 | #include <qdirectpainter_qws.h> |
39 | #include <qgfx_qws.h> | 39 | #include <qgfx_qws.h> |
40 | #include <qsize.h> | 40 | #include <qsize.h> |
41 | #include <qapplication.h> | ||
41 | 42 | ||
42 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
43 | 44 | ||
44 | #include "xinevideowidget.h" | 45 | #include "xinevideowidget.h" |
45 | 46 | ||
47 | |||
46 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 48 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
47 | { | 49 | { |
48 | ((char *) src ) += len; | 50 | ((char *) src ) += len; |
49 | 51 | ||
50 | len >>= 1; | 52 | len >>= 1; |
51 | while ( len-- ) | 53 | while ( len-- ) |
52 | *((short int *) dst )++ = *--((short int *) src ); | 54 | *((short int *) dst )++ = *--((short int *) src ); |
53 | } | 55 | } |
@@ -69,31 +71,29 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t st | |||
69 | 71 | ||
70 | while ( len-- ) { | 72 | while ( len-- ) { |
71 | ((char *) src ) -= step; | 73 | ((char *) src ) -= step; |
72 | *((short int *) dst )++ = *((short int *) src ); | 74 | *((short int *) dst )++ = *((short int *) src ); |
73 | } | 75 | } |
74 | } | 76 | } |
75 | 77 | ||
76 | 78 | ||
77 | XineVideoWidget::XineVideoWidget( int width, | 79 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
78 | int height, | ||
79 | QWidget* parent, | ||
80 | const char* name ) | ||
81 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 80 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
82 | { | 81 | { |
83 | m_image = new QImage ( width, height, qt_screen-> depth ( )); | ||
84 | m_buff = 0; | ||
85 | setBackgroundMode ( NoBackground ); | 82 | setBackgroundMode ( NoBackground ); |
86 | /* QImage image = Resource::loadImage("SoundPlayer"); | 83 | |
87 | image = image.smoothScale( width, height ); | 84 | m_image = 0; |
88 | 85 | m_buff = 0; | |
89 | m_image = new QImage( image );*/ | 86 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
87 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | ||
88 | m_rotation = 0; | ||
90 | } | 89 | } |
91 | 90 | ||
91 | |||
92 | XineVideoWidget::~XineVideoWidget ( ) | 92 | XineVideoWidget::~XineVideoWidget ( ) |
93 | { | 93 | { |
94 | delete m_image; | 94 | delete m_image; |
95 | } | 95 | } |
96 | 96 | ||
97 | void XineVideoWidget::clear ( ) | 97 | void XineVideoWidget::clear ( ) |
98 | { | 98 | { |
99 | m_buff = 0; | 99 | m_buff = 0; |
@@ -101,28 +101,29 @@ void XineVideoWidget::clear ( ) | |||
101 | } | 101 | } |
102 | 102 | ||
103 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 103 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
104 | { | 104 | { |
105 | //qWarning( "painting <<<" ); | 105 | //qWarning( "painting <<<" ); |
106 | if ( m_buff == 0 ) { | 106 | if ( m_buff == 0 ) { |
107 | QPainter p ( this ); | 107 | QPainter p ( this ); |
108 | p. fillRect ( rect ( ), black ); | 108 | p. fillRect ( rect ( ), black ); |
109 | p. drawImage ( 0, 0, *m_image ); | 109 | if ( m_image ) |
110 | p. drawImage ( 0, 0, *m_image ); | ||
110 | //qWarning ( "logo\n" ); | 111 | //qWarning ( "logo\n" ); |
111 | } | 112 | } |
112 | else { | 113 | else { |
113 | // qWarning ( "paintevent\n" ); | 114 | // qWarning ( "paintevent\n" ); |
114 | 115 | ||
115 | QArray <QRect> qt_bug_workaround_clip_rects; | 116 | QArray <QRect> qt_bug_workaround_clip_rects; |
116 | 117 | ||
117 | { | 118 | { |
118 | QDirectPainter dp ( this ); | 119 | QDirectPainter dp ( this ); |
119 | 120 | ||
120 | int rot = dp. transformOrientation ( ); | 121 | int rot = dp. transformOrientation ( ) + m_rotation; |
121 | 122 | ||
122 | uchar *fb = dp. frameBuffer ( ); | 123 | uchar *fb = dp. frameBuffer ( ); |
123 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; | 124 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; |
124 | 125 | ||
125 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 126 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
126 | 127 | ||
127 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 128 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
128 | 129 | ||
@@ -192,39 +193,75 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
192 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 193 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
193 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); | 194 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); |
194 | } | 195 | } |
195 | } | 196 | } |
196 | } | 197 | } |
197 | //qWarning( "painting >>>" ); | 198 | //qWarning( "painting >>>" ); |
198 | } | 199 | } |
199 | 200 | ||
200 | int XineVideoWidget::height ( ) const | ||
201 | { | ||
202 | return m_image-> height ( ); | ||
203 | } | ||
204 | |||
205 | int XineVideoWidget::width ( ) const | ||
206 | { | ||
207 | return m_image-> width ( ); | ||
208 | } | ||
209 | 201 | ||
210 | void XineVideoWidget::setImage ( QImage* image ) | 202 | void XineVideoWidget::setImage ( QImage* image ) |
211 | { | 203 | { |
212 | delete m_image; | 204 | delete m_image; |
213 | m_image = image; | 205 | m_image = image; |
214 | } | 206 | } |
215 | 207 | ||
216 | void XineVideoWidget::setImage( uchar* image, int yoffsetXLine, | 208 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) |
217 | int xoffsetXBytes, int width, | ||
218 | int height, int linestep, int bytes, int bpp ) | ||
219 | { | 209 | { |
210 | bool rot90 = (( -m_rotation ) & 1 ); | ||
211 | |||
212 | if ( rot90 ) { | ||
213 | int d = w; | ||
214 | w = h; | ||
215 | h = d; | ||
216 | } | ||
220 | 217 | ||
221 | m_lastframe = m_thisframe; | 218 | m_lastframe = m_thisframe; |
222 | m_thisframe. setRect ( xoffsetXBytes, yoffsetXLine, width, height ); | 219 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
223 | 220 | ||
224 | m_buff = image; | 221 | //qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
225 | m_bytes_per_line_fb = linestep; | 222 | |
226 | m_bytes_per_line_frame = bytes; | 223 | m_buff = img; |
227 | m_bytes_per_pixel = bpp; | 224 | m_bytes_per_line_frame = bpl; |
228 | 225 | ||
229 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 226 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
230 | } | 227 | } |
228 | |||
229 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | ||
230 | { | ||
231 | QSize s = size ( ); | ||
232 | bool fs = ( s == qApp-> desktop ( )-> size ( )); | ||
233 | |||
234 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | ||
235 | |||
236 | if ( fs && qt_screen-> isTransformed ( )) { | ||
237 | s = qt_screen-> mapToDevice ( s ); | ||
238 | } | ||
239 | |||
240 | //qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); | ||
241 | |||
242 | emit videoResized ( s ); | ||
243 | } | ||
244 | |||
245 | |||
246 | void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) | ||
247 | { | ||
248 | QWidget *p = parentWidget ( ); | ||
249 | |||
250 | if ( p ) { | ||
251 | QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | ||
252 | |||
253 | QApplication::sendEvent ( p, &pme ); | ||
254 | } | ||
255 | } | ||
256 | |||
257 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) | ||
258 | { | ||
259 | QWidget *p = parentWidget ( ); | ||
260 | |||
261 | if ( p ) { | ||
262 | QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | ||
263 | |||
264 | QApplication::sendEvent ( p, &pme ); | ||
265 | } | ||
266 | } | ||
267 | |||