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

This commit is contained in:
Johannes Schickel 2013-08-03 01:14:28 +02:00
parent cbef0de3a4
commit ae7bc4dcf0
3 changed files with 7 additions and 7 deletions

View file

@ -316,7 +316,7 @@ void GfxSurface::create(int width, int height) {
} }
_customSurface = new Graphics::Surface(); _customSurface = new Graphics::Surface();
_customSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); _customSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
Common::fill((byte *)_customSurface->pixels, (byte *)_customSurface->pixels + (width * height), 0); Common::fill((byte *)_customSurface->getBasePtr(0, 0), (byte *)_customSurface->getBasePtr(0, height), 0);
_bounds = Rect(0, 0, width, height); _bounds = Rect(0, 0, width, height);
} }
@ -363,7 +363,7 @@ void GfxSurface::synchronize(Serializer &s) {
if (_customSurface) { if (_customSurface) {
s.syncAsSint16LE(_customSurface->w); s.syncAsSint16LE(_customSurface->w);
s.syncAsSint16LE(_customSurface->h); s.syncAsSint16LE(_customSurface->h);
s.syncBytes((byte *)_customSurface->pixels, _customSurface->w * _customSurface->h); s.syncBytes((byte *)_customSurface->getBasePtr(0, 0), _customSurface->w * _customSurface->h);
} else { } else {
int zero = 0; int zero = 0;
s.syncAsSint16LE(zero); s.syncAsSint16LE(zero);
@ -380,7 +380,7 @@ void GfxSurface::synchronize(Serializer &s) {
_customSurface = NULL; _customSurface = NULL;
} else { } else {
create(w, h); create(w, h);
s.syncBytes((byte *)_customSurface->pixels, w * h); s.syncBytes((byte *)_customSurface->getBasePtr(0, 0), w * h);
} }
} }
} }
@ -581,7 +581,7 @@ void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Regi
Graphics::Surface destSurface = srcImage.lockSurface(); Graphics::Surface destSurface = srcImage.lockSurface();
const byte *srcP = (const byte *)srcSurface.getBasePtr(srcBounds.left, srcBounds.top); const byte *srcP = (const byte *)srcSurface.getBasePtr(srcBounds.left, srcBounds.top);
byte *destP = (byte *)destSurface.pixels; byte *destP = (byte *)destSurface.getBasePtr(0, 0);
for (int yp = srcBounds.top; yp < srcBounds.bottom; ++yp, srcP += srcSurface.pitch, destP += destSurface.pitch) { for (int yp = srcBounds.top; yp < srcBounds.bottom; ++yp, srcP += srcSurface.pitch, destP += destSurface.pitch) {
Common::copy(srcP, srcP + srcBounds.width(), destP); Common::copy(srcP, srcP + srcBounds.width(), destP);
} }

View file

@ -5399,9 +5399,9 @@ GfxSurface Scene600::Actor4::getFrame() {
// Translate the frame using the scene's pixel map // Translate the frame using the scene's pixel map
byte *pixelMap = static_cast<Scene600 *>(R2_GLOBALS._sceneManager._scene)->_pixelMap; byte *pixelMap = static_cast<Scene600 *>(R2_GLOBALS._sceneManager._scene)->_pixelMap;
Graphics::Surface surface = frame.lockSurface(); Graphics::Surface surface = frame.lockSurface();
byte *srcP = (byte *)surface.pixels; byte *srcP = (byte *)surface.getBasePtr(0, 0);
while (srcP < ((byte *)surface.pixels + (surface.w * surface.h))) { while (srcP < ((byte *)surface.getBasePtr(0, surface.h))) {
*srcP = pixelMap[*srcP]; *srcP = pixelMap[*srcP];
srcP++; srcP++;
} }

View file

@ -289,7 +289,7 @@ void Saver::writeSavegameHeader(Common::OutSaveFile *out, tSageSavegameHeader &h
// Create a thumbnail and save it // Create a thumbnail and save it
Graphics::Surface *thumb = new Graphics::Surface(); Graphics::Surface *thumb = new Graphics::Surface();
Graphics::Surface s = g_globals->_screenSurface.lockSurface(); Graphics::Surface s = g_globals->_screenSurface.lockSurface();
::createThumbnail(thumb, (const byte *)s.pixels, SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette); ::createThumbnail(thumb, (const byte *)s.getBasePtr(0, 0), SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette);
Graphics::saveThumbnail(*out, *thumb); Graphics::saveThumbnail(*out, *thumb);
g_globals->_screenSurface.unlockSurface(); g_globals->_screenSurface.unlockSurface();
thumb->free(); thumb->free();