Skip to content

Commit

Permalink
PARALLACTION: Take advantage of Surface::getPixels.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schickel committed Aug 3, 2013
1 parent 2c62980 commit ccaf4d8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions engines/parallaction/disk_br.cpp
Expand Up @@ -225,7 +225,7 @@ void DosDisk_br::loadBitmap(Common::SeekableReadStream &stream, Graphics::Surfac
}

surf.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
stream.read(surf.getBasePtr(0, 0), width * height);
stream.read(surf.getPixels(), width * height);
}

Frames* DosDisk_br::loadPointer(const char *name) {
Expand Down Expand Up @@ -449,7 +449,7 @@ void AmigaDisk_br::init() {

void AmigaDisk_br::adjustForPalette(Graphics::Surface &surf, int transparentColor) {
uint size = surf.w * surf.h;
byte *data = (byte *)surf.getBasePtr(0, 0);
byte *data = (byte *)surf.getPixels();
for (uint i = 0; i < size; i++, data++) {
if (transparentColor == -1 || transparentColor != *data)
*data += 16;
Expand Down Expand Up @@ -552,7 +552,7 @@ MaskBuffer *AmigaDisk_br::loadMask(const char *name, uint32 w, uint32 h) {
MaskBuffer *buffer = new MaskBuffer;
// surface width was shrunk to 1/4th of the bitmap width due to the pixel packing
buffer->create(decoder.getSurface()->w * 4, decoder.getSurface()->h);
memcpy(buffer->data, decoder.getSurface()->getBasePtr(0, 0), buffer->size);
memcpy(buffer->data, decoder.getSurface()->getPixels(), buffer->size);
buffer->bigEndian = true;
finalpass(buffer->data, buffer->size);
return buffer;
Expand Down Expand Up @@ -612,7 +612,7 @@ GfxObj* AmigaDisk_br::loadStatic(const char* name) {
stream->read(shadow, shadowSize);
for (int32 i = 0; i < surf->h; ++i) {
byte *src = shadow + shadowWidth * i;
byte *dst = (byte *)surf->getBasePtr(0, 0) + surf->pitch * i;
byte *dst = (byte *)surf->getPixels() + surf->pitch * i;

for (int32 j = 0; j < surf->w; ++j, ++dst) {
byte bit = src[j/8] & (1 << (7 - (j & 7)));
Expand Down
6 changes: 3 additions & 3 deletions engines/parallaction/disk_ns.cpp
Expand Up @@ -482,7 +482,7 @@ void DosDisk_ns::loadBackground(BackgroundInfo& info, const char *filename) {
// read bitmap, mask and path data and extract them into the 3 buffers
info.bg.create(info.width, info.height, Graphics::PixelFormat::createFormatCLUT8());
createMaskAndPathBuffers(info);
unpackBackground(stream, (byte *)info.bg.getBasePtr(0, 0), info._mask->data, info._path->data);
unpackBackground(stream, (byte *)info.bg.getPixels(), info._mask->data, info._path->data);

delete stream;
}
Expand Down Expand Up @@ -976,7 +976,7 @@ void AmigaDisk_ns::loadMask_internal(BackgroundInfo& info, const char *name) {
info._mask = new MaskBuffer;
// surface width was shrunk to 1/4th of the bitmap width due to the pixel packing
info._mask->create(decoder.getSurface()->w * 4, decoder.getSurface()->h);
memcpy(info._mask->data, decoder.getSurface()->getBasePtr(0, 0), info._mask->size);
memcpy(info._mask->data, decoder.getSurface()->getPixels(), info._mask->size);
info._mask->bigEndian = true;
}

Expand All @@ -998,7 +998,7 @@ void AmigaDisk_ns::loadPath_internal(BackgroundInfo& info, const char *name) {
info._path = new PathBuffer;
// surface width was shrunk to 1/8th of the bitmap width due to the pixel packing
info._path->create(decoder.getSurface()->w * 8, decoder.getSurface()->h);
memcpy(info._path->data, decoder.getSurface()->getBasePtr(0, 0), info._path->size);
memcpy(info._path->data, decoder.getSurface()->getPixels(), info._path->size);
info._path->bigEndian = true;
}

Expand Down
12 changes: 6 additions & 6 deletions engines/parallaction/graphics.cpp
Expand Up @@ -332,7 +332,7 @@ void Gfx::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int

void Gfx::clearScreen() {
if (_doubleBuffering) {
if (_backBuffer.getBasePtr(0, 0)) {
if (_backBuffer.getPixels()) {
Common::Rect r(_backBuffer.w, _backBuffer.h);
_backBuffer.fillRect(r, 0);
}
Expand Down Expand Up @@ -419,13 +419,13 @@ void Gfx::updateScreen() {
// is needed
_overlayMode = false;

bool skipBackground = (_backgroundInfo->bg.getBasePtr(0, 0) == 0); // don't render frame if background is missing
bool skipBackground = (_backgroundInfo->bg.getPixels() == 0); // don't render frame if background is missing

if (!skipBackground) {
// background may not cover the whole screen, so adjust bulk update size
uint w = _backgroundInfo->width;
uint h = _backgroundInfo->height;
byte *backgroundData = (byte *)_backgroundInfo->bg.getBasePtr(0, 0);
byte *backgroundData = (byte *)_backgroundInfo->bg.getPixels();
uint16 backgroundPitch = _backgroundInfo->bg.pitch;
copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo->_x, _backgroundInfo->_y, w, h);
}
Expand All @@ -450,7 +450,7 @@ void Gfx::applyHalfbriteEffect_NS(Graphics::Surface &surf) {
return;
}

byte *buf = (byte *)surf.getBasePtr(0, 0);
byte *buf = (byte *)surf.getPixels();
for (int i = 0; i < surf.w*surf.h; i++) {
*buf++ |= 0x20;
}
Expand Down Expand Up @@ -493,7 +493,7 @@ void Gfx::patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask)
r.moveTo(x, y);

uint16 z = (mask) ? _backgroundInfo->getMaskLayer(y) : LAYER_FOREGROUND;
blt(r, (byte *)surf.getBasePtr(0, 0), &_backgroundInfo->bg, z, 100, 0);
blt(r, (byte *)surf.getPixels(), &_backgroundInfo->bg, z, 100, 0);
}

void Gfx::fillBackground(const Common::Rect& r, byte color) {
Expand Down Expand Up @@ -704,7 +704,7 @@ void Gfx::unregisterLabel(GfxObj *label) {
void Gfx::copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surface &dst) {

byte *s = (byte *)src.getBasePtr(r.left, r.top);
byte *d = (byte *)dst.getBasePtr(0, 0);
byte *d = (byte *)dst.getPixels();

for (uint16 i = 0; i < r.height(); i++) {
memcpy(d, s, r.width());
Expand Down
2 changes: 1 addition & 1 deletion engines/parallaction/input.cpp
Expand Up @@ -499,7 +499,7 @@ void Input::initCursors() {
// TODO: scale mouse cursor (see staticres.cpp)
Graphics::Surface *surf2 = new Graphics::Surface;
surf2->create(32, 16, Graphics::PixelFormat::createFormatCLUT8());
memcpy(surf2->getBasePtr(0, 0), _resMouseArrow_BR_Amiga, 32*16);
memcpy(surf2->getPixels(), _resMouseArrow_BR_Amiga, 32*16);
_mouseArrow = new SurfaceToFrames(surf2);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion engines/parallaction/inventory.h
Expand Up @@ -108,7 +108,7 @@ class InventoryRenderer {
void highlightItem(ItemPosition pos, byte color);
void drawItem(ItemName name, byte *buffer, uint pitch);

byte *getData() { return (byte *)_surf.getBasePtr(0, 0); }
byte *getData() { return (byte *)_surf.getPixels(); }

void getRect(Common::Rect &r) const;
int16 getNumLines() const;
Expand Down

0 comments on commit ccaf4d8

Please sign in to comment.