aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-03-13 00:37:03 +0000
committerMax Horn2003-03-13 00:37:03 +0000
commit9c52f6033f18f55bc583c4ad4760b13c6c50fd95 (patch)
treef2452907d5064a8035f405bc25013a20bb4cb279 /scumm
parent27199bc83af8ba6010d2bea9f3a355c566967774 (diff)
downloadscummvm-rg350-9c52f6033f18f55bc583c4ad4760b13c6c50fd95.tar.gz
scummvm-rg350-9c52f6033f18f55bc583c4ad4760b13c6c50fd95.tar.bz2
scummvm-rg350-9c52f6033f18f55bc583c4ad4760b13c6c50fd95.zip
removed Blitter class
svn-id: r6804
Diffstat (limited to 'scumm')
-rw-r--r--scumm/smush/blitter.cpp235
-rw-r--r--scumm/smush/blitter.h83
-rw-r--r--scumm/smush/codec1.cpp20
-rw-r--r--scumm/smush/codec1.h2
-rw-r--r--scumm/smush/codec37.cpp5
-rw-r--r--scumm/smush/codec37.h2
-rw-r--r--scumm/smush/codec44.cpp5
-rw-r--r--scumm/smush/codec44.h2
-rw-r--r--scumm/smush/codec47.cpp5
-rw-r--r--scumm/smush/codec47.h2
-rw-r--r--scumm/smush/decoder.h2
-rw-r--r--scumm/smush/frenderer.h1
-rw-r--r--scumm/smush/player.cpp6
13 files changed, 22 insertions, 348 deletions
diff --git a/scumm/smush/blitter.cpp b/scumm/smush/blitter.cpp
deleted file mode 100644
index 1318a60f79..0000000000
--- a/scumm/smush/blitter.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2002-2003 The ScummVM project
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Header$
- *
- */
-
-#include "stdafx.h"
-#include "common/util.h"
-#include "blitter.h"
-#include "chunk.h"
-
-#include <assert.h>
-#include <string.h> // for memcpy
-
-Blitter::Blitter(byte *ptr, const Point &dstsize, const Rect &src) :
- _ptr(ptr),
- _clip(dstsize),
- _src(src),
- _cur(src.left(), src.top()),
- _outside(false) {
-#ifdef DEBUG_CLIPPER
- _clipped = 0;
- _clippedBlock = 0;
-#endif
- assert(_ptr);
- assert(_clip.getX() > 0 && _clip.getY() > 0);
- assert(_src.width() > 0 && _src.height() > 0);
- assert(_src.left() < _clip.getX() && _src.right() <= _clip.getX());
- assert(_src.top() < _clip.getY() && _src.bottom() <= _clip.getY());
- _offset = _ptr + _clip.getX() * _cur.getY() + _cur.getX();
-}
-
-Blitter::~Blitter() {
-#ifdef DEBUG_CLIPPER
- if(_clipped || _clippedBlock) {
- debug(3, "blitter clipped %d pixels and %d blocks", _clipped, _clippedBlock);
- }
-#endif
-}
-
-void Blitter::advance(int32 x, int32 y) {
- if(y != 0) {
- _cur.set(_src.left() + x, _cur.getY() + y);
- } else {
- _cur.getX() += x;
- if(_cur.getX() >= _src.right()) {
- _cur.set(_src.left(), _cur.getY()+1);
- }
- }
- _offset = _ptr + _clip.getX() * _cur.getY() + _cur.getX();
- _outside = ! _src.isInside(_cur);
-}
-
-void Blitter::advanceBlock(int32 x, int32 y) {
- advance(x * 4, y * 4);
-}
-
-void Blitter::put(byte data) {
- if(!_outside) {
- *_offset = data;
- advance();
- }
-#ifdef DEBUG_CLIPPER
- else _clipped++;
-#endif
-}
-
-void Blitter::put(byte data, uint32 len) {
- while(len) {
- if(_outside) {
-#ifdef DEBUG_CLIPPER
- _clipped += len;
-#endif
- break;
- }
- int32 l = MIN((int32)len, MIN(_clip.getX() - _cur.getX(), _src.right() - _cur.getX()));
- len -= l;
- memset(_offset, data, l);
- advance(l);
- }
-}
-
-void Blitter::blit(byte *ptr, uint32 len) {
- while(len) {
- if(_outside) {
-#ifdef DEBUG_CLIPPER
- _clipped += len;
-#endif
- break;
- }
- int32 l = MIN((int32)len, MIN(_clip.getX() - _cur.getX(), _src.right() - _cur.getX()));
- len -= l;
- memcpy(_offset, ptr, l);
- ptr += l;
- advance(l);
- }
-}
-
-void Blitter::blit(Chunk &src, uint32 len) {
- while(len) {
- if(_outside) {
-#ifdef DEBUG_CLIPPER
- _clipped += len;
-#endif
- break;
- }
- int32 l = MIN((int32)len, MIN(_clip.getX() -_cur.getX(), _src.right() - _cur.getX()));
- len -= l;
- src.read(_offset, l);
- advance(l);
- }
-}
-
-void Blitter::putBlock(uint32 data) {
- if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
- assert((_clip.getX() & 3) == 0);
- uint32 *dst = (uint32 *)_offset;
- int32 line_size = _clip.getX() >> 2;
- data = TO_LE_32(data);
-
- *dst = data; dst += line_size;
- *dst = data; dst += line_size;
- *dst = data; dst += line_size;
- *dst = data;
-
-#ifdef DEBUG_CLIPPER
- } else {
- _clippedBlock ++;
-#endif
- }
- advanceBlock();
-}
-
-void Blitter::putBlock(uint32 d1, uint32 d2, uint32 d3, uint32 d4) {
- if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
- assert((_clip.getX() & 3) == 0);
- uint32 *dst = (uint32 *)_offset;
- int32 line_size = _clip.getX() >> 2;
-
- *dst = TO_LE_32(d4); dst += line_size;
- *dst = TO_LE_32(d3); dst += line_size;
- *dst = TO_LE_32(d2); dst += line_size;
- *dst = TO_LE_32(d1);
-
-#ifdef DEBUG_CLIPPER
- } else {
- _clippedBlock++;
-#endif
- }
- advanceBlock();
-}
-
-void Blitter::putBlock(byte *data) {
- if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
- assert((_clip.getX() & 3) == 0);
- uint32 *dst = (uint32 *)_offset;
- int32 line_size = _clip.getX() >> 2;
- uint32 *src = (uint32 *)data;
- *dst = TO_LE_32(*src++); dst += line_size;
- *dst = TO_LE_32(*src++); dst += line_size;
- *dst = TO_LE_32(*src++); dst += line_size;
- *dst = TO_LE_32(*src++);
-#ifdef DEBUG_CLIPPER
- } else {
- _clippedBlock++;
-#endif
- }
- advanceBlock();
-}
-
-void Blitter::putBlock(Chunk &src) {
- if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
- assert((_clip.getX() & 3) == 0);
- uint32 *dst = (uint32 *)_offset;
- int32 line_size = _clip.getX() >> 2;
- *dst = TO_LE_32(src.getDword()); dst += line_size;
- *dst = TO_LE_32(src.getDword()); dst += line_size;
- *dst = TO_LE_32(src.getDword()); dst += line_size;
- *dst = TO_LE_32(src.getDword());
-#ifdef DEBUG_CLIPPER
- } else {
- _clippedBlock++;
-#endif
- }
- advanceBlock();
-}
-
-void Blitter::blockCopy(int32 offset) {
- if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) {// This is clipping
- byte * dst = _offset;
-#if defined(SCUMM_NEED_ALIGNMENT)
- memcpy(dst, dst + offset, sizeof(uint32));
-#else
- *((uint32 *)dst) = *((uint32 *)(dst + offset));
-#endif
- dst += _clip.getX();
-#if defined(SCUMM_NEED_ALIGNMENT)
- memcpy(dst, dst + offset, sizeof(uint32));
-#else
- *((uint32 *)dst) = *((uint32 *)(dst + offset));
-#endif
- dst += _clip.getX();
-#if defined(SCUMM_NEED_ALIGNMENT)
- memcpy(dst, dst + offset, sizeof(uint32));
-#else
- *((uint32 *)dst) = *((uint32 *)(dst + offset));
-#endif
- dst += _clip.getX();
-#if defined(SCUMM_NEED_ALIGNMENT)
- memcpy(dst, dst + offset, sizeof(uint32));
-#else
- *((uint32 *)dst) = *((uint32 *)(dst + offset));
-#endif
-#ifdef DEBUG_CLIPPER
- } else {
- _clippedBlock++;
-#endif
- }
- advanceBlock();
-}
diff --git a/scumm/smush/blitter.h b/scumm/smush/blitter.h
deleted file mode 100644
index 6db4f3a496..0000000000
--- a/scumm/smush/blitter.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2002-2003 The ScummVM project
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * 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 General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Header$
- *
- */
-
-#ifndef BLITTER_H
-#define BLITTER_H
-
-#include "config.h"
-
-#ifdef DEBUG
-# ifndef NO_DEBUG_CLIPPER
-# define DEBUG_CLIPPER
-# endif
-#else
-# ifdef DEBUG_CLIPPER
-# error DEBUG_CLIPPER defined without DEBUG
-# endif
-#endif
-
-#include "common/rect.h"
-
-using ScummVM::Point;
-using ScummVM::Rect;
-
-class Chunk;
-/*! @brief class for handling blitting on a frame buffer
-
- This class allows to perform secure blitting to a frame buffer in several ways.
- This means that clipping is performed, so that only the part that you want to modify can be modified.
-*/
-class Blitter {
-private:
- byte *_ptr; //!< This is the pointer to the start of the frame buffer
- byte *_offset; //!< This is the current pointer in the frame buffer
- Point _clip; //!< This is the size of the frame buffer (width/height)
- Rect _src; //!< This is the size and position of the destination rectangle
- Point _cur; //!< This is the current position in the destination rectangle
- bool _outside; //!< flag that is set to \c true when the blitter reach the end of the destination rectangle
-#ifdef DEBUG_CLIPPER
- int32 _clipped;
- int32 _clippedBlock;
-#endif
-public:
- /*! @brief constructor
-
- @param buffer the frame buffer to blit to
- @param dstsize the size of the frame buffer
- @param src the rectangle to blit to
- */
- Blitter(byte * buffer, const Point & dstsize, const Rect & src);
- virtual ~Blitter();
- void blit(byte *, uint32); //!< This method allows to blit directly some data from a buffer
- void blit(Chunk &, uint32); //!< This method allows to blit directly some data from a Chunk
- void put(byte); //!< This method allows to blit one byte
- void put(byte, uint32); //!< This method allows to blit one byte several times
- void advance(int32 = 1, int32 = 0); //!< This method allows to advance the current position in the blitter
- void advanceBlock(int32 = 1, int32 = 0); //!< This method allows to advance the current position in the blitter in terms of blocks
- void putBlock(uint32); //!< This method allows to blit one block from an int32 value repeated 4 time
- void putBlock(Chunk &); //!< This method allows to blit one block directly read from a Chunk
- void putBlock(byte *); //!< This method allows to blit one block directly from a buffer
- void putBlock(uint32, uint32, uint32, uint32); //!< This method allows to blit one block from a 4 int32 value
- void blockCopy(int32); //!< This method allows to copy one block from another separated by the given offset
- byte *getPtr() { return _ptr; }
-};
-
-#endif
diff --git a/scumm/smush/codec1.cpp b/scumm/smush/codec1.cpp
index 374d2440dd..2a2d340a1e 100644
--- a/scumm/smush/codec1.cpp
+++ b/scumm/smush/codec1.cpp
@@ -22,12 +22,11 @@
#include <stdafx.h>
#include "codec1.h"
#include "chunk.h"
-#include "blitter.h"
Codec1Decoder::~Codec1Decoder() {
}
-bool Codec1Decoder::decode(Blitter &dst, Chunk &src) {
+bool Codec1Decoder::decode(byte *dst, Chunk &src) {
byte val;
int32 size_line;
int32 code, length;
@@ -40,18 +39,17 @@ bool Codec1Decoder::decode(Blitter &dst, Chunk &src) {
#endif
while(size_line > 0) {
code = src.getByte();
- size_line --;
+ size_line--;
length = (code >> 1) + 1;
#ifdef DEBUG_CODEC1
debug(7, "codec1 : length == %d", length);
#endif
if(code & 1) {
val = src.getByte();
- size_line --;
- if(val)
- dst.put(val, length);
- else
- dst.advance(length);
+ size_line--;
+ if (val)
+ memset(dst, val, length);
+ dst += length;
#ifdef DEBUG_CODEC1
debug(7, "codec1 : blitting %d times %d", length, val);
#endif
@@ -62,9 +60,9 @@ bool Codec1Decoder::decode(Blitter &dst, Chunk &src) {
#endif
while(length--) {
val = src.getByte();
- if(val)
- dst.put(val);
- else dst.advance();
+ if (val)
+ *dst = val;
+ dst++;
}
}
}
diff --git a/scumm/smush/codec1.h b/scumm/smush/codec1.h
index c3509ad5ed..c9e022f132 100644
--- a/scumm/smush/codec1.h
+++ b/scumm/smush/codec1.h
@@ -42,7 +42,7 @@
class Codec1Decoder : public Decoder {
public:
virtual ~Codec1Decoder();
- bool decode(Blitter &, Chunk &);
+ bool decode(byte *dst, Chunk &);
};
#endif
diff --git a/scumm/smush/codec37.cpp b/scumm/smush/codec37.cpp
index 4eeabea1e4..fd6be122c3 100644
--- a/scumm/smush/codec37.cpp
+++ b/scumm/smush/codec37.cpp
@@ -22,7 +22,6 @@
#include <stdafx.h>
#include "codec37.h"
#include "chunk.h"
-#include "blitter.h"
#include "common/engine.h"
@@ -474,7 +473,7 @@ void Codec37Decoder::proc4WithoutFDFE(byte *dst, byte *src, int32 next_offs, int
} while (--bh);
}
-bool Codec37Decoder::decode(Blitter & dst, Chunk & src) {
+bool Codec37Decoder::decode(byte *dst, Chunk & src) {
int32 width = getRect().width();
int32 height = getRect().height();
int32 bw = (width + 3) >> 2, bh = (height + 3) >> 2;
@@ -549,7 +548,7 @@ bool Codec37Decoder::decode(Blitter & dst, Chunk & src) {
}
_prevSeqNb = seq_nb;
- dst.blit(_deltaBufs[_curtable], width * height);
+ memcpy(dst, _deltaBufs[_curtable], width * height);
free(chunk_buffer);
return true;
diff --git a/scumm/smush/codec37.h b/scumm/smush/codec37.h
index 5f87248d17..d145684b52 100644
--- a/scumm/smush/codec37.h
+++ b/scumm/smush/codec37.h
@@ -48,7 +48,7 @@ protected:
void proc4WithFDFE(byte *, byte *, int32, int32, int32, int32, int16 *);
void proc4WithoutFDFE(byte *, byte *, int32, int32, int32, int32, int16 *);
public:
- bool decode(Blitter &, Chunk &);
+ bool decode(byte *dst, Chunk &);
};
#endif
diff --git a/scumm/smush/codec44.cpp b/scumm/smush/codec44.cpp
index 1fa1307c55..d49041fe05 100644
--- a/scumm/smush/codec44.cpp
+++ b/scumm/smush/codec44.cpp
@@ -22,9 +22,8 @@
#include <stdafx.h>
#include "codec44.h"
#include "chunk.h"
-#include "blitter.h"
-bool Codec44Decoder::decode(Blitter & dst, Chunk & src) {
+bool Codec44Decoder::decode(byte *dst, Chunk & src) {
int32 size_line, num;
int32 length = src.getSize() - 14;
int32 width = getRect().width();
@@ -61,7 +60,7 @@ bool Codec44Decoder::decode(Blitter & dst, Chunk & src) {
} while (length > 1);
- dst.blit(_buffer, width * height);
+ memcpy(dst, _buffer, width * height);
free(org_src2);
diff --git a/scumm/smush/codec44.h b/scumm/smush/codec44.h
index 67e3ae7c4f..a3dacd279f 100644
--- a/scumm/smush/codec44.h
+++ b/scumm/smush/codec44.h
@@ -28,7 +28,7 @@ class Codec44Decoder : public Decoder {
byte _buffer[1000];
public:
- bool decode(Blitter &dst, Chunk &src);
+ bool decode(byte *dst, Chunk &src);
};
#endif
diff --git a/scumm/smush/codec47.cpp b/scumm/smush/codec47.cpp
index 533eed439a..7c62629cc2 100644
--- a/scumm/smush/codec47.cpp
+++ b/scumm/smush/codec47.cpp
@@ -24,7 +24,6 @@
#include "engine.h"
#include "codec47.h"
#include "chunk.h"
-#include "blitter.h"
static int32 codec37_table[] = {
0, 1, 2, 3, 3, 3,
@@ -664,7 +663,7 @@ Codec47Decoder::~Codec47Decoder() {
clean();
}
-bool Codec47Decoder::decode(Blitter &dst, Chunk &src) {
+bool Codec47Decoder::decode(byte *dst, Chunk &src) {
int32 width = getRect().width();
int32 height = getRect().height();
_offset1 = _deltaBufs[1] - _curBuf;
@@ -713,7 +712,7 @@ bool Codec47Decoder::decode(Blitter &dst, Chunk &src) {
break;
}
- dst.blit(_curBuf, width * height);
+ memcpy(dst, _curBuf, width * height);
if (seq_nb == _prevSeqNb + 1) {
if (chunk_buffer[3] == 1) {
diff --git a/scumm/smush/codec47.h b/scumm/smush/codec47.h
index a73cc53544..0124d2be3f 100644
--- a/scumm/smush/codec47.h
+++ b/scumm/smush/codec47.h
@@ -54,7 +54,7 @@ public:
virtual ~Codec47Decoder();
bool initSize(const Point &, const Rect &);
void clean();
- bool decode(Blitter &, Chunk &);
+ bool decode(byte *dst, Chunk &);
};
#endif
diff --git a/scumm/smush/decoder.h b/scumm/smush/decoder.h
index 466654002b..943324f87a 100644
--- a/scumm/smush/decoder.h
+++ b/scumm/smush/decoder.h
@@ -47,7 +47,7 @@ public:
Decoder() {};
virtual ~Decoder() {};
virtual bool initSize(const Point &p, const Rect &r) { _p = p; _r = r; return true; };
- virtual bool decode(Blitter &, Chunk &) = 0;
+ virtual bool decode(byte *dst, Chunk &src) = 0;
};
#endif
diff --git a/scumm/smush/frenderer.h b/scumm/smush/frenderer.h
index 45db49a8e0..4c62abc629 100644
--- a/scumm/smush/frenderer.h
+++ b/scumm/smush/frenderer.h
@@ -36,7 +36,6 @@
#include "brenderer.h"
#include "common/util.h"
-#include "blitter.h"
/*! @brief ::renderer implementation specifically designed for font files.
diff --git a/scumm/smush/player.cpp b/scumm/smush/player.cpp
index e3526fe11a..63bc931893 100644
--- a/scumm/smush/player.cpp
+++ b/scumm/smush/player.cpp
@@ -33,7 +33,6 @@
#include "frenderer.h"
#include "channel.h"
#include "chunk_type.h"
-#include "blitter.h"
#include <assert.h>
#include <stdlib.h>
@@ -608,8 +607,7 @@ void SmushPlayer::handleNewPalette(Chunk &b) {
void SmushPlayer::decodeCodec(Chunk &b, const Rect &r, Decoder &codec) {
assert(_curBuffer);
- Blitter blit((byte *)_curBuffer, _frameSize, r);
- codec.decode(blit, b);
+ codec.decode((byte *)_curBuffer, b);
if (_storeFrame == true) {
if (_frameBuffer == NULL) {
_frameBuffer = (byte *)malloc(_frameSize.getX() * _frameSize.getY());
@@ -648,7 +646,7 @@ void SmushPlayer::initSize(const Rect &r, bool always, bool transparent) {
_alreadyInit = true;
}
-void SmushPlayer::handleFrameObject(Chunk & b) {
+void SmushPlayer::handleFrameObject(Chunk &b) {
checkBlock(b, TYPE_FOBJ, 14);
if(_skipNext) {
_skipNext = false;