Diffstat (limited to 'noncore/multimedia/opieplayer2/xinevideowidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 91 |
1 files changed, 64 insertions, 27 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 | |||
@@ -39,4 +39,5 @@ | |||
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> |
@@ -44,4 +45,5 @@ | |||
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 | { |
@@ -75,19 +77,17 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t st | |||
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"); | ||
87 | image = image.smoothScale( width, height ); | ||
88 | 83 | ||
89 | m_image = new QImage( image );*/ | 84 | m_image = 0; |
85 | m_buff = 0; | ||
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 | { |
@@ -107,4 +107,5 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
107 | QPainter p ( this ); | 107 | QPainter p ( this ); |
108 | p. fillRect ( rect ( ), black ); | 108 | p. fillRect ( rect ( ), black ); |
109 | if ( m_image ) | ||
109 | p. drawImage ( 0, 0, *m_image ); | 110 | p. drawImage ( 0, 0, *m_image ); |
110 | //qWarning ( "logo\n" ); | 111 | //qWarning ( "logo\n" ); |
@@ -118,5 +119,5 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
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 ( ); |
@@ -198,13 +199,4 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
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 ) |
@@ -214,17 +206,62 @@ void XineVideoWidget::setImage ( QImage* 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 | |||