summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-18 16:43:47 (UTC)
committer zecke <zecke>2004-09-18 16:43:47 (UTC)
commitc81e90d0f6c0feec1443d711833ea382a1c10ec6 (patch) (side-by-side diff)
tree7390346761cfbceee0abccb51a80e30898f54f3b
parentfa5c8471c3053dfc8d9742426faa569b3aa03d71 (diff)
downloadopie-c81e90d0f6c0feec1443d711833ea382a1c10ec6.zip
opie-c81e90d0f6c0feec1443d711833ea382a1c10ec6.tar.gz
opie-c81e90d0f6c0feec1443d711833ea382a1c10ec6.tar.bz2
A proposal for making the memory copy functions build with g++3.4.2.
Please review the patch, specially the casts it makes, and also the boundaries and sizes. -Shouldn't we use unsigned char* instead of char*. For arm it is already unsigned? -Check again the casts
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp66
1 files changed, 47 insertions, 19 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index b55750a..15c611f 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -1,129 +1,157 @@
/*
                This file is part of the Opie Project
Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qimage.h>
#include <qdirectpainter_qws.h>
#include <qgfx_qws.h>
#include <qsize.h>
#include <qapplication.h>
#include <qpe/resource.h>
#include "xinevideowidget.h"
// 0 deg rot: copy a line from src to dst (use libc memcpy)
// 180 deg rot: copy a line from src to dst reversed
-static inline void memcpy_rev ( void *dst, void *src, size_t len )
+/*
+ * This code relies the len be a multiply of 16bit
+ */
+static inline void memcpy_rev ( void *_dst, void *_src, size_t len )
{
- len >>= 1;
-
- ((char *) src ) += ( len << 1 );
+ /*
+ * move the source to the end
+ */
+ char *src_c = static_cast<char*>(_src) + len;
+
+ /*
+ * as we copy by 16bit and not 8bit
+ * devide the length by two
+ */
+ len >>= 1;
+
+ short int* dst = static_cast<short int*>( _dst );
+ short int* src = reinterpret_cast<short int*>( src_c );
+
+ /*
+ * Increment dst after assigning
+ * Decrement src before assigning becase we move backwards
+ */
+ while ( len-- )
+ *dst++ = *--src;
- while ( len-- )
- *((short int *) dst )++ = *--((short int *) src );
}
// 90 deg rot: copy a column from src to dst
-static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
+static inline void memcpy_step ( void *_dst, void *_src, size_t len, size_t step )
{
- len >>= 1;
- while ( len-- ) {
- *((short int *) dst )++ = *((short int *) src );
- ((char *) src ) += step;
- }
+ short int *dst = static_cast<short int*>( _dst );
+ short int *src = static_cast<short int*>( _src );
+
+ len >>= 1;
+
+ /*
+ * Copy 16bit from src to dst and move to the next address
+ */
+ while ( len-- ) {
+ *dst++ = *src;
+ src = reinterpret_cast<short int*>(reinterpret_cast<char*>(src)+step);
+ }
}
// 270 deg rot: copy a column from src to dst reversed
-static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step )
+static inline void memcpy_step_rev ( void *_dst, void *_src, size_t len, size_t step )
{
- len >>= 1;
+ len >>= 1;
- ((char *) src ) += ( len * step );
+ char *src_c = static_cast<char*>( _src ) + (len*step);
+ short int* dst = static_cast<short int*>( _dst );
+ short int* src = reinterpret_cast<short int*>( src_c );
- while ( len-- ) {
- ((char *) src ) -= step;
- *((short int *) dst )++ = *((short int *) src );
- }
+ while ( len-- ) {
+ src_c -= step;
+ src = reinterpret_cast<short int*>( src_c );
+ *dst++ = *src;
+ }
}
XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name )
: QWidget ( parent, name, WRepaintNoErase | WResizeNoErase )
{
setBackgroundMode ( NoBackground );
m_logo = 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_logo;
}
void XineVideoWidget::clear ( )
{
m_buff = 0;
repaint ( false );
}
QSize XineVideoWidget::videoSize() const
{
QSize s = size();
bool fs = ( s == qApp->desktop()->size() );
// if we are in fullscreen mode, do not rotate the video
// (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!)
m_rotation = fs ? - qt_screen->transformOrientation() : 0;
if ( fs && qt_screen->isTransformed() )
s = qt_screen->mapToDevice( s );
return s;
}
void XineVideoWidget::paintEvent ( QPaintEvent * )
{
if ( m_buff == 0 ) {
QPainter p ( this );
p. fillRect ( rect ( ), black );
if ( m_logo )