From aec9b9e22a9bff54ae3c39bb796bae0f4b4c2d95 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 16 Jun 2012 04:17:14 +0200 Subject: ALL: Let overlay related methods in OSystem take a void * and use a proper pitch values. This is a first step to get rid of OverlayColor, which is a requirement for proper 4Bpp overlay support. --- backends/platform/iphone/osys_main.h | 4 ++-- backends/platform/iphone/osys_video.mm | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'backends/platform/iphone') diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index b15b5e0375..037125490d 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -152,8 +152,8 @@ public: virtual void showOverlay(); virtual void hideOverlay(); virtual void clearOverlay(); - virtual void grabOverlay(OverlayColor *buf, int pitch); - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + virtual void grabOverlay(void *buf, int pitch); + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual int16 getOverlayHeight(); virtual int16 getOverlayWidth(); virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<5551>(); } diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 1649956a6c..b01c925024 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -309,31 +309,33 @@ void OSystem_IPHONE::clearOverlay() { dirtyFullOverlayScreen(); } -void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_IPHONE::grabOverlay(void *buf, int pitch) { //printf("grabOverlay()\n"); int h = _videoContext->overlayHeight; + byte *dst = (byte *)buf; const byte *src = (const byte *)_videoContext->overlayTexture.getBasePtr(0, 0); do { - memcpy(buf, src, _videoContext->overlayWidth * sizeof(OverlayColor)); + memcpy(dst, src, _videoContext->overlayWidth * sizeof(OverlayColor)); src += _videoContext->overlayTexture.pitch; - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OSystem_IPHONE::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { //printf("copyRectToOverlay(%p, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", (const void *)buf, pitch, x, y, w, h); + const byte *src = (const byte *)buf; //Clip the coordinates if (x < 0) { w += x; - buf -= x; + src -= x * sizeof(OverlayColor); x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -352,8 +354,8 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x byte *dst = (byte *)_videoContext->overlayTexture.getBasePtr(x, y); do { - memcpy(dst, buf, w * sizeof(OverlayColor)); - buf += pitch; + memcpy(dst, src, w * sizeof(OverlayColor)); + src += pitch; dst += _videoContext->overlayTexture.pitch; } while (--h); } -- cgit v1.2.3