From 3f37842580ee0fe2456f301354d0366024cf3f2e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 21:51:59 +0100 Subject: IPHONE: Directly use the game screen's texture buffer. This gets rid of another intermediate buffer. --- backends/platform/iphone/osys_main.cpp | 3 +-- backends/platform/iphone/osys_main.h | 3 --- backends/platform/iphone/osys_video.mm | 27 ++++++--------------------- 3 files changed, 7 insertions(+), 26 deletions(-) (limited to 'backends/platform/iphone') diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index e2de6ca478..dabf73bf58 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), _gameScreenConverted(NULL), + _mixer(NULL), _gameScreenRaw(NULL), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), _mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), @@ -73,7 +73,6 @@ OSystem_IPHONE::~OSystem_IPHONE() { delete _mixer; free(_gameScreenRaw); - free(_gameScreenConverted); } int OSystem_IPHONE::timerHandler(int t) { diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 8b1365af30..180d3e9d06 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -66,8 +66,6 @@ protected: Graphics::Surface _framebuffer; byte *_gameScreenRaw; - uint16 *_gameScreenConverted; - // For use with the game texture uint16 _gamePalette[256]; // For use with the mouse texture @@ -190,7 +188,6 @@ protected: void dirtyFullOverlayScreen(); void suspendLoop(); void drawDirtyRect(const Common::Rect &dirtyRect); - void updateHardwareSurfaceForRect(const Common::Rect &updatedRect); void updateMouseTexture(); static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB); static int timerHandler(int t); diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 8fc9535717..7e2b1eee07 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -68,13 +68,6 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm _gameScreenRaw = (byte *)malloc(width * height); bzero(_gameScreenRaw, width * height); - int fullSize = _videoContext->screenWidth * _videoContext->screenHeight * sizeof(OverlayColor); - - free(_gameScreenConverted); - - _gameScreenConverted = (uint16 *)malloc(fullSize); - bzero(_gameScreenConverted, fullSize); - updateOutputSurface(); clearOverlay(); @@ -191,7 +184,8 @@ void OSystem_IPHONE::internUpdateScreen() { //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); drawDirtyRect(dirtyRect); - updateHardwareSurfaceForRect(dirtyRect); + // TODO: Implement dirty rect code + //updateHardwareSurfaceForRect(dirtyRect); } if (_videoContext->overlayVisible) { @@ -210,27 +204,18 @@ 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]; - uint16 *dst = &_gameScreenConverted[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left]; + byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left]; + 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++]; - dst += _videoContext->screenWidth - w; + dstRaw += _videoContext->screenTexture.pitch; src += _videoContext->screenWidth - w; } } -void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { - const int x1 = updatedRect.left; - const int y1 = updatedRect.top; - const int x2 = updatedRect.right; - const int y2 = updatedRect.bottom; - - for (int y = y1; y < y2; ++y) - memcpy(_videoContext->screenTexture.getBasePtr(x1, y), &_gameScreenConverted[y * _videoContext->screenWidth + x1], (x2 - x1) * 2); -} - Graphics::Surface *OSystem_IPHONE::lockScreen() { //printf("lockScreen()\n"); -- cgit v1.2.3