mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-22 01:57:16 +00:00
BACKENDS: Let copyRectToScreen take a "const void *" instead of "const byte *" as buffer.
This removes the need to convert the parameter to copyRectToScreen to "const byte *", which is commonly used in games, which use Graphics::Surface to store their graphics data.
This commit is contained in:
parent
f917db972e
commit
31880186e1
@ -60,7 +60,7 @@ public:
|
||||
virtual int16 getWidth() = 0;
|
||||
virtual void setPalette(const byte *colors, uint start, uint num) = 0;
|
||||
virtual void grabPalette(byte *colors, uint start, uint num) = 0;
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) = 0;
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) = 0;
|
||||
virtual Graphics::Surface *lockScreen() = 0;
|
||||
virtual void unlockScreen() = 0;
|
||||
virtual void fillScreen(uint32 col) = 0;
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
int16 getWidth() { return 0; }
|
||||
void setPalette(const byte *colors, uint start, uint num) {}
|
||||
void grabPalette(byte *colors, uint start, uint num) {}
|
||||
void copyRectToScreen(const byte *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) {}
|
||||
Graphics::Surface *lockScreen() { return NULL; }
|
||||
void unlockScreen() {}
|
||||
void fillScreen(uint32 col) {}
|
||||
|
@ -349,14 +349,14 @@ void OpenGLGraphicsManager::grabPalette(byte *colors, uint start, uint num) {
|
||||
memcpy(colors, _gamePalette + start * 3, num * 3);
|
||||
}
|
||||
|
||||
void OpenGLGraphicsManager::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
|
||||
void OpenGLGraphicsManager::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
||||
assert(x >= 0 && x < _screenData.w);
|
||||
assert(y >= 0 && y < _screenData.h);
|
||||
assert(h > 0 && y + h <= _screenData.h);
|
||||
assert(w > 0 && x + w <= _screenData.w);
|
||||
|
||||
// Copy buffer data to game screen internal buffer
|
||||
const byte *src = buf;
|
||||
const byte *src = (const byte *)buf;
|
||||
byte *dst = (byte *)_screenData.pixels + y * _screenData.pitch + x * _screenData.format.bytesPerPixel;
|
||||
for (int i = 0; i < h; i++) {
|
||||
memcpy(dst, src, w * _screenData.format.bytesPerPixel);
|
||||
|
@ -84,7 +84,7 @@ protected:
|
||||
virtual void grabPalette(byte *colors, uint start, uint num);
|
||||
|
||||
public:
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
virtual void fillScreen(uint32 col);
|
||||
|
@ -1227,9 +1227,9 @@ void SurfaceSdlGraphicsManager::setAspectRatioCorrection(bool enable) {
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceSdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) {
|
||||
void SurfaceSdlGraphicsManager::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
||||
assert(_transactionMode == kTransactionNone);
|
||||
assert(src);
|
||||
assert(buf);
|
||||
|
||||
if (_screen == NULL) {
|
||||
warning("SurfaceSdlGraphicsManager::copyRectToScreen: _screen == NULL");
|
||||
@ -1252,8 +1252,9 @@ void SurfaceSdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int
|
||||
#ifdef USE_RGB_COLOR
|
||||
byte *dst = (byte *)_screen->pixels + y * _screen->pitch + x * _screenFormat.bytesPerPixel;
|
||||
if (_videoMode.screenWidth == w && pitch == _screen->pitch) {
|
||||
memcpy(dst, src, h*pitch);
|
||||
memcpy(dst, buf, h*pitch);
|
||||
} else {
|
||||
const byte *src = (const byte *)buf;
|
||||
do {
|
||||
memcpy(dst, src, w * _screenFormat.bytesPerPixel);
|
||||
src += pitch;
|
||||
@ -1263,8 +1264,9 @@ void SurfaceSdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int
|
||||
#else
|
||||
byte *dst = (byte *)_screen->pixels + y * _screen->pitch + x;
|
||||
if (_screen->pitch == pitch && pitch == w) {
|
||||
memcpy(dst, src, h*w);
|
||||
memcpy(dst, buf, h*w);
|
||||
} else {
|
||||
const byte *src = (const byte *)buf;
|
||||
do {
|
||||
memcpy(dst, src, w);
|
||||
src += pitch;
|
||||
|
@ -111,7 +111,7 @@ protected:
|
||||
virtual void grabPalette(byte *colors, uint start, uint num);
|
||||
|
||||
public:
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
virtual void fillScreen(uint32 col);
|
||||
|
@ -1071,15 +1071,16 @@ void WINCESdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pit
|
||||
SDL_UnlockSurface(_overlayscreen);
|
||||
}
|
||||
|
||||
void WINCESdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) {
|
||||
void WINCESdlGraphicsManager::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
||||
assert(_transactionMode == kTransactionNone);
|
||||
assert(src);
|
||||
assert(buf);
|
||||
|
||||
if (_screen == NULL)
|
||||
return;
|
||||
|
||||
Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
|
||||
|
||||
const byte *src = (const byte *)buf;
|
||||
/* Clip the coordinates */
|
||||
if (x < 0) {
|
||||
w += x;
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
bool showMouse(bool visible);
|
||||
void setMouseCursor(const byte *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 copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h); // overloaded by CE backend (FIXME)
|
||||
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();
|
||||
void blitCursor();
|
||||
|
@ -124,7 +124,7 @@ PaletteManager *ModularBackend::getPaletteManager() {
|
||||
return _graphicsManager;
|
||||
}
|
||||
|
||||
void ModularBackend::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
|
||||
void ModularBackend::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
||||
_graphicsManager->copyRectToScreen(buf, pitch, x, y, w, h);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
virtual int16 getHeight();
|
||||
virtual int16 getWidth();
|
||||
virtual PaletteManager *getPaletteManager();
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
virtual void fillScreen(uint32 col);
|
||||
|
@ -244,7 +244,7 @@ protected:
|
||||
virtual void grabPalette(byte *colors, uint start, uint num);
|
||||
|
||||
public:
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y,
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
|
||||
int w, int h);
|
||||
virtual void updateScreen();
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
|
@ -421,7 +421,7 @@ void OSystem_Android::grabPalette(byte *colors, uint start, uint num) {
|
||||
pf.colorToRGB(READ_UINT16(p), colors[0], colors[1], colors[2]);
|
||||
}
|
||||
|
||||
void OSystem_Android::copyRectToScreen(const byte *buf, int pitch,
|
||||
void OSystem_Android::copyRectToScreen(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);
|
||||
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
|
||||
// Draw a bitmap to screen.
|
||||
// The screen will not be updated to reflect the new bitmap
|
||||
void copyRectToScreen(const byte *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);
|
||||
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
@ -260,7 +260,7 @@ void OSystem_Dreamcast::initSize(uint w, uint h, const Graphics::PixelFormat *fo
|
||||
_devpoll = Timer();
|
||||
}
|
||||
|
||||
void OSystem_Dreamcast::copyRectToScreen(const byte *buf, int pitch, int x, int y,
|
||||
void OSystem_Dreamcast::copyRectToScreen(const void *buf, int pitch, int x, int y,
|
||||
int w, int h)
|
||||
{
|
||||
if (w<1 || h<1)
|
||||
@ -269,10 +269,11 @@ void OSystem_Dreamcast::copyRectToScreen(const byte *buf, int pitch, int x, int
|
||||
x<<=1; w<<=1;
|
||||
}
|
||||
unsigned char *dst = screen + y*SCREEN_W*2 + x;
|
||||
const byte *src = (const byte *)buf;
|
||||
do {
|
||||
memcpy(dst, buf, w);
|
||||
memcpy(dst, src, w);
|
||||
dst += SCREEN_W*2;
|
||||
buf += pitch;
|
||||
src += pitch;
|
||||
} while (--h);
|
||||
_screen_dirty = true;
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) {
|
||||
|
||||
#define MISALIGNED16(ptr) (((u32) (ptr) & 1) != 0)
|
||||
|
||||
void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
|
||||
void OSystem_DS::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
||||
if (!_graphicsEnable) return;
|
||||
if (w <= 1) return;
|
||||
if (h < 0) return;
|
||||
|
@ -98,7 +98,7 @@ protected:
|
||||
public:
|
||||
void restoreHardwarePalette();
|
||||
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void updateScreen();
|
||||
virtual void setShakePos(int shakeOffset);
|
||||
|
||||
|
@ -143,7 +143,7 @@ protected:
|
||||
virtual void grabPalette(byte *colors, uint start, uint num);
|
||||
|
||||
public:
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void updateScreen();
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
@ -161,18 +161,19 @@ void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) {
|
||||
}
|
||||
}
|
||||
|
||||
void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
|
||||
void OSystem_IPHONE::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
||||
//printf("copyRectToScreen(%p, %d, %i, %i, %i, %i)\n", buf, pitch, x, y, w, h);
|
||||
//Clip the coordinates
|
||||
const byte *src = (const byte *)buf;
|
||||
if (x < 0) {
|
||||
w += x;
|
||||
buf -= x;
|
||||
src -= x;
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
h += y;
|
||||
buf -= y * pitch;
|
||||
src -= y * pitch;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
@ -193,11 +194,11 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
|
||||
|
||||
byte *dst = (byte *)_framebuffer.getBasePtr(x, y);
|
||||
if (_framebuffer.pitch == pitch && _framebuffer.w == w) {
|
||||
memcpy(dst, buf, h * pitch);
|
||||
memcpy(dst, src, h * pitch);
|
||||
} else {
|
||||
do {
|
||||
memcpy(dst, buf, w * _framebuffer.format.bytesPerPixel);
|
||||
buf += pitch;
|
||||
memcpy(dst, src, w * _framebuffer.format.bytesPerPixel);
|
||||
src += pitch;
|
||||
dst += _framebuffer.pitch;
|
||||
} while (--h);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ protected:
|
||||
virtual void grabPalette(byte *colors, uint start, uint num);
|
||||
|
||||
public:
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void updateScreen();
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
@ -442,17 +442,18 @@ void OSystem_N64::setCursorPalette(const byte *colors, uint start, uint num) {
|
||||
_dirtyOffscreen = true;
|
||||
}
|
||||
|
||||
void OSystem_N64::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
|
||||
void OSystem_N64::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
||||
//Clip the coordinates
|
||||
const byte *src = (const byte *)buf;
|
||||
if (x < 0) {
|
||||
w += x;
|
||||
buf -= x;
|
||||
src -= x;
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
h += y;
|
||||
buf -= y * pitch;
|
||||
src -= y * pitch;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
@ -472,14 +473,14 @@ void OSystem_N64::copyRectToScreen(const byte *buf, int pitch, int x, int y, int
|
||||
|
||||
do {
|
||||
for (int hor = 0; hor < w; hor++) {
|
||||
if (dst_pal[hor] != buf[hor]) {
|
||||
uint16 color = _screenPalette[buf[hor]];
|
||||
if (dst_pal[hor] != src[hor]) {
|
||||
uint16 color = _screenPalette[src[hor]];
|
||||
dst_hicol[hor] = color; // Save image converted to 16-bit
|
||||
dst_pal[hor] = buf[hor]; // Save palettized display
|
||||
dst_pal[hor] = src[hor]; // Save palettized display
|
||||
}
|
||||
}
|
||||
|
||||
buf += pitch;
|
||||
src += pitch;
|
||||
dst_pal += _screenWidth;
|
||||
dst_hicol += _screenWidth;
|
||||
} while (--h);
|
||||
|
@ -554,7 +554,7 @@ void OSystem_PS2::grabPalette(byte *colors, uint start, uint num) {
|
||||
_screen->grabPalette(colors, (uint8)start, (uint16)num);
|
||||
}
|
||||
|
||||
void OSystem_PS2::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
|
||||
void OSystem_PS2::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
||||
_screen->copyScreenRect((const uint8*)buf, pitch, x, y, w, h);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ protected:
|
||||
virtual void grabPalette(byte *colors, uint start, uint num);
|
||||
public:
|
||||
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
|
||||
virtual void setShakePos(int shakeOffset);
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
|
@ -204,11 +204,11 @@ void OSystem_PSP::setCursorPalette(const byte *colors, uint start, uint num) {
|
||||
_cursor.clearKeyColor(); // Do we need this?
|
||||
}
|
||||
|
||||
void OSystem_PSP::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
|
||||
void OSystem_PSP::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
|
||||
DEBUG_ENTER_FUNC();
|
||||
_displayManager.waitUntilRenderFinished();
|
||||
_pendingUpdate = false;
|
||||
_screen.copyFromRect(buf, pitch, x, y, w, h);
|
||||
_screen.copyFromRect((const byte *)buf, pitch, x, y, w, h);
|
||||
}
|
||||
|
||||
Graphics::Surface *OSystem_PSP::lockScreen() {
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
void setCursorPalette(const byte *colors, uint start, uint num);
|
||||
|
||||
// Screen related
|
||||
void copyRectToScreen(const byte *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);
|
||||
Graphics::Surface *lockScreen();
|
||||
void unlockScreen();
|
||||
void updateScreen();
|
||||
|
@ -167,7 +167,7 @@ protected:
|
||||
virtual void grabPalette(byte *colors, uint start, uint num);
|
||||
public:
|
||||
virtual void setCursorPalette(const byte *colors, uint start, uint num);
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y,
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
|
||||
int w, int h);
|
||||
virtual void updateScreen();
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
|
@ -395,7 +395,7 @@ void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) {
|
||||
_cursorPaletteDirty = true;
|
||||
}
|
||||
|
||||
void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y,
|
||||
void OSystem_Wii::copyRectToScreen(const void *buf, int pitch, int x, int y,
|
||||
int w, int h) {
|
||||
assert(x >= 0 && x < _gameWidth);
|
||||
assert(y >= 0 && y < _gameHeight);
|
||||
@ -407,7 +407,7 @@ void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y,
|
||||
if (!Graphics::crossBlit(_gamePixels +
|
||||
y * _gameWidth * _pfGame.bytesPerPixel +
|
||||
x * _pfGame.bytesPerPixel,
|
||||
buf, _gameWidth * _pfGame.bytesPerPixel,
|
||||
(const byte *)buf, _gameWidth * _pfGame.bytesPerPixel,
|
||||
pitch, w, h, _pfGameTexture, _pfGame)) {
|
||||
printf("crossBlit failed\n");
|
||||
::abort();
|
||||
@ -418,9 +418,10 @@ void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y,
|
||||
if (_gameWidth == pitch && pitch == w) {
|
||||
memcpy(dst, buf, h * w);
|
||||
} else {
|
||||
const byte *src = (const byte *)buf;
|
||||
do {
|
||||
memcpy(dst, buf, w);
|
||||
buf += pitch;
|
||||
memcpy(dst, src, w);
|
||||
src += pitch;
|
||||
dst += _gameWidth;
|
||||
} while (--h);
|
||||
}
|
||||
|
@ -657,7 +657,7 @@ public:
|
||||
* @see updateScreen
|
||||
* @see getScreenFormat
|
||||
*/
|
||||
virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) = 0;
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) = 0;
|
||||
|
||||
/**
|
||||
* Lock the active screen framebuffer and return a Graphics::Surface
|
||||
|
Loading…
x
Reference in New Issue
Block a user