IPHONE: Fall back to CLUT8 in case a non-supported screen mode is set up.

This makes the iPhone backend conform with the 16bpp API and thus no longer
causes assertions to fail in case the client code tries to set up an
unsupported game screen format.
This commit is contained in:
Johannes Schickel 2012-02-29 19:02:17 +01:00
parent f2c2e4fef8
commit aad85d957c
3 changed files with 13 additions and 4 deletions

View file

@ -60,7 +60,7 @@ OSystem_IPHONE::OSystem_IPHONE() :
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0),
_mouseCursorPaletteEnabled(false) {
_mouseCursorPaletteEnabled(false), _gfxTransactionError(kTransactionSuccess) {
_queuedInputEvent.type = Common::EVENT_INVALID;
_touchpadModeEnabled = !iPhone_isHighResDevice();
_fsFactory = new POSIXFilesystemFactory();

View file

@ -65,6 +65,9 @@ protected:
Graphics::Surface _framebuffer;
// For signaling that screen format set up might have failed.
TransactionError _gfxTransactionError;
// For use with the game texture
uint16 _gamePalette[256];
// For use with the mouse texture

View file

@ -84,6 +84,13 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
// to the texture buffer to avoid an additional copy step.
[g_iPhoneViewInstance performSelectorOnMainThread:@selector(createScreenTexture) withObject:nil waitUntilDone: YES];
// 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.
if (format && format->bytesPerPixel != 1 && *format != _videoContext->screenTexture.format) {
format = 0;
_gfxTransactionError = kTransactionFormatNotSupported;
}
if (!format || format->bytesPerPixel == 1) {
_framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
} else {
@ -92,7 +99,6 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
format->rLoss, format->gLoss, format->bLoss, format->aLoss,
format->rShift, format->gShift, format->bShift, format->aShift);
#endif
assert(_videoContext->screenTexture.format == *format);
// We directly draw on the screen texture in hi-color mode. Thus
// we copy over its settings here and just replace the width and
// height to avoid any problems.
@ -107,6 +113,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
}
void OSystem_IPHONE::beginGFXTransaction() {
_gfxTransactionError = kTransactionSuccess;
}
OSystem::TransactionError OSystem_IPHONE::endGFXTransaction() {
@ -114,8 +121,7 @@ OSystem::TransactionError OSystem_IPHONE::endGFXTransaction() {
updateOutputSurface();
[g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES];
// TODO: Can we return better error codes?
return kTransactionSuccess;
return _gfxTransactionError;
}
void OSystem_IPHONE::updateOutputSurface() {