aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/3ds/osystem-graphics.cpp2
-rw-r--r--backends/platform/3ds/osystem.h2
-rw-r--r--backends/platform/android/android.h2
-rw-r--r--backends/platform/android/gfx.cpp2
-rw-r--r--backends/platform/dc/dc.h2
-rw-r--r--backends/platform/dc/display.cpp2
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp2
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h2
-rw-r--r--backends/platform/ios7/ios7_app_delegate.mm15
-rw-r--r--backends/platform/ios7/ios7_common.h1
-rw-r--r--backends/platform/ios7/ios7_osys_main.cpp4
-rw-r--r--backends/platform/ios7/ios7_osys_main.h2
-rw-r--r--backends/platform/ios7/ios7_osys_video.mm47
-rw-r--r--backends/platform/ios7/ios7_video.mm19
-rw-r--r--backends/platform/iphone/osys_main.h2
-rw-r--r--backends/platform/iphone/osys_video.mm2
-rw-r--r--backends/platform/n64/osys_n64.h2
-rw-r--r--backends/platform/n64/osys_n64_base.cpp2
-rw-r--r--backends/platform/ps2/Gs2dScreen.cpp2
-rw-r--r--backends/platform/ps2/Gs2dScreen.h2
-rw-r--r--backends/platform/ps2/systemps2.cpp2
-rw-r--r--backends/platform/ps2/systemps2.h2
-rw-r--r--backends/platform/psp/default_display_client.h6
-rw-r--r--backends/platform/psp/display_client.cpp6
-rw-r--r--backends/platform/psp/display_client.h42
-rw-r--r--backends/platform/psp/osys_psp.cpp2
-rw-r--r--backends/platform/psp/osys_psp.h2
-rw-r--r--backends/platform/psp/psppixelformat.cpp2
-rw-r--r--backends/platform/psp/psppixelformat.h14
-rw-r--r--backends/platform/sdl/riscos/riscos.cpp12
-rw-r--r--backends/platform/sdl/sdl-window.cpp52
-rw-r--r--backends/platform/sdl/sdl-window.h20
-rw-r--r--backends/platform/sdl/sdl.cpp12
-rw-r--r--backends/platform/sdl/sdl.h2
-rw-r--r--backends/platform/wii/osystem.h2
-rw-r--r--backends/platform/wii/osystem_gfx.cpp2
36 files changed, 196 insertions, 100 deletions
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index 78b7907fe6..e791dd4c21 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -230,7 +230,7 @@ void OSystem_3DS::setPalette(const byte *colors, uint start, uint num) {
flushGameScreen();
}
}
-void OSystem_3DS::grabPalette(byte *colors, uint start, uint num) {
+void OSystem_3DS::grabPalette(byte *colors, uint start, uint num) const {
assert(start + num <= 256);
memcpy(colors, _palette + 3 * start, 3 * num);
}
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
index 5df49fe593..cad46a18dc 100644
--- a/backends/platform/3ds/osystem.h
+++ b/backends/platform/3ds/osystem.h
@@ -105,7 +105,7 @@ public:
int16 getHeight(){ return _gameHeight; }
int16 getWidth(){ return _gameWidth; }
void setPalette(const byte *colors, uint start, uint num);
- void grabPalette(byte *colors, uint start, uint num);
+ void grabPalette(byte *colors, uint start, uint num) const;
void copyRectToScreen(const void *buf, int pitch, int x, int y, int w,
int h);
Graphics::Surface *lockScreen();
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 2935d96381..c261f85325 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -234,7 +234,7 @@ private:
protected:
// PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
- virtual void grabPalette(byte *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num) const;
public:
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp
index f847296892..a4f1746cb7 100644
--- a/backends/platform/android/gfx.cpp
+++ b/backends/platform/android/gfx.cpp
@@ -408,7 +408,7 @@ void OSystem_Android::setPalette(const byte *colors, uint start, uint num) {
WRITE_UINT16(p, pf.RGBToColor(colors[0], colors[1], colors[2]));
}
-void OSystem_Android::grabPalette(byte *colors, uint start, uint num) {
+void OSystem_Android::grabPalette(byte *colors, uint start, uint num) const {
ENTER("%p, %u, %u", colors, start, num);
#ifdef USE_RGB_COLOR
diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h
index 6cd938ec9c..34e8014ed9 100644
--- a/backends/platform/dc/dc.h
+++ b/backends/platform/dc/dc.h
@@ -106,7 +106,7 @@ class OSystem_Dreamcast : private DCHardware, public EventsBaseBackend, public P
protected:
// PaletteManager API
void setPalette(const byte *colors, uint start, uint num);
- void grabPalette(byte *colors, uint start, uint num);
+ void grabPalette(byte *colors, uint start, uint num) const;
public:
diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp
index 1785c3c416..2547605398 100644
--- a/backends/platform/dc/display.cpp
+++ b/backends/platform/dc/display.cpp
@@ -171,7 +171,7 @@ void OSystem_Dreamcast::setCursorPalette(const byte *colors, uint start, uint nu
_enable_cursor_palette = true;
}
-void OSystem_Dreamcast::grabPalette(byte *colors, uint start, uint num)
+void OSystem_Dreamcast::grabPalette(byte *colors, uint start, uint num) const
{
const unsigned short *src = palette + start;
if (num>0)
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index f23192cd9d..861ee2e0c5 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -268,7 +268,7 @@ void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) {
refreshCursor();
}
-void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) {
+void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) const {
// consolePrintf("Grabpalette");
for (unsigned int r = start; r < start + num; r++) {
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index 9f73e125c2..f883bd14d1 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -93,7 +93,7 @@ public:
protected:
// PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
- virtual void grabPalette(byte *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num) const;
public:
void restoreHardwarePalette();
diff --git a/backends/platform/ios7/ios7_app_delegate.mm b/backends/platform/ios7/ios7_app_delegate.mm
index 88d0a8925e..014275d116 100644
--- a/backends/platform/ios7/ios7_app_delegate.mm
+++ b/backends/platform/ios7/ios7_app_delegate.mm
@@ -39,14 +39,6 @@
return self;
}
-- (void)mainLoop:(id)param {
- @autoreleasepool {
- iOS7_main(iOS7_argc, iOS7_argv);
- }
-
- exit(0);
-}
-
- (void)applicationDidFinishLaunching:(UIApplication *)application {
CGRect rect = [[UIScreen mainScreen] bounds];
@@ -78,7 +70,12 @@
name:@"UIDeviceOrientationDidChangeNotification"
object:nil];
- [NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil];
+ // Force creation of the shared instance on the main thread
+ iOS7_buildSharedOSystemInstance();
+
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
+ iOS7_main(iOS7_argc, iOS7_argv);
+ });
}
- (void)applicationWillResignActive:(UIApplication *)application {
diff --git a/backends/platform/ios7/ios7_common.h b/backends/platform/ios7/ios7_common.h
index 3609387efd..d5c1135564 100644
--- a/backends/platform/ios7/ios7_common.h
+++ b/backends/platform/ios7/ios7_common.h
@@ -122,6 +122,7 @@ void iOS7_updateScreen();
bool iOS7_fetchEvent(InternalEvent *event);
bool iOS7_isBigDevice();
+void iOS7_buildSharedOSystemInstance();
void iOS7_main(int argc, char **argv);
const char *iOS7_getDocumentsDir();
bool iOS7_touchpadModeEnabled();
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 3a627478f9..90c294a7d5 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -365,6 +365,10 @@ bool iOS7_touchpadModeEnabled() {
return sys && sys->touchpadModeEnabled();
}
+void iOS7_buildSharedOSystemInstance() {
+ OSystem_iOS7::sharedInstance();
+}
+
void iOS7_main(int argc, char **argv) {
//OSystem_iOS7::migrateApp();
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index 0f89cf7aa5..e0ac599b1d 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -153,7 +153,7 @@ public:
protected:
// PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
- virtual void grabPalette(byte *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num) const;
public:
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm
index 1ec0defd7e..30f8950ec6 100644
--- a/backends/platform/ios7/ios7_osys_video.mm
+++ b/backends/platform/ios7/ios7_osys_video.mm
@@ -120,6 +120,15 @@ Common::List<Graphics::PixelFormat> OSystem_iOS7::getSupportedFormats() const {
}
#endif
+static inline void execute_on_main_thread(void (^block)(void)) {
+ if ([NSThread currentThread] == [NSThread mainThread]) {
+ block();
+ }
+ else {
+ dispatch_sync(dispatch_get_main_queue(), block);
+ }
+}
+
void OSystem_iOS7::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
//printf("initSize(%u, %u, %p)\n", width, height, (const void *)format);
@@ -135,7 +144,9 @@ void OSystem_iOS7::initSize(uint width, uint height, const Graphics::PixelFormat
// Create the screen texture right here. We need to do this here, since
// when a game requests hi-color mode, we actually set the framebuffer
// to the texture buffer to avoid an additional copy step.
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(createScreenTexture) withObject:nil waitUntilDone: YES];
+ execute_on_main_thread(^ {
+ [[iOS7AppDelegate iPhoneView] createScreenTexture];
+ });
// In case the client code tries to set up a non supported mode, we will
// fall back to CLUT8 and set the transaction error accordingly.
@@ -172,13 +183,17 @@ void OSystem_iOS7::beginGFXTransaction() {
OSystem::TransactionError OSystem_iOS7::endGFXTransaction() {
_screenChangeCount++;
updateOutputSurface();
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES];
+ execute_on_main_thread(^ {
+ [[iOS7AppDelegate iPhoneView] setGraphicsMode];
+ });
return _gfxTransactionError;
}
void OSystem_iOS7::updateOutputSurface() {
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES];
+ execute_on_main_thread(^ {
+ [[iOS7AppDelegate iPhoneView] initSurface];
+ });
}
int16 OSystem_iOS7::getHeight() {
@@ -208,7 +223,7 @@ void OSystem_iOS7::setPalette(const byte *colors, uint start, uint num) {
_mouseDirty = _mouseNeedTextureUpdate = true;
}
-void OSystem_iOS7::grabPalette(byte *colors, uint start, uint num) {
+void OSystem_iOS7::grabPalette(byte *colors, uint start, uint num) const {
//printf("grabPalette(%p, %u, %u)\n", colors, start, num);
assert(start + num <= 256);
byte *b = colors;
@@ -338,7 +353,9 @@ void OSystem_iOS7::unlockScreen() {
void OSystem_iOS7::setShakePos(int shakeOffset) {
//printf("setShakePos(%i)\n", shakeOffset);
_videoContext->shakeOffsetY = shakeOffset;
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES];
+ execute_on_main_thread(^ {
+ [[iOS7AppDelegate iPhoneView] setViewTransformation];
+ });
// HACK: We use this to force a redraw.
_mouseDirty = true;
}
@@ -348,8 +365,10 @@ void OSystem_iOS7::showOverlay() {
_videoContext->overlayVisible = true;
dirtyFullOverlayScreen();
updateScreen();
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES];
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
+ execute_on_main_thread(^ {
+ [[iOS7AppDelegate iPhoneView] updateMouseCursorScaling];
+ [[iOS7AppDelegate iPhoneView] clearColorBuffer];
+ });
}
void OSystem_iOS7::hideOverlay() {
@@ -357,8 +376,10 @@ void OSystem_iOS7::hideOverlay() {
_videoContext->overlayVisible = false;
_dirtyOverlayRects.clear();
dirtyFullScreen();
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES];
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
+ execute_on_main_thread(^ {
+ [[iOS7AppDelegate iPhoneView] updateMouseCursorScaling];
+ [[iOS7AppDelegate iPhoneView] clearColorBuffer];
+ });
}
void OSystem_iOS7::clearOverlay() {
@@ -439,7 +460,9 @@ void OSystem_iOS7::warpMouse(int x, int y) {
//printf("warpMouse(%d, %d)\n", x, y);
_videoContext->mouseX = x;
_videoContext->mouseY = y;
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(notifyMouseMove) withObject:nil waitUntilDone: YES];
+ execute_on_main_thread(^ {
+ [[iOS7AppDelegate iPhoneView] notifyMouseMove];
+ });
_mouseDirty = true;
}
@@ -552,5 +575,7 @@ void OSystem_iOS7::updateMouseTexture() {
}
}
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES];
+ execute_on_main_thread(^ {
+ [[iOS7AppDelegate iPhoneView] updateMouseCursor];
+ });
}
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 5baa83e8e8..85a4dc91d8 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -55,16 +55,31 @@ bool iOS7_isBigDevice() {
return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
}
+static inline void execute_on_main_thread(void (^block)(void)) {
+ if ([NSThread currentThread] == [NSThread mainThread]) {
+ block();
+ }
+ else {
+ dispatch_sync(dispatch_get_main_queue(), block);
+ }
+}
+
void iOS7_updateScreen() {
//printf("Mouse: (%i, %i)\n", mouseX, mouseY);
if (!g_needsScreenUpdate) {
g_needsScreenUpdate = 1;
- [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO];
+ execute_on_main_thread(^{
+ [[iOS7AppDelegate iPhoneView] updateSurface];
+ });
}
}
bool iOS7_fetchEvent(InternalEvent *event) {
- return [[iOS7AppDelegate iPhoneView] fetchEvent:event];
+ __block bool fetched;
+ execute_on_main_thread(^{
+ fetched = [[iOS7AppDelegate iPhoneView] fetchEvent:event];
+ });
+ return fetched;
}
uint getSizeNextPOT(uint size) {
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index 390566322c..6aa77e291d 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -140,7 +140,7 @@ public:
protected:
// PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
- virtual void grabPalette(byte *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num) const;
public:
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index fa5c729a1c..f07160d350 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -155,7 +155,7 @@ void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) {
_mouseDirty = _mouseNeedTextureUpdate = true;
}
-void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) {
+void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) const {
//printf("grabPalette(%p, %u, %u)\n", colors, start, num);
assert(start + num <= 256);
byte *b = colors;
diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h
index ad49c2981f..80bedbb5ab 100644
--- a/backends/platform/n64/osys_n64.h
+++ b/backends/platform/n64/osys_n64.h
@@ -157,7 +157,7 @@ public:
protected:
// PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
- virtual void grabPalette(byte *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num) const;
public:
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp
index 16eeae5b7e..1282b16d47 100644
--- a/backends/platform/n64/osys_n64_base.cpp
+++ b/backends/platform/n64/osys_n64_base.cpp
@@ -408,7 +408,7 @@ void OSystem_N64::rebuildOffscreenMouseBuffer(void) {
}
}
-void OSystem_N64::grabPalette(byte *colors, uint start, uint num) {
+void OSystem_N64::grabPalette(byte *colors, uint start, uint num) const {
#ifdef N64_EXTREME_MEMORY_SAVING // This way loses precisions
uint32 i;
uint16 color;
diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp
index a4ec23329a..823defe8b4 100644
--- a/backends/platform/ps2/Gs2dScreen.cpp
+++ b/backends/platform/ps2/Gs2dScreen.cpp
@@ -556,7 +556,7 @@ void Gs2dScreen::setPalette(const uint8 *pal, uint8 start, uint16 num) {
SignalSema(g_DmacSema);
}
-void Gs2dScreen::grabPalette(uint8 *pal, uint8 start, uint16 num) {
+void Gs2dScreen::grabPalette(uint8 *pal, uint8 start, uint16 num) const {
assert(start + num <= 256);
for (uint16 cnt = 0; cnt < num; cnt++) {
uint16 src = start + cnt;
diff --git a/backends/platform/ps2/Gs2dScreen.h b/backends/platform/ps2/Gs2dScreen.h
index ea2b1e5f78..9ed62da2d0 100644
--- a/backends/platform/ps2/Gs2dScreen.h
+++ b/backends/platform/ps2/Gs2dScreen.h
@@ -61,7 +61,7 @@ public:
void copyScreenRect(const uint8 *buf, int pitch, int x, int y, int w, int h);
void setPalette(const uint8 *pal, uint8 start, uint16 num);
void updateScreen(void);
- void grabPalette(uint8 *pal, uint8 start, uint16 num);
+ void grabPalette(uint8 *pal, uint8 start, uint16 num) const;
//- overlay routines
void copyOverlayRect(const byte *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h);
void grabOverlay(byte *buf, uint16 pitch);
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index e914cdb9c9..f76e26a543 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -678,7 +678,7 @@ void OSystem_PS2::setPalette(const byte *colors, uint start, uint num) {
_screen->setPalette(colors, (uint8)start, (uint16)num);
}
-void OSystem_PS2::grabPalette(byte *colors, uint start, uint num) {
+void OSystem_PS2::grabPalette(byte *colors, uint start, uint num) const {
_screen->grabPalette(colors, (uint8)start, (uint16)num);
}
diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h
index 45b7dfae36..019c3634a0 100644
--- a/backends/platform/ps2/systemps2.h
+++ b/backends/platform/ps2/systemps2.h
@@ -61,7 +61,7 @@ public:
protected:
// PaletteManager API
virtual void setPalette(const byte *colors, uint start, uint num);
- virtual void grabPalette(byte *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num) const;
public:
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h);
diff --git a/backends/platform/psp/default_display_client.h b/backends/platform/psp/default_display_client.h
index d46b7f1a8a..f2972e0b49 100644
--- a/backends/platform/psp/default_display_client.h
+++ b/backends/platform/psp/default_display_client.h
@@ -40,10 +40,10 @@ public:
void clearBuffer();
void clearPalette();
void render() { _renderer.render(); }
- uint32 getWidth() { return _buffer.getSourceWidth(); }
- uint32 getHeight() { return _buffer.getSourceHeight(); }
+ uint32 getWidth() const { return _buffer.getSourceWidth(); }
+ uint32 getHeight() const { return _buffer.getSourceHeight(); }
void setPartialPalette(const byte *colors, uint start, uint num) { setDirty(); return _palette.setPartial(colors, start, num); }
- void getPartialPalette(byte *colors, uint start, uint num) {
+ void getPartialPalette(byte *colors, uint start, uint num) const {
return _palette.getPartial(colors, start, num);
}
void copyFromRect(const byte *buf, int pitch, int destX, int destY, int recWidth, int recHeight);
diff --git a/backends/platform/psp/display_client.cpp b/backends/platform/psp/display_client.cpp
index b238631e62..6e1ae9a10a 100644
--- a/backends/platform/psp/display_client.cpp
+++ b/backends/platform/psp/display_client.cpp
@@ -204,7 +204,7 @@ void Palette::deallocate() {
// Copy some of the palette to an array of colors
//
-void Palette::getPartial(byte *colors, uint start, uint num) {
+void Palette::getPartial(byte *colors, uint start, uint num) const {
DEBUG_ENTER_FUNC();
assert(_values);
@@ -286,13 +286,13 @@ void Palette::print(uint32 numToPrint /* = 0 */) {
}
}
-uint32 Palette::getRawColorAt(uint32 position) {
+uint32 Palette::getRawColorAt(uint32 position) const {
byte *pcolor = &_values[_pixelFormat.pixelsToBytes(position)];
uint32 color = _pixelFormat.getColorValueAt(pcolor);
return color;
}
-uint32 Palette::getRGBAColorAt(uint32 position) {
+uint32 Palette::getRGBAColorAt(uint32 position) const {
uint32 color = getRawColorAt(position);
uint32 r, g, b, a;
_pixelFormat.colorToRgba(color, r, g, b, a);
diff --git a/backends/platform/psp/display_client.h b/backends/platform/psp/display_client.h
index 5e81947e20..a25d9f9ecc 100644
--- a/backends/platform/psp/display_client.h
+++ b/backends/platform/psp/display_client.h
@@ -85,18 +85,19 @@ public:
void clear();
void setPixelFormats(PSPPixelFormat::Type paletteType, PSPPixelFormat::Type bufferType, bool swapRedBlue = false);
void setNumOfEntries(uint32 num) { _numOfEntries = num; }
- uint32 getNumOfEntries() { return _numOfEntries; }
- uint32 getSizeInBytes() { return _pixelFormat.pixelsToBytes(_numOfEntries); }
+ uint32 getNumOfEntries() const { return _numOfEntries; }
+ uint32 getSizeInBytes() const { return _pixelFormat.pixelsToBytes(_numOfEntries); }
void set(byte *values) { setPartial(values, 0, _numOfEntries); }
void setPartial(const byte *colors, uint start, uint num, bool supportsAlpha = false);
- void getPartial(byte *colors, uint start, uint num);
- uint32 getRawColorAt(uint32 position);
- uint32 getRGBAColorAt(uint32 position);
+ void getPartial(byte *colors, uint start, uint num) const;
+ uint32 getRawColorAt(uint32 position) const;
+ uint32 getRGBAColorAt(uint32 position) const;
void setSingleColorRGBA(uint32 num, byte r, byte g, byte b, byte a);
void setColorPositionAlpha(uint32 position, bool alpha);
+ const byte *getRawValues() const { return _values; }
byte *getRawValues() { return _values; }
- bool isAllocated() { return (_values != 0); }
- PSPPixelFormat::Type getPixelFormat() { return _pixelFormat.format; }
+ bool isAllocated() const { return (_values != 0); }
+ PSPPixelFormat::Type getPixelFormat() const { return _pixelFormat.format; }
void print(uint32 numToPrint = 0); // print to screen
protected:
@@ -127,19 +128,20 @@ public:
void setPixelFormat(PSPPixelFormat::Type type, bool swapRedBlue = false);
// getters
- uint32 getWidth() { return _width; }
- uint32 getWidthInBytes() { return _pixelFormat.pixelsToBytes(getWidth()); }
- uint32 getHeight() { return _height; }
- uint32 getSourceWidth() { return _sourceSize.width; }
- uint32 getSourceWidthInBytes() { return _pixelFormat.pixelsToBytes(_sourceSize.width); }
- uint32 getSourceHeight() { return _sourceSize.height; }
- uint32 getTextureWidth() { return _textureSize.width; }
- uint32 getTextureHeight() { return _textureSize.height; }
- PSPPixelFormat::Type getPixelFormat() { return _pixelFormat.format; }
- uint32 getBitsPerPixel() { return _pixelFormat.bitsPerPixel; }
- uint32 getBytesPerPixel() { return getBitsPerPixel() >> 3; } /* won't work for 4-bit */
+ uint32 getWidth() const { return _width; }
+ uint32 getWidthInBytes() const { return _pixelFormat.pixelsToBytes(getWidth()); }
+ uint32 getHeight() const { return _height; }
+ uint32 getSourceWidth() const { return _sourceSize.width; }
+ uint32 getSourceWidthInBytes() const { return _pixelFormat.pixelsToBytes(_sourceSize.width); }
+ uint32 getSourceHeight() const { return _sourceSize.height; }
+ uint32 getTextureWidth() const { return _textureSize.width; }
+ uint32 getTextureHeight() const { return _textureSize.height; }
+ PSPPixelFormat::Type getPixelFormat() const { return _pixelFormat.format; }
+ uint32 getBitsPerPixel() const { return _pixelFormat.bitsPerPixel; }
+ uint32 getBytesPerPixel() const { return getBitsPerPixel() >> 3; } /* won't work for 4-bit */
+ const byte *getPixels() const { return _pixels; }
byte *getPixels() { return _pixels; }
- uint32 getSizeInBytes() { return _pixelFormat.pixelsToBytes(_width * _height); }
+ uint32 getSizeInBytes() const { return _pixelFormat.pixelsToBytes(_width * _height); }
bool hasPalette();
void copyFromArray(const byte *buffer, int pitch);
@@ -147,7 +149,7 @@ public:
void copyToArray(byte *dst, int pitch);
bool allocate(bool inVram = false);
void deallocate();
- bool isAllocated() { return (_pixels != 0) ; }
+ bool isAllocated() const { return (_pixels != 0) ; }
void clear();
void flipNibbles(); // To handle peculiarities of PSP's 4 bit textures
static uint32 scaleUpToPowerOfTwo(uint32 size);
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 67cb72d9d4..e31456fb70 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -280,7 +280,7 @@ int16 OSystem_PSP::getOverlayHeight() {
return (int16)_overlay.getHeight();
}
-void OSystem_PSP::grabPalette(byte *colors, uint start, uint num) {
+void OSystem_PSP::grabPalette(byte *colors, uint start, uint num) const {
DEBUG_ENTER_FUNC();
_screen.getPartialPalette(colors, start, num);
}
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index 6f9238b84e..304c724aaa 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -94,7 +94,7 @@ public:
protected:
// PaletteManager API
void setPalette(const byte *colors, uint start, uint num);
- void grabPalette(byte *colors, uint start, uint num);
+ void grabPalette(byte *colors, uint start, uint num) const;
public:
void setCursorPalette(const byte *colors, uint start, uint num);
diff --git a/backends/platform/psp/psppixelformat.cpp b/backends/platform/psp/psppixelformat.cpp
index 2d7d524b45..83f5935eee 100644
--- a/backends/platform/psp/psppixelformat.cpp
+++ b/backends/platform/psp/psppixelformat.cpp
@@ -173,7 +173,7 @@ Graphics::PixelFormat PSPPixelFormat::convertToScummvmPixelFormat(PSPPixelFormat
return pf;
}
-uint32 PSPPixelFormat::convertTo32BitColor(uint32 color) {
+uint32 PSPPixelFormat::convertTo32BitColor(uint32 color) const {
DEBUG_ENTER_FUNC();
uint32 r, g, b, a, output;
diff --git a/backends/platform/psp/psppixelformat.h b/backends/platform/psp/psppixelformat.h
index ede5a97d6f..3cb3b8fcae 100644
--- a/backends/platform/psp/psppixelformat.h
+++ b/backends/platform/psp/psppixelformat.h
@@ -55,9 +55,9 @@ struct PSPPixelFormat {
PSPPixelFormat::Type &paletteType,
bool &swapRedBlue);
static Graphics::PixelFormat convertToScummvmPixelFormat(PSPPixelFormat::Type type);
- uint32 convertTo32BitColor(uint32 color);
+ uint32 convertTo32BitColor(uint32 color) const;
- inline uint32 rgbaToColor(uint32 r, uint32 g, uint32 b, uint32 a) {
+ inline uint32 rgbaToColor(uint32 r, uint32 g, uint32 b, uint32 a) const {
uint32 color;
switch (format) {
@@ -80,7 +80,7 @@ struct PSPPixelFormat {
return color;
}
- inline void colorToRgba(uint32 color, uint32 &r, uint32 &g, uint32 &b, uint32 &a) {
+ inline void colorToRgba(uint32 color, uint32 &r, uint32 &g, uint32 &b, uint32 &a) const {
switch (format) {
case Type_4444:
a = (color >> 12) & 0xF; // Interpolate to get true colors
@@ -140,7 +140,7 @@ struct PSPPixelFormat {
return color;
}
- inline uint32 pixelsToBytes(uint32 pixels) {
+ inline uint32 pixelsToBytes(uint32 pixels) const {
switch (bitsPerPixel) {
case 4:
pixels >>= 1;
@@ -160,7 +160,7 @@ struct PSPPixelFormat {
return pixels;
}
- inline uint16 swapRedBlue16(uint16 color) {
+ inline uint16 swapRedBlue16(uint16 color) const {
uint16 output;
switch (format) {
@@ -181,7 +181,7 @@ struct PSPPixelFormat {
return output;
}
- inline uint32 swapRedBlue32(uint32 color) {
+ inline uint32 swapRedBlue32(uint32 color) const {
uint32 output;
switch (format) {
@@ -211,7 +211,7 @@ struct PSPPixelFormat {
}
// Return whatever color we point at
- inline uint32 getColorValueAt(byte *pointer) {
+ inline uint32 getColorValueAt(byte *pointer) const {
uint32 result;
switch (bitsPerPixel) {
diff --git a/backends/platform/sdl/riscos/riscos.cpp b/backends/platform/sdl/riscos/riscos.cpp
index 08609396f1..0cdbceb902 100644
--- a/backends/platform/sdl/riscos/riscos.cpp
+++ b/backends/platform/sdl/riscos/riscos.cpp
@@ -20,16 +20,14 @@
*
*/
-#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
-
#include "common/scummsys.h"
#ifdef RISCOS
#include "backends/platform/sdl/riscos/riscos.h"
#include "backends/saves/default/default-saves.h"
-#include "backends/fs/posix/posix-fs-factory.h"
-#include "backends/fs/posix/posix-fs.h"
+#include "backends/fs/riscos/riscos-fs-factory.h"
+#include "backends/fs/riscos/riscos-fs.h"
#include <kernel.h>
#include <swis.h>
@@ -40,7 +38,7 @@
void OSystem_RISCOS::init() {
// Initialze File System Factory
- _fsFactory = new POSIXFilesystemFactory();
+ _fsFactory = new RISCOSFilesystemFactory();
// Invoke parent implementation of this method
OSystem_SDL::init();
@@ -50,7 +48,7 @@ void OSystem_RISCOS::initBackend() {
// Create the savefile manager
if (_savefileManager == 0) {
Common::String savePath = "/<Choices$Write>/ScummVM/Saves";
- if (Posix::assureDirectoryExists(savePath))
+ if (Riscos::assureDirectoryExists(savePath))
_savefileManager = new DefaultSaveFileManager(savePath);
}
@@ -89,7 +87,7 @@ Common::WriteStream *OSystem_RISCOS::createLogFile() {
Common::String logFile = "/<Choices$Write>/ScummVM/Logs";
- if (!Posix::assureDirectoryExists(logFile)) {
+ if (!Riscos::assureDirectoryExists(logFile)) {
return 0;
}
diff --git a/backends/platform/sdl/sdl-window.cpp b/backends/platform/sdl/sdl-window.cpp
index 07ddc998ba..b38a97c5ef 100644
--- a/backends/platform/sdl/sdl-window.cpp
+++ b/backends/platform/sdl/sdl-window.cpp
@@ -129,14 +129,16 @@ void SdlWindow::setWindowCaption(const Common::String &caption) {
void SdlWindow::toggleMouseGrab() {
#if SDL_VERSION_ATLEAST(2, 0, 0)
if (_window) {
- _inputGrabState = !(SDL_GetWindowGrab(_window) == SDL_TRUE);
+ _inputGrabState = SDL_GetWindowGrab(_window) == SDL_FALSE;
SDL_SetWindowGrab(_window, _inputGrabState ? SDL_TRUE : SDL_FALSE);
}
#else
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) {
SDL_WM_GrabInput(SDL_GRAB_ON);
+ _inputGrabState = true;
} else {
SDL_WM_GrabInput(SDL_GRAB_OFF);
+ _inputGrabState = false;
}
#endif
}
@@ -153,14 +155,20 @@ bool SdlWindow::hasMouseFocus() const {
#endif
}
-void SdlWindow::warpMouseInWindow(uint x, uint y) {
+bool SdlWindow::warpMouseInWindow(int x, int y) {
+ if (hasMouseFocus()) {
#if SDL_VERSION_ATLEAST(2, 0, 0)
- if (_window && hasMouseFocus()) {
- SDL_WarpMouseInWindow(_window, x, y);
- }
+ if (_window) {
+ SDL_WarpMouseInWindow(_window, x, y);
+ return true;
+ }
#else
- SDL_WarpMouse(x, y);
+ SDL_WarpMouse(x, y);
+ return true;
#endif
+ }
+
+ return false;
}
void SdlWindow::iconifyWindow() {
@@ -223,6 +231,33 @@ bool SdlWindow::createOrUpdateWindow(int width, int height, uint32 flags) {
const uint32 oldNonUpdateableFlags = _lastFlags & ~updateableFlagsMask;
const uint32 newNonUpdateableFlags = flags & ~updateableFlagsMask;
+ const uint32 fullscreenFlags = flags & fullscreenMask;
+
+ // This is terrible, but there is no way in SDL to get information on the
+ // maximum bounds of a window with decoration, and SDL is too dumb to make
+ // sure the window's surface doesn't grow beyond the display bounds, which
+ // can easily happen with 3x scalers. There is a function in SDL to get the
+ // window decoration size, but it only exists starting in SDL 2.0.5, which
+ // is a buggy release on some platforms so we can't safely use 2.0.5+
+ // features since some users replace the SDL dynamic library with 2.0.4, and
+ // the documentation says it only works on X11 anyway, which means it is
+ // basically worthless. So we'll just try to keep things closeish to the
+ // maximum for now.
+ SDL_DisplayMode displayMode;
+ SDL_GetDesktopDisplayMode(0, &displayMode);
+ if (!fullscreenFlags) {
+ displayMode.w -= 20;
+ displayMode.h -= 30;
+ }
+
+ if (width > displayMode.w) {
+ width = displayMode.w;
+ }
+
+ if (height > displayMode.h) {
+ height = displayMode.h;
+ }
+
if (!_window || oldNonUpdateableFlags != newNonUpdateableFlags) {
destroyWindow();
_window = SDL_CreateWindow(_windowCaption.c_str(), _lastX,
@@ -231,8 +266,6 @@ bool SdlWindow::createOrUpdateWindow(int width, int height, uint32 flags) {
setupIcon();
}
} else {
- const uint32 fullscreenFlags = flags & fullscreenMask;
-
if (fullscreenFlags) {
SDL_DisplayMode fullscreenMode;
fullscreenMode.w = width;
@@ -246,7 +279,8 @@ bool SdlWindow::createOrUpdateWindow(int width, int height, uint32 flags) {
}
SDL_SetWindowFullscreen(_window, fullscreenFlags);
- SDL_SetWindowGrab(_window, (flags & SDL_WINDOW_INPUT_GRABBED) ? SDL_TRUE : SDL_FALSE);
+ const bool shouldGrab = (flags & SDL_WINDOW_INPUT_GRABBED) | fullscreenFlags;
+ SDL_SetWindowGrab(_window, shouldGrab ? SDL_TRUE : SDL_FALSE);
}
if (!_window) {
diff --git a/backends/platform/sdl/sdl-window.h b/backends/platform/sdl/sdl-window.h
index d75e811f56..05893c47d3 100644
--- a/backends/platform/sdl/sdl-window.h
+++ b/backends/platform/sdl/sdl-window.h
@@ -56,9 +56,12 @@ public:
bool hasMouseFocus() const;
/**
- * Warp the mouse to the specified position in window coordinates.
+ * Warp the mouse to the specified position in window coordinates. The mouse
+ * will only be warped if the window is focused in the window manager.
+ *
+ * @returns true if the system cursor was warped.
*/
- void warpMouseInWindow(uint x, uint y);
+ bool warpMouseInWindow(int x, int y);
/**
* Iconifies the window.
@@ -73,6 +76,18 @@ public:
*/
bool getSDLWMInformation(SDL_SysWMinfo *info) const;
+ bool mouseIsGrabbed() const {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ if (_window) {
+ return SDL_GetWindowGrab(_window) == SDL_TRUE;
+ }
+#endif
+ return _inputGrabState;
+ }
+
+private:
+ bool _inputGrabState;
+
#if SDL_VERSION_ATLEAST(2, 0, 0)
public:
/**
@@ -108,7 +123,6 @@ private:
*/
int _lastX, _lastY;
- bool _inputGrabState;
Common::String _windowCaption;
#endif
};
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index bbd5c89f80..f44d87666a 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -297,20 +297,28 @@ void OSystem_SDL::initBackend() {
dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->activateManager();
}
-#if defined(USE_TASKBAR)
void OSystem_SDL::engineInit() {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->unlockWindowSize();
+#endif
+#ifdef USE_TASKBAR
// Add the started engine to the list of recent tasks
_taskbarManager->addRecent(ConfMan.getActiveDomainName(), ConfMan.get("description"));
// Set the overlay icon the current running engine
_taskbarManager->setOverlayIcon(ConfMan.getActiveDomainName(), ConfMan.get("description"));
+#endif
}
void OSystem_SDL::engineDone() {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->unlockWindowSize();
+#endif
+#ifdef USE_TASKBAR
// Remove overlay icon
_taskbarManager->setOverlayIcon("", "");
-}
#endif
+}
void OSystem_SDL::initSDL() {
// Check if SDL has not been initialized
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index bc4292be0b..61513fa65f 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -59,10 +59,8 @@ public:
// Override functions from ModularBackend and OSystem
virtual void initBackend();
-#if defined(USE_TASKBAR)
virtual void engineInit();
virtual void engineDone();
-#endif
virtual void quit();
virtual void fatalError();
diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h
index f1591614bf..5482eb7d49 100644
--- a/backends/platform/wii/osystem.h
+++ b/backends/platform/wii/osystem.h
@@ -165,7 +165,7 @@ public:
virtual PaletteManager *getPaletteManager() { return this; }
protected:
virtual void setPalette(const byte *colors, uint start, uint num);
- virtual void grabPalette(byte *colors, uint start, uint num);
+ virtual void grabPalette(byte *colors, uint start, uint num) const;
public:
virtual void setCursorPalette(const byte *colors, uint start, uint num);
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp
index c7989e95ad..932ca3814c 100644
--- a/backends/platform/wii/osystem_gfx.cpp
+++ b/backends/platform/wii/osystem_gfx.cpp
@@ -352,7 +352,7 @@ void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) {
}
}
-void OSystem_Wii::grabPalette(byte *colors, uint start, uint num) {
+void OSystem_Wii::grabPalette(byte *colors, uint start, uint num) const {
#ifdef USE_RGB_COLOR
assert(_pfGame.bytesPerPixel == 1);
#endif