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/tsage | |
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/tsage')
-rw-r--r-- | engines/tsage/events.cpp | 8 | ||||
-rw-r--r-- | engines/tsage/graphics.cpp | 23 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_logic.cpp | 2 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes0.cpp | 4 | ||||
-rw-r--r-- | engines/tsage/saveload.cpp | 2 |
5 files changed, 17 insertions, 22 deletions
diff --git a/engines/tsage/events.cpp b/engines/tsage/events.cpp index 8f07a8243b..5ca531fdb9 100644 --- a/engines/tsage/events.cpp +++ b/engines/tsage/events.cpp @@ -277,7 +277,7 @@ void EventsClass::setCursor(CursorType cursorType) { GfxSurface s = surfaceFromRes(cursor); Graphics::Surface surface = s.lockSurface(); - const byte *cursorData = (const byte *)surface.getBasePtr(0, 0); + const byte *cursorData = (const byte *)surface.getPixels(); CursorMan.replaceCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor); s.unlockSurface(); @@ -333,7 +333,7 @@ void EventsClass::pushCursor(CursorType cursorType) { GfxSurface s = surfaceFromRes(cursor); Graphics::Surface surface = s.lockSurface(); - const byte *cursorData = (const byte *)surface.getBasePtr(0, 0); + const byte *cursorData = (const byte *)surface.getPixels(); CursorMan.pushCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor); s.unlockSurface(); @@ -346,7 +346,7 @@ void EventsClass::popCursor() { } void EventsClass::setCursor(Graphics::Surface &cursor, int transColor, const Common::Point &hotspot, CursorType cursorId) { - const byte *cursorData = (const byte *)cursor.getBasePtr(0, 0); + const byte *cursorData = (const byte *)cursor.getPixels(); CursorMan.replaceCursor(cursorData, cursor.w, cursor.h, hotspot.x, hotspot.y, transColor); _currentCursor = cursorId; @@ -355,7 +355,7 @@ void EventsClass::setCursor(Graphics::Surface &cursor, int transColor, const Com void EventsClass::setCursor(GfxSurface &cursor) { Graphics::Surface s = cursor.lockSurface(); - const byte *cursorData = (const byte *)s.getBasePtr(0, 0); + const byte *cursorData = (const byte *)s.getPixels(); CursorMan.replaceCursor(cursorData, cursor.getBounds().width(), cursor.getBounds().height(), cursor._centroid.x, cursor._centroid.y, cursor._transColor); diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp index ce19502524..1815c3d751 100644 --- a/engines/tsage/graphics.cpp +++ b/engines/tsage/graphics.cpp @@ -47,7 +47,7 @@ GfxSurface *surfaceGetArea(GfxSurface &src, const Rect &bounds) { Graphics::Surface destSurface = dest->lockSurface(); byte *srcP = (byte *)srcSurface.getBasePtr(bounds.left, bounds.top); - byte *destP = (byte *)destSurface.getBasePtr(0, 0); + byte *destP = (byte *)destSurface.getPixels(); for (int y = bounds.top; y < bounds.bottom; ++y, srcP += srcSurface.pitch, destP += destSurface.pitch) Common::copy(srcP, srcP + destSurface.pitch, destP); @@ -76,7 +76,7 @@ GfxSurface surfaceFromRes(const byte *imgData) { const byte *srcP = imgData + 10; Graphics::Surface destSurface = s.lockSurface(); - byte *destP = (byte *)destSurface.getBasePtr(0, 0); + byte *destP = (byte *)destSurface.getPixels(); if (!rleEncoded) { Common::copy(srcP, srcP + (r.width() * r.height()), destP); @@ -316,7 +316,7 @@ void GfxSurface::create(int width, int height) { } _customSurface = new Graphics::Surface(); _customSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - Common::fill((byte *)_customSurface->pixels, (byte *)_customSurface->pixels + (width * height), 0); + Common::fill((byte *)_customSurface->getPixels(), (byte *)_customSurface->getBasePtr(0, height), 0); _bounds = Rect(0, 0, width, height); } @@ -332,12 +332,7 @@ Graphics::Surface GfxSurface::lockSurface() { // Setup the returned surface either as one pointing to the same pixels as the source, or // as a subset of the source one based on the currently set bounds Graphics::Surface result; - result.w = _bounds.width(); - result.h = _bounds.height(); - result.pitch = src->pitch; - result.format = src->format; - result.pixels = src->getBasePtr(_bounds.left, _bounds.top); - + result.init(_bounds.width(), _bounds.height(), src->pitch, src->getBasePtr(_bounds.left, _bounds.top), src->format); return result; } @@ -363,7 +358,7 @@ void GfxSurface::synchronize(Serializer &s) { if (_customSurface) { s.syncAsSint16LE(_customSurface->w); s.syncAsSint16LE(_customSurface->h); - s.syncBytes((byte *)_customSurface->pixels, _customSurface->w * _customSurface->h); + s.syncBytes((byte *)_customSurface->getPixels(), _customSurface->w * _customSurface->h); } else { int zero = 0; s.syncAsSint16LE(zero); @@ -380,7 +375,7 @@ void GfxSurface::synchronize(Serializer &s) { _customSurface = NULL; } else { create(w, h); - s.syncBytes((byte *)_customSurface->pixels, w * h); + s.syncBytes((byte *)_customSurface->getPixels(), w * h); } } } @@ -417,8 +412,8 @@ GfxSurface &GfxSurface::operator=(const GfxSurface &s) { // Surface owns the internal data, so replicate it so new surface owns it's own _customSurface = new Graphics::Surface(); _customSurface->create(s._customSurface->w, s._customSurface->h, Graphics::PixelFormat::createFormatCLUT8()); - const byte *srcP = (const byte *)s._customSurface->getBasePtr(0, 0); - byte *destP = (byte *)_customSurface->getBasePtr(0, 0); + const byte *srcP = (const byte *)s._customSurface->getPixels(); + byte *destP = (byte *)_customSurface->getPixels(); Common::copy(srcP, srcP + (_bounds.width() * _bounds.height()), destP); } @@ -581,7 +576,7 @@ void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Regi Graphics::Surface destSurface = srcImage.lockSurface(); const byte *srcP = (const byte *)srcSurface.getBasePtr(srcBounds.left, srcBounds.top); - byte *destP = (byte *)destSurface.pixels; + byte *destP = (byte *)destSurface.getPixels(); for (int yp = srcBounds.top; yp < srcBounds.bottom; ++yp, srcP += srcSurface.pitch, destP += destSurface.pitch) { Common::copy(srcP, srcP + srcBounds.width(), destP); } diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index 0495834307..cb28d6d60b 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -522,7 +522,7 @@ void SceneExt::refreshBackground(int xAmount, int yAmount) { assert(screenSize == (s.w * s.h)); // Copy the data - byte *destP = (byte *)s.getBasePtr(0, 0); + byte *destP = (byte *)s.getPixels(); Common::copy(dataP, dataP + (s.w * s.h), destP); _backSurface.unlockSurface(); diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp index e37d5bfff3..ead4f5c770 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -5399,9 +5399,9 @@ GfxSurface Scene600::Actor4::getFrame() { // Translate the frame using the scene's pixel map byte *pixelMap = static_cast<Scene600 *>(R2_GLOBALS._sceneManager._scene)->_pixelMap; Graphics::Surface surface = frame.lockSurface(); - byte *srcP = (byte *)surface.pixels; + byte *srcP = (byte *)surface.getPixels(); - while (srcP < ((byte *)surface.pixels + (surface.w * surface.h))) { + while (srcP < ((byte *)surface.getBasePtr(0, surface.h))) { *srcP = pixelMap[*srcP]; srcP++; } diff --git a/engines/tsage/saveload.cpp b/engines/tsage/saveload.cpp index af2f3566ad..7143305586 100644 --- a/engines/tsage/saveload.cpp +++ b/engines/tsage/saveload.cpp @@ -289,7 +289,7 @@ void Saver::writeSavegameHeader(Common::OutSaveFile *out, tSageSavegameHeader &h // Create a thumbnail and save it Graphics::Surface *thumb = new Graphics::Surface(); Graphics::Surface s = g_globals->_screenSurface.lockSurface(); - ::createThumbnail(thumb, (const byte *)s.pixels, SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette); + ::createThumbnail(thumb, (const byte *)s.getPixels(), SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette); Graphics::saveThumbnail(*out, *thumb); g_globals->_screenSurface.unlockSurface(); thumb->free(); |