summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp181
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.h7
2 files changed, 159 insertions, 29 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index b5a714e..e46c4df 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -39,12 +39,43 @@
39#include <qsize.h> 39#include <qsize.h>
40 40
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42 42
43#include "xinevideowidget.h" 43#include "xinevideowidget.h"
44 44
45static inline void memcpy_rev ( void *dst, void *src, size_t len )
46{
47 ((char *) src ) += len;
48
49 len >>= 1;
50 while ( len-- )
51 *((short int *) dst )++ = *--((short int *) src );
52}
53
54static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
55{
56 len >>= 1;
57 while ( len-- ) {
58 *((short int *) dst )++ = *((short int *) src );
59 ((char *) src ) += step;
60 }
61}
62
63static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step )
64{
65 len >>= 1;
66
67 ((char *) src ) += ( len * step );
68
69 while ( len-- ) {
70 ((char *) src ) -= step;
71 *((short int *) dst )++ = *((short int *) src );
72 }
73}
74
75
45XineVideoWidget::XineVideoWidget( int width, 76XineVideoWidget::XineVideoWidget( int width,
46 int height, 77 int height,
47 QWidget* parent, 78 QWidget* parent,
48 const char* name ) 79 const char* name )
49 : QWidget( parent, name, WRepaintNoErase | WResizeNoErase ) 80 : QWidget( parent, name, WRepaintNoErase | WResizeNoErase )
50{ 81{
@@ -53,73 +84,175 @@ XineVideoWidget::XineVideoWidget( int width,
53 setBackgroundMode( NoBackground); 84 setBackgroundMode( NoBackground);
54/* QImage image = Resource::loadImage("SoundPlayer"); 85/* QImage image = Resource::loadImage("SoundPlayer");
55 image = image.smoothScale( width, height ); 86 image = image.smoothScale( width, height );
56 87
57 m_image = new QImage( image );*/ 88 m_image = new QImage( image );*/
58} 89}
59XineVideoWidget::~XineVideoWidget() { 90
91XineVideoWidget::~XineVideoWidget ( )
92{
60 delete m_image; 93 delete m_image;
61} 94}
62void XineVideoWidget::clear() { 95
96void XineVideoWidget::clear ( )
97{
63 m_buff = 0; 98 m_buff = 0;
64 repaint(false); 99 repaint(false);
65} 100}
66void XineVideoWidget::paintEvent( QPaintEvent* e ) { 101
102void XineVideoWidget::paintEvent ( QPaintEvent * )
103{
67 qWarning("painting"); 104 qWarning("painting");
68 if (m_buff == 0 ) { 105 if (m_buff == 0 ) {
69 QPainter p(this ); 106 QPainter p(this );
70 p.fillRect( rect(), black ); 107 p.fillRect( rect(), black );
71 p.drawImage( 0, 0, *m_image ); 108 p.drawImage( 0, 0, *m_image );
72 qWarning ( "logo\n" ); 109 qWarning ( "logo\n" );
73 } 110 }
74 else { 111 else {
75 qWarning("paitnevent\n"); 112 qWarning ( "paintevent\n" );
113
114 QArray <QRect> qt_bug_workaround_clip_rects;
115
76 { 116 {
117 QDirectPainter dp ( this );
77 118
78 if (( m_thisframe & m_lastframe ) != m_lastframe ) { 119 uchar *fb = dp. frameBuffer ( );
79 QPainter p ( this ); 120 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame;
80 p. fillRect ( m_lastframe, black ); 121
122 QRect framerect = QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( ));
123
124 qt_bug_workaround_clip_rects. resize ( dp. numRects ( ));
125
126 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) {
127 const QRect &clip = dp. rect ( i );
128
129 qt_bug_workaround_clip_rects [i] = clip;
130
131 int rot = dp. transformOrientation ( );
132
133 if ( rot == 0 || rot == 180 ) {
134 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb );
135 uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame );
136
137 if ( rot == 180 )
138 src += (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame );
139
140 uint leftfill = 0;
141 uint framefill = 0;
142 uint rightfill = 0;
143 uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
144
145 if ( clip. left ( ) < framerect. left ( ))
146 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
147 if ( clip. right ( ) > framerect. right ( ))
148 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
149
150 framefill = clipwidth - ( leftfill + rightfill );
151
152 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
153 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
154 memset ( dst, 0, clipwidth );
81 } 155 }
156 else {
157 if ( leftfill )
158 memset ( dst, 0, leftfill );
159
160 if ( framefill ) {
161 if ( rot == 0 )
162 memcpy ( dst + leftfill, src, framefill );
163 else
164 memcpy_rev ( dst + leftfill, src, framefill );
82 } 165 }
83 { 166 if ( rightfill )
84 QDirectPainter dp ( this ); 167 memset ( dst + leftfill + framefill, 0, rightfill );
168 }
169
170 dst += m_bytes_per_line_fb;
171 src += ( rot == 0 ? m_bytes_per_line_frame : -m_bytes_per_line_frame );
172 }
173 }
174 else { // rot == 90 || rot == 270
175 uchar *dst = fb + ( clip. y ( ) * m_bytes_per_pixel ) + ( clip. x ( ) * m_bytes_per_line_fb );
176 uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame );
177
178 if ( rot == 270 )
179 src += (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame );
180
181 uint leftfill = 0;
182 uint framefill = 0;
183 uint rightfill = 0;
184 uint clipwidth = clip. height ( ) * m_bytes_per_pixel;
185
186 if ( clip. bottom ( ) > framerect. bottom ( ))
187 leftfill = (( clip. bottom ( ) - framerect. bottom ( )) * m_bytes_per_pixel ) <? clipwidth;
188 if ( clip. top ( ) < framerect. top ( ))
189 rightfill = (( framerect. top ( ) - framerect. top ( )) * m_bytes_per_pixel ) <? clipwidth;
190
191 framefill = clipwidth - ( leftfill + rightfill );
192
193 for ( int y = clip. left ( ); y <= clip. right ( ); y++ ) {
194 if (( y < framerect. left ( )) || ( y > framerect. right ( ))) {
195 memset ( dst, 0, clipwidth );
196 }
197 else {
198 if ( leftfill )
199 memset ( dst, 0, leftfill );
85 200
86 uchar* dst = dp.frameBuffer() + (m_thisframe. y ( ) + dp.yOffset() ) * linestep + 201 if ( framefill ) {
87 (m_thisframe. x ( ) + dp.xOffset() ) * m_bytes_per_pixel; 202 if ( rot == 90 )
88 uchar* frame = m_buff; 203 memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame );
89 for(int y = 0; y < m_thisframe. height ( ); y++ ) { 204 else
90 memcpy( dst, frame, m_bytes ); 205 memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame );
91 frame += m_bytes; 206 }
92 dst += linestep; 207 if ( rightfill )
208 memset ( dst + leftfill + framefill, 0, rightfill );
209 }
210
211 dst += m_bytes_per_line_fb;
212 src += ( rot == 90 ? +1 : -1 ); // m_bytes_per_line_frame : -m_bytes_per_line_frame );
213 }
214 }
93 } 215 }
94 } 216 }
95 { 217 {
96 // QVFB hack by MArtin Jones 218 // QVFB hack by MArtin Jones
97 QPainter p ( this ); 219 QPainter p ( this );
98 p. fillRect ( m_thisframe, QBrush ( NoBrush )); 220
221 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) {
222 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) );
99 } 223 }
100 } 224 }
101} 225}
102int XineVideoWidget::height() const{ 226}
227
228int XineVideoWidget::height ( ) const
229{
103 return m_image->height(); 230 return m_image->height();
104} 231}
105int XineVideoWidget::width() const{ 232
233int XineVideoWidget::width ( ) const
234{
106 return m_image->width(); 235 return m_image->width();
107} 236}
108void XineVideoWidget::setImage( QImage* image ) { 237
238void XineVideoWidget::setImage ( QImage* image )
239{
109 delete m_image; 240 delete m_image;
110 m_image = image; 241 m_image = image;
111} 242}
243
112void XineVideoWidget::setImage( uchar* image, int yoffsetXLine, 244void XineVideoWidget::setImage( uchar* image, int yoffsetXLine,
113 int xoffsetXBytes, int width, 245 int xoffsetXBytes, int width,
114 int height, int linestep, int bytes, int bpp ) { 246 int height, int linestep, int bytes, int bpp )
247{
115 248
116 m_lastframe = m_thisframe; 249 m_lastframe = m_thisframe;
117 m_thisframe. setRect ( xoffsetXBytes, yoffsetXLine, width, height ); 250 m_thisframe. setRect ( xoffsetXBytes, yoffsetXLine, width, height );
118 251
119 m_buff = image; 252 m_buff = image;
120 this->linestep = linestep; 253 m_bytes_per_line_fb = linestep;
121 m_bytes = bytes; 254 m_bytes_per_line_frame = bytes;
122 m_bytes_per_pixel = bpp; 255 m_bytes_per_pixel = bpp;
123 256
124 repaint ( false ); 257 repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false );
125} 258}
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h
index 5656194..7d9a6d2 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.h
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.h
@@ -51,17 +51,14 @@ public:
51protected: 51protected:
52 void paintEvent( QPaintEvent* p ); 52 void paintEvent( QPaintEvent* p );
53private: 53private:
54 QRect m_lastframe; 54 QRect m_lastframe;
55 QRect m_thisframe; 55 QRect m_thisframe;
56 56
57 int m_wid;
58 int m_height;
59 int m_yOff, m_xOff;
60 uchar* m_buff; 57 uchar* m_buff;
61 int m_Width, m_Height, linestep; 58 int m_bytes_per_line_fb;
62 int m_bytes; 59 int m_bytes_per_line_frame;
63 int m_bytes_per_pixel; 60 int m_bytes_per_pixel;
64 QImage* m_image; 61 QImage* m_image;
65 62
66}; 63};
67 64