summaryrefslogtreecommitdiff
authoralwin <alwin>2005-04-10 22:00:26 (UTC)
committer alwin <alwin>2005-04-10 22:00:26 (UTC)
commitad2f1bd57cbfb0fdaf4d348ee3a70d3ea370d5d1 (patch) (unidiff)
tree1028d369feda50bfdad0f2531577a4daa261b0e1
parentd133e1f4c2b820ca428438cb17f5477190d268b1 (diff)
downloadopie-ad2f1bd57cbfb0fdaf4d348ee3a70d3ea370d5d1.zip
opie-ad2f1bd57cbfb0fdaf4d348ee3a70d3ea370d5d1.tar.gz
opie-ad2f1bd57cbfb0fdaf4d348ee3a70d3ea370d5d1.tar.bz2
-restored file header
-removed obsolete stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp52
1 files changed, 23 insertions, 29 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 7f59085..78ebe19 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -1,65 +1,64 @@
1
2/* 1/*
3                This file is part of the Opie Project 2                This file is part of the Opie Project
4 3
5              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
6 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
7 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
8 =. 7 =.
9 .=l. 8 .=l.
10           .>+-= 9           .>+-=
11 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
12.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
13:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
14.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
15 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
16     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
17    .%`+i>       _;_. 16    .%`+i>       _;_.
18    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
20    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
23..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
24++=   -.     .`     .: details. 23++=   -.     .`     .: details.
25 :     =  ...= . :.=- 24 :     =  ...= . :.=-
26 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
27  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
28    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
29 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
30 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
31 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
32 31
33*/ 32*/
34 33
35#include "xinevideowidget.h" 34#include "xinevideowidget.h"
36#include <opie2/odebug.h> 35#include <opie2/odebug.h>
37 36
38#include <qimage.h> 37#include <qimage.h>
39#include <qdirectpainter_qws.h> 38#include <qdirectpainter_qws.h>
40#include <qgfx_qws.h> 39#include <qgfx_qws.h>
41#include <qsize.h> 40#include <qsize.h>
42#include <qapplication.h> 41#include <qapplication.h>
43 42
44#include <qpe/resource.h> 43#include <qpe/resource.h>
45 44
46#include <pthread.h> 45#include <pthread.h>
47 46
48 47
49 48
50// 0 deg rot: copy a line from src to dst (use libc memcpy) 49// 0 deg rot: copy a line from src to dst (use libc memcpy)
51 50
52// 180 deg rot: copy a line from src to dst reversed 51// 180 deg rot: copy a line from src to dst reversed
53 52
54/* 53/*
55 * This code relies the len be a multiply of 16bit 54 * This code relies the len be a multiply of 16bit
56 */ 55 */
57static inline void memcpy_rev ( void *_dst, void *_src, size_t len ) 56static inline void memcpy_rev ( void *_dst, void *_src, size_t len )
58{ 57{
59 58
60 /* 59 /*
61 * move the source to the end 60 * move the source to the end
62 */ 61 */
63 char *src_c = static_cast<char*>(_src) + len; 62 char *src_c = static_cast<char*>(_src) + len;
64 63
65 /* 64 /*
@@ -154,186 +153,181 @@ void XineVideoWidget::clear ( )
154 repaint ( false ); 153 repaint ( false );
155} 154}
156 155
157QSize XineVideoWidget::videoSize() const 156QSize XineVideoWidget::videoSize() const
158{ 157{
159 QSize s = size(); 158 QSize s = size();
160 bool fs = ( s == qApp->desktop()->size() ); 159 bool fs = ( s == qApp->desktop()->size() );
161 160
162 // if we are in fullscreen mode, do not rotate the video 161 // if we are in fullscreen mode, do not rotate the video
163 // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) 162 // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!)
164 m_rotation = fs ? - qt_screen->transformOrientation() : 0; 163 m_rotation = fs ? - qt_screen->transformOrientation() : 0;
165 164
166 if ( fs && qt_screen->isTransformed() ) 165 if ( fs && qt_screen->isTransformed() )
167 s = qt_screen->mapToDevice( s ); 166 s = qt_screen->mapToDevice( s );
168 167
169 return s; 168 return s;
170} 169}
171 170
172void XineVideoWidget::paintEvent ( QPaintEvent * ) 171void XineVideoWidget::paintEvent ( QPaintEvent * )
173{ 172{
174 if (m_bufmutex.isLocked()) { 173 if (m_bufmutex.isLocked()) {
175 return; 174 return;
176 } 175 }
177 ThreadUtil::AutoLock a(m_bufmutex); 176 ThreadUtil::AutoLock a(m_bufmutex);
178 QPainter p ( this ); 177 QPainter p ( this );
179 p. fillRect ( rect (), black ); 178 p. fillRect ( rect (), black );
180 if (m_logo) 179 if (m_logo)
181 p. drawImage ( 0, 0, *m_logo ); 180 p. drawImage ( 0, 0, *m_logo );
182} 181}
183 182
184void XineVideoWidget::paintEvent2 ( QPaintEvent * ) 183void XineVideoWidget::paintEvent2 ( QPaintEvent * )
185{ 184{
186 ThreadUtil::AutoLock a(m_bufmutex); 185 ThreadUtil::AutoLock a(m_bufmutex);
187 QPainter p (this); 186 QPainter p (this);
188 if ( m_buff == 0 ) { 187 if ( m_buff == 0 ) {
189 p. fillRect ( rect ( ), black ); 188 p. fillRect ( rect ( ), black );
190 if ( m_logo ) 189 if ( m_logo )
191 p. drawImage ( 0, 0, *m_logo ); 190 p. drawImage ( 0, 0, *m_logo );
192 } else if (m_lastsize){ 191 } else if (m_lastsize){
193 // Qt needs to be notified which areas were really updated .. strange 192 // Qt needs to be notified which areas were really updated .. strange
194 QArray <QRect> qt_bug_workaround_clip_rects; 193 QArray <QRect> qt_bug_workaround_clip_rects;
195 194
196 { 195 {
197 QDirectPainter dp ( this ); 196 QDirectPainter dp ( this );
198 197
199 int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation 198 int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation
200 199
201 bool rot90 = (( -m_rotation ) & 1 ); 200 bool rot90 = (( -m_rotation ) & 1 );
202 201
203 int _vw,_vh; 202 int _vw,_vh;
204 switch (rot90) { 203 switch (rot90) {
205 case true: 204 case true:
206 _vh = m_framesize.width(); 205 _vh = m_framesize.width();
207 _vw = m_framesize.height(); 206 _vw = m_framesize.height();
208 break; 207 break;
209 default: 208 default:
210 _vw = m_framesize.width(); 209 _vw = m_framesize.width();
211 _vh = m_framesize.height(); 210 _vh = m_framesize.height();
212 break; 211 break;
213 break; 212 break;
214 } 213 }
215 int middle_w = _vw/2; 214 int middle_w = _vw/2;
216 int middle_h = _vh/2; 215 int middle_h = _vh/2;
217 m_thisframe.setRect(width()/2-middle_w,height()/2-middle_h,_vw,_vh); 216 m_thisframe.setRect(width()/2-middle_w,height()/2-middle_h,_vw,_vh);
218 QRect topFill,rightFill,leftFill,downFill; 217
219 topFill. setRect(0,0 ,width(),m_thisframe.top()); 218 {
220 downFill.setCoords(0,m_thisframe.bottom(),width(),height()); 219 // is this stuff realy needed? it seems working without, too.
221 rightFill.setCoords(m_thisframe.right(),0,width(),height()); 220 QRect topFill,rightFill,leftFill,downFill;
222 leftFill.setCoords(0,0,m_thisframe.left(),height()); 221 topFill. setRect(0,0 ,width(),m_thisframe.top());
223 222 downFill.setCoords(0,m_thisframe.bottom(),width(),height());
224 if (topFill.isValid()) { 223 rightFill.setCoords(m_thisframe.right(),0,width(),height());
225 p.fillRect(topFill,black); 224 leftFill.setCoords(0,0,m_thisframe.left(),height());
226 } 225
227 if (downFill.isValid()) { 226 if (topFill.isValid()) {
228 p.fillRect(downFill,black); 227 p.fillRect(topFill,black);
229 } 228 }
230 if (rightFill.isValid()) { 229 if (downFill.isValid()) {
231 p.fillRect(rightFill,black); 230 p.fillRect(downFill,black);
232 } 231 }
233 if (leftFill.isValid()) { 232 if (rightFill.isValid()) {
234 p.fillRect(leftFill,black); 233 p.fillRect(rightFill,black);
234 }
235 if (leftFill.isValid()) {
236 p.fillRect(leftFill,black);
237 }
238
235 } 239 }
236 uchar *fb = dp. frameBuffer ( ); 240 uchar *fb = dp. frameBuffer ( );
237 uchar *frame = m_buff; 241 uchar *frame = m_buff;
238 242
239 // where is the video frame in fb coordinates 243 // where is the video frame in fb coordinates
240 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), 244 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ),
241 qt_screen-> height ( ))); 245 qt_screen-> height ( )));
242 246
243 uchar * src = frame; 247 uchar * src = frame;
244 uchar * dst = fb+framerect.y()*m_bytes_per_line_fb+framerect.x()*m_bytes_per_pixel; 248 uchar * dst = fb+framerect.y()*m_bytes_per_line_fb+framerect.x()*m_bytes_per_pixel;
245 249
246 for (int y=framerect.top();y<=framerect.bottom();++y) { 250 for (int y=framerect.top();y<=framerect.bottom();++y) {
247 switch (rot) { 251 switch (rot) {
248 case 0: 252 case 0:
249 memcpy(dst,src,m_bytes_per_line_frame); 253 memcpy(dst,src,m_bytes_per_line_frame);
250 src+=m_bytes_per_line_frame; 254 src+=m_bytes_per_line_frame;
251 break; 255 break;
252 case 1: 256 case 1:
253 memcpy_step ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame ); 257 memcpy_step ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame );
254 src -= m_bytes_per_pixel; 258 src -= m_bytes_per_pixel;
255 break; 259 break;
256 case 2: 260 case 2:
257 memcpy_rev ( dst, src, m_thisframe.size().width()); 261 memcpy_rev ( dst, src, m_thisframe.size().width());
258 src-=m_bytes_per_line_frame; 262 src-=m_bytes_per_line_frame;
259 break; 263 break;
260 case 3: 264 case 3:
261 memcpy_step_rev ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame ); 265 memcpy_step_rev ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame );
262 src += m_bytes_per_pixel; 266 src += m_bytes_per_pixel;
263 break; 267 break;
264 default: 268 default:
265 break; 269 break;
266 } 270 }
267 dst += m_bytes_per_line_fb; 271 dst += m_bytes_per_line_fb;
268 } 272 }
269 } 273 }
270
271
272 {
273 // QVFB hack by Martin Jones
274 // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter
275 p.fillRect(QRect(mapFromGlobal (m_thisframe. topLeft ( )), m_thisframe.size ()),QBrush(NoBrush));
276 }
277 } 274 }
278} 275}
279 276
280QImage *XineVideoWidget::logo ( ) const 277QImage *XineVideoWidget::logo ( ) const
281{ 278{
282 return m_logo; 279 return m_logo;
283} 280}
284 281
285 282
286void XineVideoWidget::setLogo ( QImage* logo ) 283void XineVideoWidget::setLogo ( QImage* logo )
287{ 284{
288 delete m_logo; 285 delete m_logo;
289 m_logo = logo; 286 m_logo = logo;
290} 287}
291 288
292void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) 289void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl )
293{ 290{
294 // mutex area for AutoLock 291 // mutex area for AutoLock
295 { 292 {
296 if (m_bufmutex.isLocked()||w>width()||h>height()) { 293 if (m_bufmutex.isLocked()||w>width()||h>height()) {
297 // no time to wait - drop frame 294 // no time to wait - drop frame
298 return; 295 return;
299 } 296 }
300 ThreadUtil::AutoLock a(m_bufmutex); 297 ThreadUtil::AutoLock a(m_bufmutex);
301 bool rot90 = (( -m_rotation ) & 1 ); 298 bool rot90 = (( -m_rotation ) & 1 );
302 int l = h*bpl; 299 int l = h*bpl;
303 if (l!=m_lastsize) { 300 if (l!=m_lastsize) {
304 if (m_buff) { 301 if (m_buff) {
305 delete[]m_buff; 302 delete[]m_buff;
306 } 303 }
307 if (l>0) { 304 if (l>0) {
308 m_buff = new uchar[l]; 305 m_buff = new uchar[l];
309 odebug << "Point to: " << (unsigned long)m_buff << oendl; 306 odebug << "Point to: " << (unsigned long)m_buff << oendl;
310 m_lastsize=l; 307 m_lastsize=l;
311 } else { 308 } else {
312 m_buff = 0; 309 m_buff = 0;
313 } 310 }
314 } else if (l==0){
315 delete[] m_buff;
316 m_buff = 0;
317 } 311 }
318 m_lastsize = l; 312 m_lastsize = l;
319 m_framesize = QSize(w,h); 313 m_framesize = QSize(w,h);
320 if (m_buff && m_lastsize) { 314 if (m_buff && m_lastsize) {
321 memcpy(m_buff,img,m_lastsize); 315 memcpy(m_buff,img,m_lastsize);
322 } 316 }
323 m_bytes_per_line_frame = bpl; 317 m_bytes_per_line_frame = bpl;
324 } // Release Mutex 318 } // Release Mutex
325 319
326 paintEvent2(0); 320 if (m_buff) paintEvent2(0);
327} 321}
328 322
329void XineVideoWidget::resizeEvent ( QResizeEvent * ) 323void XineVideoWidget::resizeEvent ( QResizeEvent * )
330{ 324{
331 emit videoResized( videoSize() ); 325 emit videoResized( videoSize() );
332} 326}
333 327
334 328
335void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) 329void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ )
336{ 330{
337 emit clicked(); 331 emit clicked();
338} 332}
339 333