summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp151
1 files changed, 57 insertions, 94 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 8e8f139..4b69044 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -33,12 +33,13 @@
*/
#include <qimage.h>
#include <qpainter.h>
#include <qgfx_qws.h>
#include <qdirectpainter_qws.h>
+#include <qgfx_qws.h>
#include <qsize.h>
#include <qpe/resource.h>
#include "xinevideowidget.h"
@@ -52,16 +53,12 @@ static inline void memcpy_rev ( void *dst, void *src, size_t len )
}
static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
{
len >>= 1;
while ( len-- ) {
-// *((char *) dst ) = *((char *) src + 1);
-// *((char *) dst + 1) = *((char *) src );
-// ((char *) dst ) += 2;
-
*((short int *) dst )++ = *((short int *) src );
((char *) src ) += step;
}
}
static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step )
@@ -70,16 +67,12 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t st
((char *) src ) += ( len * step );
while ( len-- ) {
((char *) src ) -= step;
*((short int *) dst )++ = *((short int *) src );
-
-// *((char *) dst ) = *((char *) src + 1);
-// *((char *) dst + 1) = *((char *) src );
-// ((char *) dst ) += 2;
}
}
XineVideoWidget::XineVideoWidget( int width,
int height,
@@ -106,18 +99,18 @@ void XineVideoWidget::clear ( )
m_buff = 0;
repaint ( false );
}
void XineVideoWidget::paintEvent ( QPaintEvent * )
{
- qWarning( "painting <<<" );
+ //qWarning( "painting <<<" );
if ( m_buff == 0 ) {
QPainter p ( this );
p. fillRect ( rect ( ), black );
p. drawImage ( 0, 0, *m_image );
- qWarning ( "logo\n" );
+ //qWarning ( "logo\n" );
}
else {
// qWarning ( "paintevent\n" );
QArray <QRect> qt_bug_workaround_clip_rects;
@@ -126,115 +119,85 @@ void XineVideoWidget::paintEvent ( QPaintEvent * )
int rot = dp. transformOrientation ( );
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 = QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( ));
-
+ QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
+
qt_bug_workaround_clip_rects. resize ( dp. numRects ( ));
for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) {
const QRect &clip = dp. rect ( i );
- qt_bug_workaround_clip_rects [i] = clip;
+ qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
- if ( rot == 0 || rot == 180 ) {
- uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb );
- uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame );
-
- if ( rot == 180 )
- src += (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame );
-
- uint leftfill = 0;
- uint framefill = 0;
- uint rightfill = 0;
- uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
-
- if ( clip. left ( ) < framerect. left ( ))
- leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
- if ( clip. right ( ) > framerect. right ( ))
- rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
-
- framefill = clipwidth - ( leftfill + rightfill );
-
- for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
- if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
- memset ( dst, 0, clipwidth );
- }
- else {
- if ( leftfill )
- memset ( dst, 0, leftfill );
-
- if ( framefill ) {
- if ( rot == 0 )
- memcpy ( dst + leftfill, src, framefill );
- else
- memcpy_rev ( dst + leftfill, src, framefill );
- }
- if ( rightfill )
- memset ( dst + leftfill + framefill, 0, rightfill );
- }
-
- dst += m_bytes_per_line_fb;
- src += ( rot == 0 ? m_bytes_per_line_frame : -m_bytes_per_line_frame );
- }
+ uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb );
+ uchar *src = frame;
+
+ switch ( rot ) {
+ case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break;
+ case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break;
+ case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break;
+ case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break;
}
- else { // rot == 90 || rot == 270
- uchar *dst = fb + ( clip. y ( ) * m_bytes_per_pixel ) + ( clip. x ( ) * m_bytes_per_line_fb );
- uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame );
-
- if ( rot == 270 )
- src += (( framerect. height ( ) - 1 ) * m_bytes_per_pixel );
-
- uint leftfill = 0;
- uint framefill = 0;
- uint rightfill = 0;
- uint clipwidth = clip. height ( ) * m_bytes_per_pixel;
-
- if ( clip. bottom ( ) > framerect. bottom ( ))
- leftfill = (( clip. bottom ( ) - framerect. bottom ( )) * m_bytes_per_pixel ) <? clipwidth;
- if ( clip. top ( ) < framerect. top ( ))
- rightfill = (( framerect. top ( ) - framerect. top ( )) * m_bytes_per_pixel ) <? clipwidth;
+
+ uint leftfill = 0;
+ uint framefill = 0;
+ uint rightfill = 0;
+ uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
+
+ if ( clip. left ( ) < framerect. left ( ))
+ leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
+ if ( clip. right ( ) > framerect. right ( ))
+ rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
+
+ framefill = clipwidth - ( leftfill + rightfill );
+
+ for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
+ if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
+ memset ( dst, 0, clipwidth );
+ }
+ else {
+ if ( leftfill )
+ memset ( dst, 0, leftfill );
+
+ if ( framefill ) {
+ switch ( rot ) {
+ case 0: memcpy ( dst + leftfill, src, framefill ); break;
+ case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
+ case 2: memcpy_rev ( dst + leftfill, src, framefill ); break;
+ case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
+ }
+ }
+ if ( rightfill )
+ memset ( dst + leftfill + framefill, 0, rightfill );
+ }
- framefill = clipwidth - ( leftfill + rightfill );
+ dst += m_bytes_per_line_fb;
- for ( int y = clip. left ( ); y <= clip. right ( ); y++ ) {
- if (( y < framerect. left ( )) || ( y > framerect. right ( ))) {
- memset ( dst, 0, clipwidth );
- }
- else {
- if ( leftfill )
- memset ( dst, 0, leftfill );
-
- if ( framefill ) {
- if ( rot == 90 )
- memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame );
- else
- memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame );
- }
- if ( rightfill )
- memset ( dst + leftfill + framefill, 0, rightfill );
- }
-
- dst += m_bytes_per_line_fb;
- src += ( rot == 270 ? -m_bytes_per_pixel : m_bytes_per_pixel );
- }
+ switch ( rot ) {
+ case 0: src += m_bytes_per_line_frame; break;
+ case 1: src -= m_bytes_per_pixel; break;
+ case 2: src -= m_bytes_per_line_frame; break;
+ case 3: src += m_bytes_per_pixel; break;
+ }
}
}
- }
+ }
+ //qWarning ( " ||| painting |||" );
{
// QVFB hack by MArtin Jones
QPainter p ( this );
-
+
for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) {
p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) );
}
}
}
- qWarning( "painting >>>" );
+ //qWarning( "painting >>>" );
}
int XineVideoWidget::height ( ) const
{
return m_image-> height ( );
}