summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/xinevideowidget.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/xinevideowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp95
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
@@ -35,17 +35,19 @@
#include <qimage.h>
#include <qpainter.h>
#include <qgfx_qws.h>
#include <qdirectpainter_qws.h>
#include <qgfx_qws.h>
#include <qsize.h>
+#include <qapplication.h>
#include <qpe/resource.h>
#include "xinevideowidget.h"
+
static inline void memcpy_rev ( void *dst, void *src, size_t len )
{
((char *) src ) += len;
len >>= 1;
while ( len-- )
@@ -71,27 +73,25 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t st
((char *) src ) -= step;
*((short int *) dst )++ = *((short int *) src );
}
}
-XineVideoWidget::XineVideoWidget( int width,
- int height,
- QWidget* parent,
- const char* name )
+XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name )
: QWidget ( parent, name, WRepaintNoErase | WResizeNoErase )
{
- m_image = new QImage ( width, height, qt_screen-> depth ( ));
- m_buff = 0;
setBackgroundMode ( NoBackground );
- /* QImage image = Resource::loadImage("SoundPlayer");
- image = image.smoothScale( width, height );
-
- m_image = new QImage( image );*/
+
+ m_image = 0;
+ m_buff = 0;
+ m_bytes_per_line_fb = qt_screen-> linestep ( );
+ m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8;
+ m_rotation = 0;
}
+
XineVideoWidget::~XineVideoWidget ( )
{
delete m_image;
}
void XineVideoWidget::clear ( )
@@ -103,24 +103,25 @@ void XineVideoWidget::clear ( )
void XineVideoWidget::paintEvent ( QPaintEvent * )
{
//qWarning( "painting <<<" );
if ( m_buff == 0 ) {
QPainter p ( this );
p. fillRect ( rect ( ), black );
- p. drawImage ( 0, 0, *m_image );
+ if ( m_image )
+ p. drawImage ( 0, 0, *m_image );
//qWarning ( "logo\n" );
}
else {
// qWarning ( "paintevent\n" );
QArray <QRect> qt_bug_workaround_clip_rects;
{
QDirectPainter dp ( this );
- int rot = dp. transformOrientation ( );
+ int rot = dp. transformOrientation ( ) + m_rotation;
uchar *fb = dp. frameBuffer ( );
uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame;
QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
@@ -194,37 +195,73 @@ void XineVideoWidget::paintEvent ( QPaintEvent * )
}
}
}
//qWarning( "painting >>>" );
}
-int XineVideoWidget::height ( ) const
-{
- return m_image-> height ( );
-}
-
-int XineVideoWidget::width ( ) const
-{
- return m_image-> width ( );
-}
void XineVideoWidget::setImage ( QImage* image )
{
delete m_image;
m_image = image;
}
-void XineVideoWidget::setImage( uchar* image, int yoffsetXLine,
- int xoffsetXBytes, int width,
- int height, int linestep, int bytes, int bpp )
+void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl )
{
+ bool rot90 = (( -m_rotation ) & 1 );
+
+ if ( rot90 ) {
+ int d = w;
+ w = h;
+ h = d;
+ }
m_lastframe = m_thisframe;
- m_thisframe. setRect ( xoffsetXBytes, yoffsetXLine, width, height );
+ m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h );
- m_buff = image;
- m_bytes_per_line_fb = linestep;
- m_bytes_per_line_frame = bytes;
- m_bytes_per_pixel = bpp;
+// qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h );
+
+ m_buff = img;
+ m_bytes_per_line_frame = bpl;
repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false );
}
+
+void XineVideoWidget::resizeEvent ( QResizeEvent * )
+{
+ QSize s = size ( );
+ bool fs = ( s == qApp-> desktop ( )-> size ( ));
+
+ m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0;
+
+ if ( fs && qt_screen-> isTransformed ( )) {
+ s = qt_screen-> mapToDevice ( s );
+ }
+
+// qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation );
+
+ emit videoResized ( s );
+}
+
+
+void XineVideoWidget::mousePressEvent ( QMouseEvent *me )
+{
+ QWidget *p = parentWidget ( );
+
+ if ( p ) {
+ QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( ));
+
+ QApplication::sendEvent ( p, &pme );
+ }
+}
+
+void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me )
+{
+ QWidget *p = parentWidget ( );
+
+ if ( p ) {
+ QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( ));
+
+ QApplication::sendEvent ( p, &pme );
+ }
+}
+