SCUMM: Prefer getBasePtr over direct Surface::pixels access.

This commit is contained in:
Johannes Schickel 2013-08-02 22:23:00 +02:00
parent 4790a4abd5
commit c05cb7f3bb
11 changed files with 35 additions and 27 deletions

View File

@ -994,7 +994,7 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) {
if (_draw_bottom < rect.bottom)
_draw_bottom = rect.bottom;
v1.destptr = (byte *)_out.pixels + v1.y * _out.pitch + v1.x * _vm->_bytesPerPixel;
v1.destptr = (byte *)_out.getBasePtr(v1.x, v1.y);
codec1_genericDecode(v1);
@ -1288,7 +1288,7 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) {
int32 numskip_before = skip_x + (skip_y * _width);
int32 numskip_after = _width - cur_x;
byte *dst = (byte *)_out.pixels + height_unk * _out.pitch + width_unk * _vm->_bytesPerPixel;
byte *dst = (byte *)_out.getBasePtr(width_unk, height_unk);
akos16Decompress(dst, _out.pitch, _srcptr, cur_x, out_height, dir, numskip_before, numskip_after, transparency, clip.left, clip.top, _zbuf);
return 0;
@ -1358,7 +1358,7 @@ byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) {
palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768;
}
byte *dstPtr = (byte *)_out.pixels + dst.top * _out.pitch + dst.left * _vm->_bytesPerPixel;
byte *dstPtr = (byte *)_out.getBasePtr(dst.left, dst.top);
if (_shadow_mode == 3) {
Wiz::decompressWizImage<kWizXMap>(dstPtr, _out.pitch, kDstScreen, _srcptr, src, 0, palPtr, xmap, _vm->_bytesPerPixel);
} else {

View File

@ -38,7 +38,7 @@ byte BaseCostumeRenderer::drawCostume(const VirtScreen &vs, int numStrips, const
_actorX += _vm->_virtscr[kMainVirtScreen].xstart & 7;
_out.w = _out.pitch / _vm->_bytesPerPixel;
_out.pixels = (byte *)_out.pixels - (_vm->_virtscr[kMainVirtScreen].xstart & 7);
_out.pixels = (byte *)_out.getBasePtr(-(_vm->_virtscr[kMainVirtScreen].xstart & 7), 0);
_numStrips = numStrips;

View File

@ -231,7 +231,10 @@ void drawBomp(const BompDrawData &bd) {
}
src = bd.src;
dst = (byte *)bd.dst.pixels + bd.y * bd.dst.pitch + (bd.x + clip.left);
// FIXME: This gets passed a const destination Surface. Intuitively this
// should never get written to. But sadly it does... For now we simply
// cast the const qualifier away.
dst = (byte *)const_cast<void *>(bd.dst.getBasePtr((bd.x + clip.left), bd.y));
const byte maskbit = revBitMask((bd.x + clip.left) & 7);

View File

@ -799,7 +799,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
if (ignoreCharsetMask || !vs->hasTwoBuffers) {
dstPtr = vs->getPixels(0, 0);
} else {
dstPtr = (byte *)_vm->_textSurface.pixels;
dstPtr = (byte *)_vm->_textSurface.getBasePtr(0, 0);
}
if (_blitAlso && vs->hasTwoBuffers) {
@ -829,7 +829,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr,
dstPtr = vs->getPixels(_left, drawTop);
} else {
dstSurface = _vm->_textSurface;
dstPtr = (byte *)_vm->_textSurface.pixels + (_top - _vm->_screenTop) * _vm->_textSurface.pitch * _vm->_textSurfaceMultiplier + _left * _vm->_textSurfaceMultiplier;
dstPtr = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, (_top - _vm->_screenTop) * _vm->_textSurfaceMultiplier);
}
if (_blitAlso && vs->hasTwoBuffers) {
@ -907,7 +907,7 @@ bool CharsetRendererClassic::prepareDraw(uint16 chr) {
void CharsetRendererClassic::drawChar(int chr, Graphics::Surface &s, int x, int y) {
if (!prepareDraw(chr))
return;
byte *dst = (byte *)s.pixels + y * s.pitch + x;
byte *dst = (byte *)s.getBasePtr(x, y);
drawBitsN(s, dst, _charPtr, *_fontPtr, y, _width, _height);
}
@ -1242,7 +1242,6 @@ void CharsetRendererNut::printChar(int chr, bool ignoreCharsetMask) {
if (ignoreCharsetMask) {
VirtScreen *vs = &_vm->_virtscr[kMainVirtScreen];
s = *vs;
s.pixels = vs->getPixels(0, 0);
} else {
s = _vm->_textSurface;
drawTop -= _vm->_screenTop;
@ -1401,7 +1400,7 @@ void CharsetRendererTownsClassic::drawBitsN(const Graphics::Surface&, byte *dst,
}
bool scale2x = (_vm->_textSurfaceMultiplier == 2);
dst = (byte *)_vm->_textSurface.pixels + (_top - _vm->_screenTop) * _vm->_textSurface.pitch * _vm->_textSurfaceMultiplier + _left * _vm->_textSurfaceMultiplier;
dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, (_top - _vm->_screenTop) * _vm->_textSurfaceMultiplier);
int y, x;
int color;

View File

@ -293,7 +293,7 @@ byte ClassicCostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) {
return 2;
}
v1.destptr = (byte *)_out.pixels + v1.y * _out.pitch + v1.x * _vm->_bytesPerPixel;
v1.destptr = (byte *)_out.getBasePtr(v1.x, v1.y);
v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf);
@ -826,7 +826,7 @@ byte NESCostumeRenderer::drawLimb(const Actor *a, int limb) {
int my = _actorY + y + ty;
int mx = _actorX + x + tx;
if (!(_zbuf && (maskBuf[my * _numStrips + mx / 8] & revBitMask(mx & 7))))
*((byte *)_out.pixels + my * _out.pitch + mx) = palette[c];
*((byte *)_out.getBasePtr(mx, my)) = palette[c];
}
}
}
@ -1238,7 +1238,7 @@ byte V0CostumeRenderer::drawLimb(const Actor *a, int limb) {
int destY = ypos + y;
if (destY >= 0 && destY < _out.h && destX >= 0 && destX < _out.w) {
byte *dst = (byte *)_out.pixels + destY * _out.pitch + destX;
byte *dst = (byte *)_out.getBasePtr(destX, destY);
byte *mask = _vm->getMaskBuffer(0, destY, _zbuf);
if (a0->_limb_flipped[limb]) {
LINE(0, 0); LINE(2, 2); LINE(4, 4); LINE(6, 6);

View File

@ -139,7 +139,7 @@ void ScummEngine_v6::grabCursor(int x, int y, int w, int h) {
return;
}
setCursorFromBuffer((byte *)vs->pixels + (y - vs->topline) * vs->pitch + x, w, h, vs->pitch);
setCursorFromBuffer((byte *)vs->getBasePtr(x, y - vs->topline), w, h, vs->pitch);
}
void ScummEngine_v6::setDefaultCursor() {

View File

@ -641,7 +641,7 @@ static void hlineColor(ScummEngine *scumm, int x1, int x2, int y, byte color) {
x2 = right - 1;
ptr = (byte *)vs->pixels + x1 + y * vs->pitch;
ptr = (byte *)vs->getBasePtr(y, x1);
while (x1++ <= x2) {
*ptr++ = color;

View File

@ -422,7 +422,7 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int
_res->createResource(rtBuffer, slot + 1, size);
vs->pixels = getResourceAddress(rtBuffer, slot + 1);
memset(vs->pixels, 0, size); // reset background
memset(vs->getPixels(0, 0), 0, size); // reset background
if (twobufs) {
vs->backBuf = _res->createResource(rtBuffer, slot + 5, size);
@ -612,7 +612,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
// Some paranoia checks
assert(top >= 0 && bottom <= vs->h);
assert(x >= 0 && width <= vs->pitch);
assert(_textSurface.pixels);
assert(_textSurface.getBasePtr(0, 0));
// Perform some clipping
if (width > vs->w - x)
@ -1135,7 +1135,7 @@ void ScummEngine::clearTextSurface() {
_townsScreen->fillLayerRect(1, 0, 0, _textSurface.w, _textSurface.h, 0);
#endif
fill((byte *)_textSurface.pixels, _textSurface.pitch,
fill((byte *)_textSurface.getBasePtr(0, 0), _textSurface.pitch,
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
_game.platform == Common::kPlatformFMTowns ? 0 :
#endif
@ -1590,7 +1590,7 @@ void GdiV2::prepareDrawBitmap(const byte *ptr, VirtScreen *vs,
if (vs->hasTwoBuffers)
dst = vs->backBuf + y * vs->pitch + x * 8;
else
dst = (byte *)vs->pixels + y * vs->pitch + x * 8;
dst = (byte *)vs->getPixels(x * 8, y);
mask_ptr = getMaskBuffer(x, y, 1);
@ -1827,7 +1827,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const
if (vs->hasTwoBuffers)
dstPtr = vs->backBuf + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel);
else
dstPtr = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel);
dstPtr = (byte *)vs->getPixels(x * 8, y);
transpStrip = drawStrip(dstPtr, vs, x, y, width, height, stripnr, smap_ptr);
@ -1836,7 +1836,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const
transpStrip = true;
if (vs->hasTwoBuffers) {
byte *frontBuf = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel);
byte *frontBuf = (byte *)vs->getPixels(x * 8, y);
if (lightsOn)
copy8Col(frontBuf, vs->pitch, dstPtr, height, vs->format.bytesPerPixel);
else
@ -2262,7 +2262,7 @@ void Gdi::resetBackground(int top, int bottom, int strip) {
vs->bdirty[strip] = bottom;
bgbak_ptr = (byte *)vs->backBuf + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->format.bytesPerPixel;
backbuff_ptr = (byte *)vs->pixels + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->format.bytesPerPixel;
backbuff_ptr = (byte *)vs->getPixels((strip + vs->xstart/8) * 8, top);
numLinesToProcess = bottom - top;
if (numLinesToProcess) {

View File

@ -34,7 +34,7 @@ void ScummEngine::towns_drawStripToScreen(VirtScreen *vs, int dstX, int dstY, in
if (width <= 0 || height <= 0)
return;
assert(_textSurface.pixels);
assert(_textSurface.getBasePtr(0, 0));
int m = _textSurfaceMultiplier;

View File

@ -90,7 +90,7 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint
if (!surface)
return;
byte *src = (byte *)surface->pixels;
const byte *src = (const byte *)surface->getBasePtr(0, 0);
if (_video->hasDirtyPalette())
_vm->setPaletteFromPtr(_video->getPalette(), 256);
@ -119,7 +119,7 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint
dst += y * pitch + x * 2;
do {
for (uint i = 0; i < w; i++) {
uint16 color = *((uint16 *)src + i);
uint16 color = *((const uint16 *)src + i);
switch (dstType) {
case kDstScreen:
WRITE_UINT16(dst + i * 2, color);

View File

@ -357,7 +357,10 @@ void NutRenderer::drawFrame(byte *dst, int c, int x, int y) {
}
void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color) {
byte *dst = (byte *)s.pixels + y * s.pitch + x;
// FIXME: This gets passed a const destination Surface. Intuitively this
// should never get written to. But sadly it does... For now we simply
// cast the const qualifier away.
byte *dst = (byte *)const_cast<void *>(s.getBasePtr(x, y));
const int width = MIN((int)_chars[c].width, s.w - x);
const int height = MIN((int)_chars[c].height, s.h - y);
const byte *src = unpackChar(c);
@ -391,7 +394,10 @@ void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byt
}
void NutRenderer::draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color) {
byte *dst = (byte *)s.pixels + y * s.pitch + x;
// FIXME: This gets passed a const destination Surface. Intuitively this
// should never get written to. But sadly it does... For now we simply
// cast the const qualifier away.
byte *dst = (byte *)const_cast<void *>(s.getBasePtr(x, y));
const int width = _vm->_2byteWidth;
const int height = MIN(_vm->_2byteHeight, s.h - y);
const byte *src = _vm->get2byteCharPtr(c);