removed Blitter class
svn-id: r6804
This commit is contained in:
parent
27199bc83a
commit
9c52f6033f
13 changed files with 22 additions and 348 deletions
|
@ -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();
|
||||
}
|
|
@ -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
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
class Codec1Decoder : public Decoder {
|
||||
public:
|
||||
virtual ~Codec1Decoder();
|
||||
bool decode(Blitter &, Chunk &);
|
||||
bool decode(byte *dst, Chunk &);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include "brenderer.h"
|
||||
#include "common/util.h"
|
||||
#include "blitter.h"
|
||||
|
||||
/*! @brief ::renderer implementation specifically designed for font files.
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue