summaryrefslogtreecommitdiff
authoralwin <alwin>2005-04-11 21:53:59 (UTC)
committer alwin <alwin>2005-04-11 21:53:59 (UTC)
commitdf382ea245959ed4d27012358e24c4c95767270f (patch) (unidiff)
treec1d71289d9773461692c8c181fef3b27e402eb0d
parent840e44417402bbc6048ca5e8ff3dd6be966e753f (diff)
downloadopie-df382ea245959ed4d27012358e24c4c95767270f.zip
opie-df382ea245959ed4d27012358e24c4c95767270f.tar.gz
opie-df382ea245959ed4d27012358e24c4c95767270f.tar.bz2
next stage of bug hunting
seems that errors/problems in pure display are fixed. removed all qpaint stuff may invoked in xine-thread (evil,evil!) - I think it isn't needed there. so I deactivated the mutex this moment
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp101
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.h42
2 files changed, 57 insertions, 86 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 78ebe19..b27b8e1 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -1,35 +1,35 @@
1/* 1/*
2                This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9 .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:, .> :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.-- : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - . .-<_> .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16    .%`+i>       _;_. 16 .%`+i> _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17 .i_,=:_. -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++=   -.     .`     .: details. 23++= -. .` .: details.
24 :     =  ...= . :.=- 24 : = ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -. .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "xinevideowidget.h" 34#include "xinevideowidget.h"
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
@@ -165,94 +165,60 @@ QSize XineVideoWidget::videoSize() const
165 if ( fs && qt_screen->isTransformed() ) 165 if ( fs && qt_screen->isTransformed() )
166 s = qt_screen->mapToDevice( s ); 166 s = qt_screen->mapToDevice( s );
167 167
168 return s; 168 return s;
169} 169}
170 170
171void XineVideoWidget::paintEvent ( QPaintEvent * ) 171void XineVideoWidget::paintEvent ( QPaintEvent * )
172{ 172{
173 if (m_bufmutex.isLocked()) {
174 return;
175 }
176 ThreadUtil::AutoLock a(m_bufmutex);
177 QPainter p ( this ); 173 QPainter p ( this );
178 p. fillRect ( rect (), black ); 174 p. fillRect ( rect (), black );
179 if (m_logo) 175 if (m_logo)
180 p. drawImage ( 0, 0, *m_logo ); 176 p. drawImage ( 0, 0, *m_logo );
181} 177}
182 178
183void XineVideoWidget::paintEvent2 ( QPaintEvent * ) 179void XineVideoWidget::paintEvent2 ( QPaintEvent * )
184{ 180{
185 ThreadUtil::AutoLock a(m_bufmutex);
186 QPainter p (this);
187 if ( m_buff == 0 ) { 181 if ( m_buff == 0 ) {
188 p. fillRect ( rect ( ), black ); 182 return;
189 if ( m_logo )
190 p. drawImage ( 0, 0, *m_logo );
191 } else if (m_lastsize){ 183 } else if (m_lastsize){
192 // Qt needs to be notified which areas were really updated .. strange
193 QArray <QRect> qt_bug_workaround_clip_rects;
194
195 { 184 {
196 QDirectPainter dp ( this ); 185 QDirectPainter dp ( this );
197
198 int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation 186 int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation
199
200 bool rot90 = (( -m_rotation ) & 1 ); 187 bool rot90 = (( -m_rotation ) & 1 );
201
202 int _vw,_vh; 188 int _vw,_vh;
203 switch (rot90) { 189 switch (rot90) {
204 case true: 190 case true:
205 _vh = m_framesize.width(); 191 _vh = m_framesize.width();
206 _vw = m_framesize.height(); 192 _vw = m_framesize.height();
207 break; 193 break;
208 default: 194 default:
209 _vw = m_framesize.width(); 195 _vw = m_framesize.width();
210 _vh = m_framesize.height(); 196 _vh = m_framesize.height();
211 break; 197 break;
212 break; 198 break;
213 } 199 }
214 int middle_w = _vw/2; 200 int middle_w = _vw/2;
215 int middle_h = _vh/2; 201 int middle_h = _vh/2;
216 m_thisframe.setRect(width()/2-middle_w,height()/2-middle_h,_vw,_vh); 202 m_thisframe.setRect(width()/2-middle_w,height()/2-middle_h,_vw,_vh);
217
218 {
219 // is this stuff realy needed? it seems working without, too.
220 QRect topFill,rightFill,leftFill,downFill;
221 topFill. setRect(0,0 ,width(),m_thisframe.top());
222 downFill.setCoords(0,m_thisframe.bottom(),width(),height());
223 rightFill.setCoords(m_thisframe.right(),0,width(),height());
224 leftFill.setCoords(0,0,m_thisframe.left(),height());
225
226 if (topFill.isValid()) {
227 p.fillRect(topFill,black);
228 }
229 if (downFill.isValid()) {
230 p.fillRect(downFill,black);
231 }
232 if (rightFill.isValid()) {
233 p.fillRect(rightFill,black);
234 }
235 if (leftFill.isValid()) {
236 p.fillRect(leftFill,black);
237 }
238
239 }
240 uchar *fb = dp. frameBuffer ( ); 203 uchar *fb = dp. frameBuffer ( );
241 uchar *frame = m_buff; 204 uchar *frame = m_buff;
242 205
243 // where is the video frame in fb coordinates 206 // where is the video frame in fb coordinates
244 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), 207 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ),
245 qt_screen-> height ( ))); 208 qt_screen-> height ( )));
246 209
247 uchar * src = frame; 210 uchar * src = frame;
248 uchar * dst = fb+framerect.y()*m_bytes_per_line_fb+framerect.x()*m_bytes_per_pixel; 211 uchar * dst = fb+framerect.y()*m_bytes_per_line_fb+framerect.x()*m_bytes_per_pixel;
249 212
250 for (int y=framerect.top();y<=framerect.bottom();++y) { 213 if (framerect.height()!=m_framesize.height()) {
214 odebug << "Hoehm: " << framerect.height() << " <-> " << m_framesize.height() << oendl;
215 }
216 for (int y = 0;y<framerect.height();++y) {
251 switch (rot) { 217 switch (rot) {
252 case 0: 218 case 0:
253 memcpy(dst,src,m_bytes_per_line_frame); 219 memcpy(dst,src,m_bytes_per_line_frame);
254 src+=m_bytes_per_line_frame; 220 src+=m_bytes_per_line_frame;
255 break; 221 break;
256 case 1: 222 case 1:
257 memcpy_step ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame ); 223 memcpy_step ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame );
258 src -= m_bytes_per_pixel; 224 src -= m_bytes_per_pixel;
@@ -285,21 +251,23 @@ void XineVideoWidget::setLogo ( QImage* logo )
285 delete m_logo; 251 delete m_logo;
286 m_logo = logo; 252 m_logo = logo;
287} 253}
288 254
289void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) 255void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl )
290{ 256{
291 // mutex area for AutoLock 257 // mutex area for AutoLock
292 { 258 {
293 if (m_bufmutex.isLocked()||w>width()||h>height()) { 259#if 0
294 // no time to wait - drop frame 260 ThreadUtil::AutoLock a(m_bufmutex);
261#endif
262 if (!isVisible()||w>width()||h>height()/*||m_bufmutex.isLocked()*/) {
263 //drop frame
295 return; 264 return;
296 } 265 }
297 ThreadUtil::AutoLock a(m_bufmutex);
298 bool rot90 = (( -m_rotation ) & 1 ); 266 bool rot90 = (( -m_rotation ) & 1 );
299 int l = h*bpl; 267 int l = h*bpl;
300 if (l!=m_lastsize) { 268 if (l!=m_lastsize) {
301 if (m_buff) { 269 if (m_buff) {
302 delete[]m_buff; 270 delete[]m_buff;
303 } 271 }
304 if (l>0) { 272 if (l>0) {
305 m_buff = new uchar[l]; 273 m_buff = new uchar[l];
@@ -310,24 +278,27 @@ void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl )
310 } 278 }
311 } 279 }
312 m_lastsize = l; 280 m_lastsize = l;
313 m_framesize = QSize(w,h); 281 m_framesize = QSize(w,h);
314 if (m_buff && m_lastsize) { 282 if (m_buff && m_lastsize) {
315 memcpy(m_buff,img,m_lastsize); 283 memcpy(m_buff,img,m_lastsize);
316 } 284 }
317 m_bytes_per_line_frame = bpl; 285 m_bytes_per_line_frame = bpl;
286 if (m_buff) paintEvent2(0);
318 } // Release Mutex 287 } // Release Mutex
319
320 if (m_buff) paintEvent2(0);
321} 288}
322 289
323void XineVideoWidget::resizeEvent ( QResizeEvent * ) 290void XineVideoWidget::resizeEvent ( QResizeEvent * )
324{ 291{
292#if 0
293 ThreadUtil::AutoLock a(m_bufmutex);
294#endif
325 emit videoResized( videoSize() ); 295 emit videoResized( videoSize() );
296 odebug << "All resize done" << oendl;
326} 297}
327 298
328 299
329void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) 300void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ )
330{ 301{
331 emit clicked(); 302 emit clicked();
332} 303}
333 304
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h
index eccff1a..a0ec5bc 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.h
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.h
@@ -1,36 +1,36 @@
1 1
2/* 2/*
3                This file is part of the Opie Project 3 This file is part of the Opie Project
4 4
5              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 5 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
6 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 6 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
7 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 7 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
8 =. 8 =.
9 .=l. 9 .=l.
10           .>+-= 10 .>+-=
11 _;:,     .>    :=|. This program is free software; you can 11 _;:, .> :=|. This program is free software; you can
12.> <`_,   >  .   <= redistribute it and/or modify it under 12.> <`_, > . <= redistribute it and/or modify it under
13:`=1 )Y*s>-.--   : the terms of the GNU General Public 13:`=1 )Y*s>-.-- : the terms of the GNU General Public
14.="- .-=="i,     .._ License as published by the Free Software 14.="- .-=="i, .._ License as published by the Free Software
15 - .   .-<_>     .<> Foundation; either version 2 of the License, 15 - . .-<_> .<> Foundation; either version 2 of the License,
16     ._= =}       : or (at your option) any later version. 16 ._= =} : or (at your option) any later version.
17    .%`+i>       _;_. 17 .%`+i> _;_.
18    .i_,=:_.      -<s. This program is distributed in the hope that 18 .i_,=:_. -<s. This program is distributed in the hope that
19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 19 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
20    : ..    .:,     . . . without even the implied warranty of 20 : .. .:, . . . without even the implied warranty of
21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 21 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 22 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
23..}^=.=       =       ; Library General Public License for more 23..}^=.= = ; Library General Public License for more
24++=   -.     .`     .: details. 24++= -. .` .: details.
25 :     =  ...= . :.=- 25 : = ...= . :.=-
26 -.   .:....=;==+<; You should have received a copy of the GNU 26 -. .:....=;==+<; You should have received a copy of the GNU
27  -_. . .   )=.  = Library General Public License along with 27 -_. . . )=. = Library General Public License along with
28    --        :-=` this library; see the file COPYING.LIB. 28 -- :-=` this library; see the file COPYING.LIB.
29 If not, write to the Free Software Foundation, 29 If not, write to the Free Software Foundation,
30 Inc., 59 Temple Place - Suite 330, 30 Inc., 59 Temple Place - Suite 330,
31 Boston, MA 02111-1307, USA. 31 Boston, MA 02111-1307, USA.
32 32
33*/ 33*/
34 34
35 35
36#include <qwidget.h> 36#include <qwidget.h>