diff options
35 files changed, 137 insertions, 129 deletions
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 9fde5cfaf2..24397228e6 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -73,8 +73,8 @@ public: virtual void hideOverlay() = 0; virtual Graphics::PixelFormat getOverlayFormat() const = 0; virtual void clearOverlay() = 0; - virtual void grabOverlay(OverlayColor *buf, int pitch) = 0; - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h)= 0; + virtual void grabOverlay(void *buf, int pitch) = 0; + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h)= 0; virtual int16 getOverlayHeight() = 0; virtual int16 getOverlayWidth() = 0; diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h index 30b1946a77..276be7d3fa 100644 --- a/backends/graphics/null/null-graphics.h +++ b/backends/graphics/null/null-graphics.h @@ -71,8 +71,8 @@ public: void hideOverlay() {} Graphics::PixelFormat getOverlayFormat() const { return Graphics::PixelFormat(); } void clearOverlay() {} - void grabOverlay(OverlayColor *buf, int pitch) {} - void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {} + void grabOverlay(void *buf, int pitch) {} + void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) {} int16 getOverlayHeight() { return 0; } int16 getOverlayWidth() { return 0; } diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index ed63916551..dce902d894 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -467,33 +467,35 @@ void OpenGLGraphicsManager::clearOverlay() { _overlayNeedsRedraw = true; } -void OpenGLGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { - assert(_overlayData.format.bytesPerPixel == sizeof(buf[0])); +void OpenGLGraphicsManager::grabOverlay(void *buf, int pitch) { const byte *src = (byte *)_overlayData.pixels; + byte *dst = (byte *)buf; for (int i = 0; i < _overlayData.h; i++) { // Copy overlay data to buffer - memcpy(buf, src, _overlayData.pitch); - buf += pitch; + memcpy(dst, src, _overlayData.pitch); + dst += pitch; src += _overlayData.pitch; } } -void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OpenGLGraphicsManager::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { assert(_transactionMode == kTransactionNone); if (_overlayTexture == NULL) return; + const byte *src = (const byte *)buf; + // Clip the coordinates if (x < 0) { w += x; - buf -= x; + src -= x * 2; x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -507,11 +509,10 @@ void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch return; // Copy buffer data to internal overlay surface - const byte *src = (const byte *)buf; byte *dst = (byte *)_overlayData.pixels + y * _overlayData.pitch; for (int i = 0; i < h; i++) { memcpy(dst + x * _overlayData.format.bytesPerPixel, src, w * _overlayData.format.bytesPerPixel); - src += pitch * sizeof(buf[0]); + src += pitch; dst += _overlayData.pitch; } diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index b2f78187dc..9d8d418d11 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -97,8 +97,8 @@ public: virtual void hideOverlay(); virtual Graphics::PixelFormat getOverlayFormat() const; 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(); diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index cdbe6293e4..fb964d6951 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -1597,7 +1597,7 @@ void SurfaceSdlGraphicsManager::clearOverlay() { _forceFull = true; } -void SurfaceSdlGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { +void SurfaceSdlGraphicsManager::grabOverlay(void *buf, int pitch) { assert(_transactionMode == kTransactionNone); if (_overlayscreen == NULL) @@ -1607,31 +1607,35 @@ void SurfaceSdlGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { error("SDL_LockSurface failed: %s", SDL_GetError()); byte *src = (byte *)_overlayscreen->pixels; + byte *dst = (byte *)buf; int h = _videoMode.overlayHeight; do { - memcpy(buf, src, _videoMode.overlayWidth * 2); + memcpy(dst, src, _videoMode.overlayWidth * 2); src += _overlayscreen->pitch; - buf += pitch; + dst += pitch; } while (--h); SDL_UnlockSurface(_overlayscreen); } -void SurfaceSdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void SurfaceSdlGraphicsManager::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { assert(_transactionMode == kTransactionNone); if (_overlayscreen == NULL) return; + const byte *src = (const byte *)buf; + // Clip the coordinates if (x < 0) { w += x; - buf -= x; + src -= x * 2; x = 0; } if (y < 0) { - h += y; buf -= y * pitch; + h += y; + src -= y * pitch; y = 0; } @@ -1654,9 +1658,9 @@ void SurfaceSdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int p byte *dst = (byte *)_overlayscreen->pixels + y * _overlayscreen->pitch + x * 2; do { - memcpy(dst, buf, w * 2); + memcpy(dst, src, w * 2); dst += _overlayscreen->pitch; - buf += pitch; + src += pitch; } while (--h); SDL_UnlockSurface(_overlayscreen); diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index f387c213fb..21444cc25d 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -124,8 +124,8 @@ public: virtual void hideOverlay(); virtual Graphics::PixelFormat getOverlayFormat() const { return _overlayFormat; } 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() { return _videoMode.overlayHeight; } virtual int16 getOverlayWidth() { return _videoMode.overlayWidth; } diff --git a/backends/graphics/wincesdl/wincesdl-graphics.cpp b/backends/graphics/wincesdl/wincesdl-graphics.cpp index 13d52bcd25..f075f8cf8a 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.cpp +++ b/backends/graphics/wincesdl/wincesdl-graphics.cpp @@ -1023,22 +1023,24 @@ bool WINCESdlGraphicsManager::saveScreenshot(const char *filename) { return true; } -void WINCESdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void WINCESdlGraphicsManager::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { assert(_transactionMode == kTransactionNone); if (_overlayscreen == NULL) return; + const byte *src = (const byte *)buf; + // Clip the coordinates if (x < 0) { w += x; - buf -= x; + src -= x * 2; x = 0; } if (y < 0) { h += y; - buf -= y * pitch; + src -= y * pitch; y = 0; } @@ -1063,9 +1065,9 @@ void WINCESdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pit byte *dst = (byte *)_overlayscreen->pixels + y * _overlayscreen->pitch + x * 2; do { - memcpy(dst, buf, w * 2); + memcpy(dst, src, w * 2); dst += _overlayscreen->pitch; - buf += pitch; + src += pitch; } while (--h); SDL_UnlockSurface(_overlayscreen); diff --git a/backends/graphics/wincesdl/wincesdl-graphics.h b/backends/graphics/wincesdl/wincesdl-graphics.h index 33bf7e7880..2897ca5f40 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.h +++ b/backends/graphics/wincesdl/wincesdl-graphics.h @@ -74,7 +74,7 @@ public: void undrawMouse(); bool showMouse(bool visible); void setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format); // overloaded by CE backend - void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); // overloaded by CE backend (FIXME) Graphics::Surface *lockScreen(); void unlockScreen(); diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 3c26d5afee..b46f33a2bc 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -171,11 +171,11 @@ void ModularBackend::clearOverlay() { _graphicsManager->clearOverlay(); } -void ModularBackend::grabOverlay(OverlayColor *buf, int pitch) { +void ModularBackend::grabOverlay(void *buf, int pitch) { _graphicsManager->grabOverlay(buf, pitch); } -void ModularBackend::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void ModularBackend::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { _graphicsManager->copyRectToOverlay(buf, pitch, x, y, w, h); } diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 400102428b..b43769c716 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -93,8 +93,8 @@ public: virtual void hideOverlay(); virtual Graphics::PixelFormat getOverlayFormat() const; 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(); diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index ce51baec3d..4b13ca4b0f 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -257,8 +257,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, + 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(); diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp index 1241667533..44046cb1c1 100644 --- a/backends/platform/android/gfx.cpp +++ b/backends/platform/android/gfx.cpp @@ -636,7 +636,7 @@ void OSystem_Android::clearOverlay() { _overlay_texture->fillBuffer(0); } -void OSystem_Android::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_Android::grabOverlay(void *buf, int pitch) { ENTER("%p, %d", buf, pitch); GLTHREADCHECK; @@ -644,25 +644,24 @@ void OSystem_Android::grabOverlay(OverlayColor *buf, int pitch) { const Graphics::Surface *surface = _overlay_texture->surface_const(); assert(surface->format.bytesPerPixel == sizeof(buf[0])); + byte *dst = (byte *)buf; const byte *src = (const byte *)surface->pixels; uint h = surface->h; do { - memcpy(buf, src, surface->w * surface->format.bytesPerPixel); + memcpy(dst, src, surface->w * surface->format.bytesPerPixel); src += surface->pitch; - // This 'pitch' is pixels not bytes - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_Android::copyRectToOverlay(const OverlayColor *buf, int pitch, +void OSystem_Android::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { ENTER("%p, %d, %d, %d, %d, %d", buf, pitch, x, y, w, h); GLTHREADCHECK; - // This 'pitch' is pixels not bytes - _overlay_texture->updateBuffer(x, y, w, h, buf, pitch * sizeof(buf[0])); + _overlay_texture->updateBuffer(x, y, w, h, buf, pitch); } int16 OSystem_Android::getOverlayHeight() { diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index aa2a3709cb..d41839d961 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -172,8 +172,8 @@ public: void showOverlay(); void hideOverlay(); void clearOverlay(); - void grabOverlay(OverlayColor *buf, int pitch); - void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + void grabOverlay(void *buf, int pitch); + void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<4444>(); } // Mutex handling diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index 35e7b70a82..cc5798fc10 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -653,27 +653,29 @@ void OSystem_Dreamcast::clearOverlay() _overlay_dirty = true; } -void OSystem_Dreamcast::grabOverlay(OverlayColor *buf, int pitch) +void OSystem_Dreamcast::grabOverlay(void *buf, int pitch) { int h = OVL_H; unsigned short *src = overlay; + unsigned char *dst = (unsigned char *)buf; do { - memcpy(buf, src, OVL_W*sizeof(int16)); + memcpy(dst, src, OVL_W*sizeof(int16)); src += OVL_W; - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_Dreamcast::copyRectToOverlay(const OverlayColor *buf, int pitch, +void OSystem_Dreamcast::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { if (w<1 || h<1) return; unsigned short *dst = overlay + y*OVL_W + x; + const unsigned char *src = (const unsigned char *)buf; do { - memcpy(dst, buf, w*sizeof(int16)); + memcpy(dst, src, w*sizeof(int16)); dst += OVL_W; - buf += pitch; + src += pitch; } while (--h); _overlay_dirty = true; } diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index b4bf38c45b..5c20deb359 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -509,13 +509,13 @@ void OSystem_DS::clearOverlay() { // consolePrintf("clearovl\n"); } -void OSystem_DS::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_DS::grabOverlay(void *buf, int pitch) { // consolePrintf("grabovl\n") u16 *start = DS::get16BitBackBuffer(); for (int y = 0; y < 200; y++) { u16 *src = start + (y * 320); - u16 *dest = ((u16 *) (buf)) + (y * pitch); + u16 *dest = (u16 *)((u8 *)buf + (y * pitch)); for (int x = 0; x < 320; x++) { *dest++ = *src++; @@ -524,9 +524,9 @@ void OSystem_DS::grabOverlay(OverlayColor *buf, int pitch) { } -void OSystem_DS::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OSystem_DS::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { u16 *bg = (u16 *) DS::get16BitBackBuffer(); - const u16 *src = (const u16 *) buf; + const u8 *source = (const u8 *)buf; // if (x + w > 256) w = 256 - x; //if (x + h > 256) h = 256 - y; @@ -536,7 +536,7 @@ void OSystem_DS::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, in for (int dy = y; dy < y + h; dy++) { - + const u16 *src = (const u16 *)source; // Slow but save copy: for (int dx = x; dx < x + w; dx++) { @@ -546,7 +546,7 @@ void OSystem_DS::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, in //consolePrintf("%d,", *src); src++; } - src += (pitch - w); + source += pitch; // Fast but broken copy: (why?) /* diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index d35b16c8fd..a6001da764 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -105,8 +105,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<1555>(); } 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); } diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index 121f84f93f..3266180a7b 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -171,8 +171,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 { diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index b526c68762..ed2badb305 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -683,28 +683,30 @@ void OSystem_N64::clearOverlay() { _dirtyOffscreen = true; } -void OSystem_N64::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_N64::grabOverlay(void *buf, int pitch) { int h = _overlayHeight; OverlayColor *src = _overlayBuffer; + byte *dst = (byte *)buf; do { - memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); + memcpy(dst, src, _overlayWidth * sizeof(OverlayColor)); src += _overlayWidth; - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_N64::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OSystem_N64::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int 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; } @@ -723,11 +725,11 @@ void OSystem_N64::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, i OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x); if (_overlayWidth == pitch && pitch == w) { - memcpy(dst, buf, h * w * sizeof(OverlayColor)); + memcpy(dst, src, h * w * sizeof(OverlayColor)); } else { do { - memcpy(dst, buf, w * sizeof(OverlayColor)); - buf += pitch; + memcpy(dst, src, w * sizeof(OverlayColor)); + src += pitch; dst += _overlayWidth; } while (--h); } diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp index 8df6198c38..f93166ef67 100644 --- a/backends/platform/ps2/Gs2dScreen.cpp +++ b/backends/platform/ps2/Gs2dScreen.cpp @@ -564,7 +564,7 @@ void Gs2dScreen::clearPrintfOverlay(void) { free(tmpBuf); } -void Gs2dScreen::copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h) { +void Gs2dScreen::copyOverlayRect(const byte *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h) { WaitSema(g_DmacSema); // warning("_overlayBuf [dst] = %x", _overlayBuf); @@ -601,7 +601,7 @@ void Gs2dScreen::clearOverlay(void) { SignalSema(g_DmacSema); } -void Gs2dScreen::grabOverlay(uint16 *buf, uint16 pitch) { +void Gs2dScreen::grabOverlay(byte *buf, uint16 pitch) { uint16 *src = _overlayBuf; for (uint32 cnt = 0; cnt < _height; cnt++) { memcpy(buf, src, _width * 2); diff --git a/backends/platform/ps2/Gs2dScreen.h b/backends/platform/ps2/Gs2dScreen.h index 4fbb3fdef8..005dabc809 100644 --- a/backends/platform/ps2/Gs2dScreen.h +++ b/backends/platform/ps2/Gs2dScreen.h @@ -62,8 +62,8 @@ public: void updateScreen(void); void grabPalette(uint8 *pal, uint8 start, uint16 num); //- overlay routines - void copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h); - void grabOverlay(uint16 *buf, uint16 pitch); + void copyOverlayRect(const byte *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h); + void grabOverlay(byte *buf, uint16 pitch); void clearOverlay(void); void showOverlay(void); void hideOverlay(void); diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index a639725d78..5628658381 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -634,12 +634,12 @@ void OSystem_PS2::clearOverlay(void) { _screen->clearOverlay(); } -void OSystem_PS2::grabOverlay(OverlayColor *buf, int pitch) { - _screen->grabOverlay((uint16 *)buf, (uint16)pitch); +void OSystem_PS2::grabOverlay(void *buf, int pitch) { + _screen->grabOverlay((byte *)buf, (uint16)pitch); } -void OSystem_PS2::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { - _screen->copyOverlayRect((const uint16*)buf, (uint16)pitch, (uint16)x, (uint16)y, (uint16)w, (uint16)h); +void OSystem_PS2::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { + _screen->copyOverlayRect((const byte *)buf, (uint16)pitch, (uint16)x, (uint16)y, (uint16)w, (uint16)h); } Graphics::PixelFormat OSystem_PS2::getOverlayFormat(void) const { diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index efbe7d5f93..99482d4da4 100644 --- a/backends/platform/ps2/systemps2.h +++ b/backends/platform/ps2/systemps2.h @@ -72,8 +72,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 getOverlayWidth(void); virtual int16 getOverlayHeight(void); diff --git a/backends/platform/psp/default_display_client.cpp b/backends/platform/psp/default_display_client.cpp index 2ee7ff5b74..bc252144fa 100644 --- a/backends/platform/psp/default_display_client.cpp +++ b/backends/platform/psp/default_display_client.cpp @@ -123,15 +123,15 @@ void Overlay::setSize(uint32 width, uint32 height) { _renderer.setDrawWholeBuffer(); // We need to let the renderer know how much to draw } -void Overlay::copyToArray(OverlayColor *buf, int pitch) { +void Overlay::copyToArray(void *buf, int pitch) { DEBUG_ENTER_FUNC(); - _buffer.copyToArray((byte *)buf, pitch * sizeof(OverlayColor)); // Change to bytes + _buffer.copyToArray((byte *)buf, pitch); // Change to bytes } -void Overlay::copyFromRect(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void Overlay::copyFromRect(const void *buf, int pitch, int x, int y, int w, int h) { DEBUG_ENTER_FUNC(); - _buffer.copyFromRect((byte *)buf, pitch * sizeof(OverlayColor), x, y, w, h); // Change to bytes + _buffer.copyFromRect((byte *)buf, pitch, x, y, w, h); // Change to bytes // debug //_buffer.print(0xFF); setDirty(); diff --git a/backends/platform/psp/default_display_client.h b/backends/platform/psp/default_display_client.h index 721a7e6fea..95c52e2352 100644 --- a/backends/platform/psp/default_display_client.h +++ b/backends/platform/psp/default_display_client.h @@ -69,8 +69,8 @@ public: bool allocate(); void setBytesPerPixel(uint32 size); void setSize(uint32 width, uint32 height); - void copyToArray(OverlayColor *buf, int pitch); - void copyFromRect(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + void copyToArray(void *buf, int pitch); + void copyFromRect(const void *buf, int pitch, int x, int y, int w, int h); }; /** diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 3fe9a7f9c7..0032fea072 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -260,12 +260,12 @@ void OSystem_PSP::clearOverlay() { _overlay.clearBuffer(); } -void OSystem_PSP::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_PSP::grabOverlay(void *buf, int pitch) { DEBUG_ENTER_FUNC(); _overlay.copyToArray(buf, pitch); } -void OSystem_PSP::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +void OSystem_PSP::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { DEBUG_ENTER_FUNC(); _displayManager.waitUntilRenderFinished(); _pendingUpdate = false; diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index d167c757ae..2afdabd0fc 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -109,8 +109,8 @@ public: void showOverlay(); void hideOverlay(); void clearOverlay(); - void grabOverlay(OverlayColor *buf, int pitch); - void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); + void grabOverlay(void *buf, int pitch); + void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h); int16 getOverlayHeight(); int16 getOverlayWidth(); Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<4444>(); } diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index ecd69178bb..f1c8d77533 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -177,8 +177,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, + 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 getOverlayWidth(); virtual int16 getOverlayHeight(); diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 741acd4f4a..6b0e31bd7b 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -571,28 +571,30 @@ void OSystem_Wii::clearOverlay() { _overlayDirty = true; } -void OSystem_Wii::grabOverlay(OverlayColor *buf, int pitch) { +void OSystem_Wii::grabOverlay(void *buf, int pitch) { int h = _overlayHeight; OverlayColor *src = _overlayPixels; + byte *dst = (byte *)buf; do { - memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); + memcpy(dst, src, _overlayWidth * sizeof(OverlayColor)); src += _overlayWidth; - buf += pitch; + dst += pitch; } while (--h); } -void OSystem_Wii::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, +void OSystem_Wii::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) { + const byte *src = (const byte *)buf; 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; } @@ -607,11 +609,11 @@ void OSystem_Wii::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, OverlayColor *dst = _overlayPixels + (y * _overlayWidth + x); if (_overlayWidth == pitch && pitch == w) { - memcpy(dst, buf, h * w * sizeof(OverlayColor)); + memcpy(dst, src, h * w * sizeof(OverlayColor)); } else { do { - memcpy(dst, buf, w * sizeof(OverlayColor)); - buf += pitch; + memcpy(dst, src, w * sizeof(OverlayColor)); + src += pitch; dst += _overlayWidth; } while (--h); } diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index 42f9707ddc..75de86472f 100644 --- a/backends/vkeybd/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -161,7 +161,7 @@ void VirtualKeyboardGUI::run() { _system->clearOverlay(); } _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); - _system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w); + _system->grabOverlay(_overlayBackup.pixels, _overlayBackup.pitch); setupCursor(); @@ -171,7 +171,7 @@ void VirtualKeyboardGUI::run() { removeCursor(); - _system->copyRectToOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w, 0, 0, _overlayBackup.w, _overlayBackup.h); + _system->copyRectToOverlay(_overlayBackup.pixels, _overlayBackup.pitch, 0, 0, _overlayBackup.w, _overlayBackup.h); if (!g_gui.isActive()) _system->hideOverlay(); _overlayBackup.free(); @@ -262,7 +262,7 @@ void VirtualKeyboardGUI::screenChanged() { _screenH = newScreenH; _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); - _system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w); + _system->grabOverlay(_overlayBackup.pixels, _overlayBackup.pitch); if (!_kbd->checkModeResolutions()) { _displaying = false; @@ -371,7 +371,7 @@ void VirtualKeyboardGUI::redraw() { blit(&surf, &_dispSurface, _dispX - _dirtyRect.left, _dispY - _dirtyRect.top, _dispBackColor); } - _system->copyRectToOverlay((OverlayColor *)surf.pixels, surf.w, + _system->copyRectToOverlay(surf.pixels, surf.pitch, _dirtyRect.left, _dirtyRect.top, surf.w, surf.h); surf.free(); diff --git a/common/system.h b/common/system.h index a6753eac49..7a4fa00dec 100644 --- a/common/system.h +++ b/common/system.h @@ -790,20 +790,14 @@ public: * Copy the content of the overlay into a buffer provided by the caller. * This is only used to implement fake alpha blending. */ - virtual void grabOverlay(OverlayColor *buf, int pitch) = 0; + virtual void grabOverlay(void *buf, int pitch) = 0; /** * Blit a graphics buffer to the overlay. * In a sense, this is the reverse of grabOverlay. * - * @note The pitch parameter actually contains the 'pixel pitch', i.e., - * the number of pixels per scanline, and not as usual the number of bytes - * per scanline. - * - * @todo Change 'pitch' to be byte and not pixel based - * * @param buf the buffer containing the graphics data source - * @param pitch the pixel pitch of the buffer (number of pixels in a scanline) + * @param pitch the pitch of the buffer (number of bytes in a scanline) * @param x the x coordinate of the destination rectangle * @param y the y coordinate of the destination rectangle * @param w the width of the destination rectangle @@ -812,7 +806,7 @@ public: * @see copyRectToScreen * @see grabOverlay */ - virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) = 0; + virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) = 0; /** * Return the height of the overlay. diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index 36ec726fc7..082694b728 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -935,7 +935,7 @@ TestExitStatus GFXtests::overlayGraphics() { } g_system->showOverlay(); - g_system->copyRectToOverlay(buffer, 100, 270, 175, 100, 50); + g_system->copyRectToOverlay(buffer, 200, 270, 175, 100, 50); g_system->updateScreen(); g_system->delayMillis(1000); diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 7817725664..1ed5a3308a 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -422,8 +422,8 @@ void VectorRendererSpec<PixelType>:: copyFrame(OSystem *sys, const Common::Rect &r) { sys->copyRectToOverlay( - (const OverlayColor *)_activeSurface->getBasePtr(r.left, r.top), - _activeSurface->pitch / _activeSurface->format.bytesPerPixel, + _activeSurface->getBasePtr(r.left, r.top), + _activeSurface->pitch, r.left, r.top, r.width(), r.height() ); } diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 1bf7ad3c85..e37022f5f1 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -429,7 +429,7 @@ bool ThemeEngine::init() { void ThemeEngine::clearAll() { if (_initOk) { _system->clearOverlay(); - _system->grabOverlay((OverlayColor *)_screen.pixels, _screen.w); + _system->grabOverlay(_screen.pixels, _screen.pitch); } } |