Skip to content

Commit

Permalink
IPHONE: Get rid of _gameScreenRaw, instead use _framebuffer internally.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schickel committed Feb 25, 2012
1 parent 97e486d commit 23732c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
4 changes: 2 additions & 2 deletions backends/platform/iphone/osys_main.cpp
Expand Up @@ -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),
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion backends/platform/iphone/osys_main.h
Expand Up @@ -64,7 +64,6 @@ class OSystem_IPHONE : public EventsBaseBackend, public PaletteManager {
VideoContext *_videoContext;

Graphics::Surface _framebuffer;
byte *_gameScreenRaw;

// For use with the game texture
uint16 _gamePalette[256];
Expand Down
30 changes: 10 additions & 20 deletions backends/platform/iphone/osys_video.mm
Expand Up @@ -62,10 +62,7 @@
_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();
Expand Down Expand Up @@ -134,12 +131,12 @@
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)
Expand All @@ -150,14 +147,14 @@
}


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);
}
}
Expand Down Expand Up @@ -207,27 +204,20 @@
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;
for (int x = w; x > 0; x--)
*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;
}

Expand Down

0 comments on commit 23732c7

Please sign in to comment.