From d82741a3c8b64fc0b167548f65b53181b67959fb Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 3 Aug 2013 00:17:40 +0200 Subject: [PATCH] PARALLACTION: Prefer getBasePtr over direct Surface::pixels access. --- engines/parallaction/disk_br.cpp | 8 ++++---- engines/parallaction/disk_ns.cpp | 6 +++--- engines/parallaction/graphics.cpp | 18 +++++++++--------- engines/parallaction/input.cpp | 2 +- engines/parallaction/inventory.h | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp index 3135c3e8c5aa..dfb8bded87ad 100644 --- a/engines/parallaction/disk_br.cpp +++ b/engines/parallaction/disk_br.cpp @@ -225,7 +225,7 @@ void DosDisk_br::loadBitmap(Common::SeekableReadStream &stream, Graphics::Surfac } surf.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - stream.read(surf.pixels, width * height); + stream.read(surf.getBasePtr(0, 0), width * height); } Frames* DosDisk_br::loadPointer(const char *name) { @@ -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.pixels; + byte *data = (byte *)surf.getBasePtr(0, 0); for (uint i = 0; i < size; i++, data++) { if (transparentColor == -1 || transparentColor != *data) *data += 16; @@ -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()->pixels, buffer->size); + memcpy(buffer->data, decoder.getSurface()->getBasePtr(0, 0), buffer->size); buffer->bigEndian = true; finalpass(buffer->data, buffer->size); return buffer; @@ -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->pixels + surf->pitch * i; + byte *dst = (byte *)surf->getBasePtr(0, 0) + surf->pitch * i; for (int32 j = 0; j < surf->w; ++j, ++dst) { byte bit = src[j/8] & (1 << (7 - (j & 7))); diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp index 4c4893ec61ea..45f7100f80de 100644 --- a/engines/parallaction/disk_ns.cpp +++ b/engines/parallaction/disk_ns.cpp @@ -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.pixels, info._mask->data, info._path->data); + unpackBackground(stream, (byte *)info.bg.getBasePtr(0, 0), info._mask->data, info._path->data); delete stream; } @@ -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()->pixels, info._mask->size); + memcpy(info._mask->data, decoder.getSurface()->getBasePtr(0, 0), info._mask->size); info._mask->bigEndian = true; } @@ -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()->pixels, info._path->size); + memcpy(info._path->data, decoder.getSurface()->getBasePtr(0, 0), info._path->size); info._path->bigEndian = true; } diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index b8a8ceb61fa2..0aaf78ec1351 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -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.pixels) { + if (_backBuffer.getBasePtr(0, 0)) { Common::Rect r(_backBuffer.w, _backBuffer.h); _backBuffer.fillRect(r, 0); } @@ -419,7 +419,7 @@ void Gfx::updateScreen() { // is needed _overlayMode = false; - bool skipBackground = (_backgroundInfo->bg.pixels == 0); // don't render frame if background is missing + bool skipBackground = (_backgroundInfo->bg.getBasePtr(0, 0) == 0); // don't render frame if background is missing if (!skipBackground) { // background may not cover the whole screen, so adjust bulk update size @@ -450,7 +450,7 @@ void Gfx::applyHalfbriteEffect_NS(Graphics::Surface &surf) { return; } - byte *buf = (byte *)surf.pixels; + byte *buf = (byte *)surf.getBasePtr(0, 0); for (int i = 0; i < surf.w*surf.h; i++) { *buf++ |= 0x20; } @@ -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.pixels, &_backgroundInfo->bg, z, 100, 0); + blt(r, (byte *)surf.getBasePtr(0, 0), &_backgroundInfo->bg, z, 100, 0); } void Gfx::fillBackground(const Common::Rect& r, byte color) { @@ -536,12 +536,12 @@ GfxObj *Gfx::renderFloatingLabel(Font *font, char *text) { setupLabelSurface(*cnv, w, h); font->setColor((_gameType == GType_BRA) ? 0 : 7); - font->drawString((byte *)cnv->pixels + 1, cnv->w, text); - font->drawString((byte *)cnv->pixels + 1 + cnv->w * 2, cnv->w, text); - font->drawString((byte *)cnv->pixels + cnv->w, cnv->w, text); - font->drawString((byte *)cnv->pixels + 2 + cnv->w, cnv->w, text); + font->drawString((byte *)cnv->getBasePtr(1, 0), cnv->w, text); + font->drawString((byte *)cnv->getBasePtr(1, 2), cnv->w, text); + font->drawString((byte *)cnv->getBasePtr(0, 1), cnv->w, text); + font->drawString((byte *)cnv->getBasePtr(2, 1), cnv->w, text); font->setColor((_gameType == GType_BRA) ? 11 : 1); - font->drawString((byte *)cnv->pixels + 1 + cnv->w, cnv->w, text); + font->drawString((byte *)cnv->getBasePtr(1, 1), cnv->w, text); } else { w = font->getStringWidth(text); h = font->height(); diff --git a/engines/parallaction/input.cpp b/engines/parallaction/input.cpp index bf7cdc439d63..df7275aaccfc 100644 --- a/engines/parallaction/input.cpp +++ b/engines/parallaction/input.cpp @@ -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->pixels, _resMouseArrow_BR_Amiga, 32*16); + memcpy(surf2->getBasePtr(0, 0), _resMouseArrow_BR_Amiga, 32*16); _mouseArrow = new SurfaceToFrames(surf2); } break; diff --git a/engines/parallaction/inventory.h b/engines/parallaction/inventory.h index a3b7bf953f6d..418d1f7229e4 100644 --- a/engines/parallaction/inventory.h +++ b/engines/parallaction/inventory.h @@ -108,7 +108,7 @@ class InventoryRenderer { void highlightItem(ItemPosition pos, byte color); void drawItem(ItemName name, byte *buffer, uint pitch); - byte* getData() const { return (byte *)_surf.pixels; } + byte *getData() { return (byte *)_surf.getBasePtr(0, 0); } void getRect(Common::Rect &r) const; int16 getNumLines() const;