diff options
author | Johannes Schickel | 2013-08-07 12:24:59 -0700 |
---|---|---|
committer | Johannes Schickel | 2013-08-07 12:24:59 -0700 |
commit | 7f8308e0eb50c4e13ec0684619b5474983a93a66 (patch) | |
tree | 0a057f01385a11d99add1e294f70891a8e8bf6c9 /engines/scumm | |
parent | 6e9390feb8166d5f9d6c6fdfe00a336b4f71de4c (diff) | |
parent | e5f0c42a65f38611272542a144228753e0496493 (diff) | |
download | scummvm-rg350-7f8308e0eb50c4e13ec0684619b5474983a93a66.tar.gz scummvm-rg350-7f8308e0eb50c4e13ec0684619b5474983a93a66.tar.bz2 scummvm-rg350-7f8308e0eb50c4e13ec0684619b5474983a93a66.zip |
Merge pull request #365 from lordhoto/protected-pixels
Make Graphics::Surface::pixels protected.
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/akos.cpp | 6 | ||||
-rw-r--r-- | engines/scumm/base-costume.cpp | 8 | ||||
-rw-r--r-- | engines/scumm/bomp.cpp | 5 | ||||
-rw-r--r-- | engines/scumm/charset.cpp | 10 | ||||
-rw-r--r-- | engines/scumm/costume.cpp | 6 | ||||
-rw-r--r-- | engines/scumm/cursor.cpp | 10 | ||||
-rw-r--r-- | engines/scumm/debugger.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/gfx.cpp | 16 | ||||
-rw-r--r-- | engines/scumm/gfx_towns.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/he/animation_he.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/nut_renderer.cpp | 10 | ||||
-rw-r--r-- | engines/scumm/object.cpp | 2 |
12 files changed, 45 insertions, 36 deletions
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index b6acf01050..481c4af432 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -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 { diff --git a/engines/scumm/base-costume.cpp b/engines/scumm/base-costume.cpp index 46c68c81b0..e1a8688bb9 100644 --- a/engines/scumm/base-costume.cpp +++ b/engines/scumm/base-costume.cpp @@ -32,13 +32,15 @@ byte BaseCostumeRenderer::drawCostume(const VirtScreen &vs, int numStrips, const _out = vs; if (drawToBackBuf) - _out.pixels = vs.getBackPixels(0, 0); + _out.setPixels(vs.getBackPixels(0, 0)); else - _out.pixels = vs.getPixels(0, 0); + _out.setPixels(vs.getPixels(0, 0)); _actorX += _vm->_virtscr[kMainVirtScreen].xstart & 7; _out.w = _out.pitch / _vm->_bytesPerPixel; - _out.pixels = (byte *)_out.pixels - (_vm->_virtscr[kMainVirtScreen].xstart & 7); + // We do not use getBasePtr here because the offset to pixels never used + // _vm->_bytesPerPixel, but it seems unclear why. + _out.setPixels((byte *)_out.getPixels() - (_vm->_virtscr[kMainVirtScreen].xstart & 7)); _numStrips = numStrips; diff --git a/engines/scumm/bomp.cpp b/engines/scumm/bomp.cpp index 845cf70722..5b87f3042c 100644 --- a/engines/scumm/bomp.cpp +++ b/engines/scumm/bomp.cpp @@ -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); diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 9ae75b6683..dd79aff2da 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -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.getPixels(); } 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,7 @@ void CharsetRendererNut::printChar(int chr, bool ignoreCharsetMask) { if (ignoreCharsetMask) { VirtScreen *vs = &_vm->_virtscr[kMainVirtScreen]; s = *vs; - s.pixels = vs->getPixels(0, 0); + s.setPixels(vs->getPixels(0, 0)); } else { s = _vm->_textSurface; drawTop -= _vm->_screenTop; @@ -1401,7 +1401,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; diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp index 4ebdd00fdc..85c60f9a40 100644 --- a/engines/scumm/costume.cpp +++ b/engines/scumm/costume.cpp @@ -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); diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 269ae9e10a..721644b554 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -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() { @@ -417,13 +417,11 @@ void ScummEngine_v5::redefineBuiltinCursorFromChar(int index, int chr) { Graphics::Surface s; byte buf[16*17]; memset(buf, 123, 16*17); - s.pixels = buf; - s.w = _charset->getCharWidth(chr); - s.h = _charset->getFontHeight(); - s.pitch = s.w; + s.init(_charset->getCharWidth(chr), _charset->getFontHeight(), + _charset->getCharWidth(chr), buf, + Graphics::PixelFormat::createFormatCLUT8()); // s.h = 17 for FM-TOWNS Loom Japanese. Fixes bug #1166917 assert(s.w <= 16 && s.h <= 17); - s.format = Graphics::PixelFormat::createFormatCLUT8(); _charset->drawChar(chr, s, 0, 0); diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp index 9b6dd1e687..872293f821 100644 --- a/engines/scumm/debugger.cpp +++ b/engines/scumm/debugger.cpp @@ -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(x1, y); while (x1++ <= x2) { *ptr++ = color; diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 50ff0b3988..4c1fdaf673 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -421,8 +421,8 @@ 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 + vs->setPixels(getResourceAddress(rtBuffer, slot + 1)); + memset(vs->getBasePtr(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.getPixels()); // 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.getPixels(), _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->getBasePtr(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->getBasePtr(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->getBasePtr(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->getBasePtr((strip + vs->xstart/8) * 8, top); numLinesToProcess = bottom - top; if (numLinesToProcess) { diff --git a/engines/scumm/gfx_towns.cpp b/engines/scumm/gfx_towns.cpp index f86a4e56d5..0aed181afd 100644 --- a/engines/scumm/gfx_towns.cpp +++ b/engines/scumm/gfx_towns.cpp @@ -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.getPixels()); int m = _textSurfaceMultiplier; diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index be17a3b305..d01b456c8b 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -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->getPixels(); 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); diff --git a/engines/scumm/nut_renderer.cpp b/engines/scumm/nut_renderer.cpp index 048b29d68b..d9f0b412e1 100644 --- a/engines/scumm/nut_renderer.cpp +++ b/engines/scumm/nut_renderer.cpp @@ -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); diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp index ed77a863cd..d266183f85 100644 --- a/engines/scumm/object.cpp +++ b/engines/scumm/object.cpp @@ -1715,7 +1715,7 @@ void ScummEngine_v6::drawBlastObject(BlastObject *eo) { error("object %d is not a blast object", eo->number); bdd.dst = *vs; - bdd.dst.pixels = vs->getPixels(0, 0); + bdd.dst.setPixels(vs->getPixels(0, 0)); bdd.x = eo->rect.left; bdd.y = eo->rect.top; |