aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/iphone/osys_main.cpp4
-rw-r--r--backends/platform/iphone/osys_main.h1
-rw-r--r--backends/platform/iphone/osys_video.mm30
3 files changed, 12 insertions, 23 deletions
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index dd34e95c72..790e192f97 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -55,7 +55,7 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL;
void *OSystem_IPHONE::s_soundParam = NULL;
OSystem_IPHONE::OSystem_IPHONE() :
- _mixer(NULL), _gameScreenRaw(NULL),
+ _mixer(NULL),
_mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0),
_mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0),
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
@@ -72,7 +72,7 @@ OSystem_IPHONE::~OSystem_IPHONE() {
AudioQueueDispose(s_AudioQueue.queue, true);
delete _mixer;
- free(_gameScreenRaw);
+ _framebuffer.free();
}
int OSystem_IPHONE::timerHandler(int t) {
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index 84c460aaf4..675fc96321 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -64,7 +64,6 @@ protected:
VideoContext *_videoContext;
Graphics::Surface _framebuffer;
- byte *_gameScreenRaw;
// For use with the game texture
uint16 _gamePalette[256];
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index 265a36f946..080b476a9e 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -62,10 +62,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
_videoContext->screenHeight = height;
_videoContext->shakeOffsetY = 0;
- free(_gameScreenRaw);
-
- _gameScreenRaw = (byte *)malloc(width * height);
- bzero(_gameScreenRaw, width * height);
+ _framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_fullScreenIsDirty = false;
dirtyFullScreen();
@@ -134,12 +131,12 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
y = 0;
}
- if (w > (int)_videoContext->screenWidth - x) {
- w = _videoContext->screenWidth - x;
+ if (w > (int)_framebuffer.w - x) {
+ w = _framebuffer.w - x;
}
- if (h > (int)_videoContext->screenHeight - y) {
- h = _videoContext->screenHeight - y;
+ if (h > (int)_framebuffer.h - y) {
+ h = _framebuffer.h - y;
}
if (w <= 0 || h <= 0)
@@ -150,14 +147,14 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
}
- byte *dst = _gameScreenRaw + y * _videoContext->screenWidth + x;
- if ((int)_videoContext->screenWidth == pitch && pitch == w)
+ byte *dst = (byte *)_framebuffer.getBasePtr(x, y);
+ if (_framebuffer.pitch == pitch && pitch == w)
memcpy(dst, buf, h * w);
else {
do {
memcpy(dst, buf, w);
buf += pitch;
- dst += _videoContext->screenWidth;
+ dst += _framebuffer.pitch;
} while (--h);
}
}
@@ -207,7 +204,7 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
int h = dirtyRect.bottom - dirtyRect.top;
int w = dirtyRect.right - dirtyRect.left;
- byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left];
+ const byte *src = (const byte *)_framebuffer.getBasePtr(dirtyRect.left, dirtyRect.top);
byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top);
for (int y = h; y > 0; y--) {
uint16 *dst = (uint16 *)dstRaw;
@@ -215,19 +212,12 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
*dst++ = _gamePalette[*src++];
dstRaw += _videoContext->screenTexture.pitch;
- src += _videoContext->screenWidth - w;
+ src += _framebuffer.pitch - w;
}
}
Graphics::Surface *OSystem_IPHONE::lockScreen() {
//printf("lockScreen()\n");
-
- _framebuffer.pixels = _gameScreenRaw;
- _framebuffer.w = _videoContext->screenWidth;
- _framebuffer.h = _videoContext->screenHeight;
- _framebuffer.pitch = _videoContext->screenWidth;
- _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
-
return &_framebuffer;
}