[Scummvm-cvs-logs] scummvm master -> 5ae958bcf3a1dc4d7be093eac99eb0d5145c8c7e
lordhoto
lordhoto at gmail.com
Thu Feb 23 03:18:58 CET 2012
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c5ccb32b48 IPHONE: Move graphics related OSystem code to a ObjC++ file.
e83e31c2cc IPHONE: Move mouse coordinate conversion code to iPhoneView.
e1edb20fed IPHONE: Move VideoContext definition to iphone_common.h.
ab15435ad0 IPHONE: Move overlay visibility status to VideoContext.
99ffbfedbc IPHONE: Use VideoContext in OSystem_IPHONE.
e00fc73eb8 IPHONE: Silence a few signed/unsigned integer comparison warnings.
5ae958bcf3 IPHONE: Let iPhoneView and OSystem_IPHONE share the same VideoContext.
Commit: c5ccb32b48ac0cf662539e8d4a1f0392f96c4b1a
https://github.com/scummvm/scummvm/commit/c5ccb32b48ac0cf662539e8d4a1f0392f96c4b1a
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T16:52:50-08:00
Commit Message:
IPHONE: Move graphics related OSystem code to a ObjC++ file.
Changed paths:
A backends/platform/iphone/osys_video.mm
R backends/platform/iphone/osys_video.cpp
diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp
deleted file mode 100644
index e26c360..0000000
--- a/backends/platform/iphone/osys_video.cpp
+++ /dev/null
@@ -1,432 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-// Disable symbol overrides so that we can use system headers.
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
-
-#include "osys_main.h"
-
-const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const {
- return s_supportedGraphicsModes;
-}
-
-
-int OSystem_IPHONE::getDefaultGraphicsMode() const {
- return kGraphicsModeLinear;
-}
-
-bool OSystem_IPHONE::setGraphicsMode(int mode) {
- switch (mode) {
- case kGraphicsModeNone:
- case kGraphicsModeLinear:
- _currentGraphicsMode = mode;
- iPhone_setGraphicsMode((GraphicsModes)mode);
- return true;
-
- default:
- return false;
- }
-}
-
-int OSystem_IPHONE::getGraphicsMode() const {
- return _currentGraphicsMode;
-}
-
-void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
- //printf("initSize(%i, %i)\n", width, height);
-
- _screenWidth = width;
- _screenHeight = height;
-
- free(_gameScreenRaw);
-
- _gameScreenRaw = (byte *)malloc(width * height);
- bzero(_gameScreenRaw, width * height);
-
- //free(_overlayBuffer);
-
- int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor);
- //_overlayBuffer = (OverlayColor *)malloc(fullSize);
- clearOverlay();
-
- free(_gameScreenConverted);
-
- _gameScreenConverted = (uint16 *)malloc(fullSize);
- bzero(_gameScreenConverted, fullSize);
-
- iPhone_initSurface(width, height);
-
- if (_overlayBuffer == NULL) {
- _overlayHeight = iPhone_getScreenHeight();
- _overlayWidth = iPhone_getScreenWidth();
-
- printf("Overlay: (%u x %u)\n", _overlayWidth, _overlayHeight);
- _overlayBuffer = new OverlayColor[_overlayHeight * _overlayWidth];
- }
-
- _fullScreenIsDirty = false;
- dirtyFullScreen();
- _mouseVisible = false;
- _mouseCursorPaletteEnabled = false;
- _screenChangeCount++;
- updateScreen();
-}
-
-int16 OSystem_IPHONE::getHeight() {
- return _screenHeight;
-}
-
-int16 OSystem_IPHONE::getWidth() {
- return _screenWidth;
-}
-
-void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) {
- assert(start + num <= 256);
- const byte *b = colors;
-
- for (uint i = start; i < start + num; ++i) {
- _gamePalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]);
- _gamePaletteRGBA5551[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(b[0], b[1], b[2]);
- b += 3;
- }
-
- dirtyFullScreen();
-}
-
-void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) {
- assert(start + num <= 256);
- byte *b = colors;
-
- for (uint i = start; i < start + num; ++i) {
- Graphics::colorToRGB<Graphics::ColorMasks<565> >(_gamePalette[i], b[0], b[1], b[2]);
- b += 3;
- }
-}
-
-void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
- //printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h);
- //Clip the coordinates
- if (x < 0) {
- w += x;
- buf -= x;
- x = 0;
- }
-
- if (y < 0) {
- h += y;
- buf -= y * pitch;
- y = 0;
- }
-
- if (w > _screenWidth - x) {
- w = _screenWidth - x;
- }
-
- if (h > _screenHeight - y) {
- h = _screenHeight - y;
- }
-
- if (w <= 0 || h <= 0)
- return;
-
- if (!_fullScreenIsDirty) {
- _dirtyRects.push_back(Common::Rect(x, y, x + w, y + h));
- }
-
-
- byte *dst = _gameScreenRaw + y * _screenWidth + x;
- if (_screenWidth == pitch && pitch == w)
- memcpy(dst, buf, h * w);
- else {
- do {
- memcpy(dst, buf, w);
- buf += pitch;
- dst += _screenWidth;
- } while (--h);
- }
-}
-
-void OSystem_IPHONE::updateScreen() {
- //printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size());
-
- if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty)
- return;
-
- internUpdateScreen();
- _mouseDirty = false;
- _fullScreenIsDirty = false;
- _fullScreenOverlayIsDirty = false;
-
- iPhone_updateScreen(_mouseX, _mouseY);
-}
-
-void OSystem_IPHONE::internUpdateScreen() {
- if (_mouseNeedTextureUpdate) {
- updateMouseTexture();
- _mouseNeedTextureUpdate = false;
- }
-
- while (_dirtyRects.size()) {
- Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1);
-
- //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
- drawDirtyRect(dirtyRect);
- updateHardwareSurfaceForRect(dirtyRect);
- }
-
- if (_overlayVisible) {
- while (_dirtyOverlayRects.size()) {
- Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1);
-
- //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
- drawDirtyOverlayRect(dirtyRect);
- }
- }
-}
-
-void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
- int h = dirtyRect.bottom - dirtyRect.top;
- int w = dirtyRect.right - dirtyRect.left;
-
- byte *src = &_gameScreenRaw[dirtyRect.top * _screenWidth + dirtyRect.left];
- uint16 *dst = &_gameScreenConverted[dirtyRect.top * _screenWidth + dirtyRect.left];
- for (int y = h; y > 0; y--) {
- for (int x = w; x > 0; x--)
- *dst++ = _gamePalette[*src++];
-
- dst += _screenWidth - w;
- src += _screenWidth - w;
- }
-}
-
-void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) {
- iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
-}
-
-void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) {
- iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom);
-}
-
-Graphics::Surface *OSystem_IPHONE::lockScreen() {
- //printf("lockScreen()\n");
-
- _framebuffer.pixels = _gameScreenRaw;
- _framebuffer.w = _screenWidth;
- _framebuffer.h = _screenHeight;
- _framebuffer.pitch = _screenWidth;
- _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
-
- return &_framebuffer;
-}
-
-void OSystem_IPHONE::unlockScreen() {
- //printf("unlockScreen()\n");
- dirtyFullScreen();
-}
-
-void OSystem_IPHONE::setShakePos(int shakeOffset) {
- //printf("setShakePos(%i)\n", shakeOffset);
- iPhone_setShakeOffset(shakeOffset);
- // HACK: We use this to force a redraw.
- _mouseDirty = true;
-}
-
-void OSystem_IPHONE::showOverlay() {
- //printf("showOverlay()\n");
- _overlayVisible = true;
- dirtyFullOverlayScreen();
- updateScreen();
- iPhone_enableOverlay(true);
-}
-
-void OSystem_IPHONE::hideOverlay() {
- //printf("hideOverlay()\n");
- _overlayVisible = false;
- _dirtyOverlayRects.clear();
- dirtyFullScreen();
- iPhone_enableOverlay(false);
-}
-
-void OSystem_IPHONE::clearOverlay() {
- //printf("clearOverlay()\n");
- bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor));
- dirtyFullOverlayScreen();
-}
-
-void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
- //printf("grabOverlay()\n");
- int h = _overlayHeight;
- OverlayColor *src = _overlayBuffer;
-
- do {
- memcpy(buf, src, _overlayWidth * sizeof(OverlayColor));
- src += _overlayWidth;
- buf += pitch;
- } while (--h);
-}
-
-void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
- //printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h);
-
- //Clip the coordinates
- if (x < 0) {
- w += x;
- buf -= x;
- x = 0;
- }
-
- if (y < 0) {
- h += y;
- buf -= y * pitch;
- y = 0;
- }
-
- if (w > _overlayWidth - x)
- w = _overlayWidth - x;
-
- if (h > _overlayHeight - y)
- h = _overlayHeight - y;
-
- if (w <= 0 || h <= 0)
- return;
-
- if (!_fullScreenOverlayIsDirty) {
- _dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h));
- }
-
- OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x);
- if (_overlayWidth == pitch && pitch == w)
- memcpy(dst, buf, h * w * sizeof(OverlayColor));
- else {
- do {
- memcpy(dst, buf, w * sizeof(OverlayColor));
- buf += pitch;
- dst += _overlayWidth;
- } while (--h);
- }
-}
-
-int16 OSystem_IPHONE::getOverlayHeight() {
- return _overlayHeight;
-}
-
-int16 OSystem_IPHONE::getOverlayWidth() {
- return _overlayWidth;
-}
-
-bool OSystem_IPHONE::showMouse(bool visible) {
- bool last = _mouseVisible;
- _mouseVisible = visible;
- iPhone_showCursor(visible);
- _mouseDirty = true;
-
- return last;
-}
-
-void OSystem_IPHONE::warpMouse(int x, int y) {
- //printf("warpMouse()\n");
-
- _mouseX = x;
- _mouseY = y;
- _mouseDirty = true;
-}
-
-void OSystem_IPHONE::dirtyFullScreen() {
- if (!_fullScreenIsDirty) {
- _dirtyRects.clear();
- _dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
- _fullScreenIsDirty = true;
- }
-}
-
-void OSystem_IPHONE::dirtyFullOverlayScreen() {
- if (!_fullScreenOverlayIsDirty) {
- _dirtyOverlayRects.clear();
- _dirtyOverlayRects.push_back(Common::Rect(0, 0, _overlayWidth, _overlayHeight));
- _fullScreenOverlayIsDirty = true;
- }
-}
-
-void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
- //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale);
-
- if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
- free(_mouseBuf);
- _mouseBuf = NULL;
- }
-
- if (_mouseBuf == NULL)
- _mouseBuf = (byte *)malloc(w * h);
-
- _mouseWidth = w;
- _mouseHeight = h;
-
- _mouseHotspotX = hotspotX;
- _mouseHotspotY = hotspotY;
-
- _mouseKeyColor = (byte)keycolor;
-
- memcpy(_mouseBuf, buf, w * h);
-
- _mouseDirty = true;
- _mouseNeedTextureUpdate = true;
-}
-
-void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) {
- assert(start + num <= 256);
-
- for (uint i = start; i < start + num; ++i, colors += 3)
- _mouseCursorPalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(colors[0], colors[1], colors[2]);
-
- // FIXME: This is just stupid, our client code seems to assume that this
- // automatically enables the cursor palette.
- _mouseCursorPaletteEnabled = true;
-
- if (_mouseCursorPaletteEnabled)
- _mouseDirty = _mouseNeedTextureUpdate = true;
-}
-
-void OSystem_IPHONE::updateMouseTexture() {
- int texWidth = getSizeNextPOT(_mouseWidth);
- int texHeight = getSizeNextPOT(_mouseHeight);
- int bufferSize = texWidth * texHeight * sizeof(int16);
- uint16 *mouseBuf = (uint16 *)malloc(bufferSize);
- memset(mouseBuf, 0, bufferSize);
-
- const uint16 *palette;
- if (_mouseCursorPaletteEnabled)
- palette = _mouseCursorPalette;
- else
- palette = _gamePaletteRGBA5551;
-
- for (uint x = 0; x < _mouseWidth; ++x) {
- for (uint y = 0; y < _mouseHeight; ++y) {
- const byte color = _mouseBuf[y * _mouseWidth + x];
- if (color != _mouseKeyColor)
- mouseBuf[y * texWidth + x] = palette[color] | 0x1;
- else
- mouseBuf[y * texWidth + x] = 0x0;
- }
- }
-
- iPhone_setMouseCursor(mouseBuf, _mouseWidth, _mouseHeight, _mouseHotspotX, _mouseHotspotY);
-}
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
new file mode 100644
index 0000000..e26c360
--- /dev/null
+++ b/backends/platform/iphone/osys_video.mm
@@ -0,0 +1,432 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "osys_main.h"
+
+const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const {
+ return s_supportedGraphicsModes;
+}
+
+
+int OSystem_IPHONE::getDefaultGraphicsMode() const {
+ return kGraphicsModeLinear;
+}
+
+bool OSystem_IPHONE::setGraphicsMode(int mode) {
+ switch (mode) {
+ case kGraphicsModeNone:
+ case kGraphicsModeLinear:
+ _currentGraphicsMode = mode;
+ iPhone_setGraphicsMode((GraphicsModes)mode);
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+int OSystem_IPHONE::getGraphicsMode() const {
+ return _currentGraphicsMode;
+}
+
+void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
+ //printf("initSize(%i, %i)\n", width, height);
+
+ _screenWidth = width;
+ _screenHeight = height;
+
+ free(_gameScreenRaw);
+
+ _gameScreenRaw = (byte *)malloc(width * height);
+ bzero(_gameScreenRaw, width * height);
+
+ //free(_overlayBuffer);
+
+ int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor);
+ //_overlayBuffer = (OverlayColor *)malloc(fullSize);
+ clearOverlay();
+
+ free(_gameScreenConverted);
+
+ _gameScreenConverted = (uint16 *)malloc(fullSize);
+ bzero(_gameScreenConverted, fullSize);
+
+ iPhone_initSurface(width, height);
+
+ if (_overlayBuffer == NULL) {
+ _overlayHeight = iPhone_getScreenHeight();
+ _overlayWidth = iPhone_getScreenWidth();
+
+ printf("Overlay: (%u x %u)\n", _overlayWidth, _overlayHeight);
+ _overlayBuffer = new OverlayColor[_overlayHeight * _overlayWidth];
+ }
+
+ _fullScreenIsDirty = false;
+ dirtyFullScreen();
+ _mouseVisible = false;
+ _mouseCursorPaletteEnabled = false;
+ _screenChangeCount++;
+ updateScreen();
+}
+
+int16 OSystem_IPHONE::getHeight() {
+ return _screenHeight;
+}
+
+int16 OSystem_IPHONE::getWidth() {
+ return _screenWidth;
+}
+
+void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) {
+ assert(start + num <= 256);
+ const byte *b = colors;
+
+ for (uint i = start; i < start + num; ++i) {
+ _gamePalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]);
+ _gamePaletteRGBA5551[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(b[0], b[1], b[2]);
+ b += 3;
+ }
+
+ dirtyFullScreen();
+}
+
+void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) {
+ assert(start + num <= 256);
+ byte *b = colors;
+
+ for (uint i = start; i < start + num; ++i) {
+ Graphics::colorToRGB<Graphics::ColorMasks<565> >(_gamePalette[i], b[0], b[1], b[2]);
+ b += 3;
+ }
+}
+
+void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
+ //printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h);
+ //Clip the coordinates
+ if (x < 0) {
+ w += x;
+ buf -= x;
+ x = 0;
+ }
+
+ if (y < 0) {
+ h += y;
+ buf -= y * pitch;
+ y = 0;
+ }
+
+ if (w > _screenWidth - x) {
+ w = _screenWidth - x;
+ }
+
+ if (h > _screenHeight - y) {
+ h = _screenHeight - y;
+ }
+
+ if (w <= 0 || h <= 0)
+ return;
+
+ if (!_fullScreenIsDirty) {
+ _dirtyRects.push_back(Common::Rect(x, y, x + w, y + h));
+ }
+
+
+ byte *dst = _gameScreenRaw + y * _screenWidth + x;
+ if (_screenWidth == pitch && pitch == w)
+ memcpy(dst, buf, h * w);
+ else {
+ do {
+ memcpy(dst, buf, w);
+ buf += pitch;
+ dst += _screenWidth;
+ } while (--h);
+ }
+}
+
+void OSystem_IPHONE::updateScreen() {
+ //printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size());
+
+ if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty)
+ return;
+
+ internUpdateScreen();
+ _mouseDirty = false;
+ _fullScreenIsDirty = false;
+ _fullScreenOverlayIsDirty = false;
+
+ iPhone_updateScreen(_mouseX, _mouseY);
+}
+
+void OSystem_IPHONE::internUpdateScreen() {
+ if (_mouseNeedTextureUpdate) {
+ updateMouseTexture();
+ _mouseNeedTextureUpdate = false;
+ }
+
+ while (_dirtyRects.size()) {
+ Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1);
+
+ //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
+ drawDirtyRect(dirtyRect);
+ updateHardwareSurfaceForRect(dirtyRect);
+ }
+
+ if (_overlayVisible) {
+ while (_dirtyOverlayRects.size()) {
+ Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1);
+
+ //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
+ drawDirtyOverlayRect(dirtyRect);
+ }
+ }
+}
+
+void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
+ int h = dirtyRect.bottom - dirtyRect.top;
+ int w = dirtyRect.right - dirtyRect.left;
+
+ byte *src = &_gameScreenRaw[dirtyRect.top * _screenWidth + dirtyRect.left];
+ uint16 *dst = &_gameScreenConverted[dirtyRect.top * _screenWidth + dirtyRect.left];
+ for (int y = h; y > 0; y--) {
+ for (int x = w; x > 0; x--)
+ *dst++ = _gamePalette[*src++];
+
+ dst += _screenWidth - w;
+ src += _screenWidth - w;
+ }
+}
+
+void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) {
+ iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
+}
+
+void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) {
+ iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom);
+}
+
+Graphics::Surface *OSystem_IPHONE::lockScreen() {
+ //printf("lockScreen()\n");
+
+ _framebuffer.pixels = _gameScreenRaw;
+ _framebuffer.w = _screenWidth;
+ _framebuffer.h = _screenHeight;
+ _framebuffer.pitch = _screenWidth;
+ _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
+
+ return &_framebuffer;
+}
+
+void OSystem_IPHONE::unlockScreen() {
+ //printf("unlockScreen()\n");
+ dirtyFullScreen();
+}
+
+void OSystem_IPHONE::setShakePos(int shakeOffset) {
+ //printf("setShakePos(%i)\n", shakeOffset);
+ iPhone_setShakeOffset(shakeOffset);
+ // HACK: We use this to force a redraw.
+ _mouseDirty = true;
+}
+
+void OSystem_IPHONE::showOverlay() {
+ //printf("showOverlay()\n");
+ _overlayVisible = true;
+ dirtyFullOverlayScreen();
+ updateScreen();
+ iPhone_enableOverlay(true);
+}
+
+void OSystem_IPHONE::hideOverlay() {
+ //printf("hideOverlay()\n");
+ _overlayVisible = false;
+ _dirtyOverlayRects.clear();
+ dirtyFullScreen();
+ iPhone_enableOverlay(false);
+}
+
+void OSystem_IPHONE::clearOverlay() {
+ //printf("clearOverlay()\n");
+ bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor));
+ dirtyFullOverlayScreen();
+}
+
+void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
+ //printf("grabOverlay()\n");
+ int h = _overlayHeight;
+ OverlayColor *src = _overlayBuffer;
+
+ do {
+ memcpy(buf, src, _overlayWidth * sizeof(OverlayColor));
+ src += _overlayWidth;
+ buf += pitch;
+ } while (--h);
+}
+
+void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
+ //printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h);
+
+ //Clip the coordinates
+ if (x < 0) {
+ w += x;
+ buf -= x;
+ x = 0;
+ }
+
+ if (y < 0) {
+ h += y;
+ buf -= y * pitch;
+ y = 0;
+ }
+
+ if (w > _overlayWidth - x)
+ w = _overlayWidth - x;
+
+ if (h > _overlayHeight - y)
+ h = _overlayHeight - y;
+
+ if (w <= 0 || h <= 0)
+ return;
+
+ if (!_fullScreenOverlayIsDirty) {
+ _dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h));
+ }
+
+ OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x);
+ if (_overlayWidth == pitch && pitch == w)
+ memcpy(dst, buf, h * w * sizeof(OverlayColor));
+ else {
+ do {
+ memcpy(dst, buf, w * sizeof(OverlayColor));
+ buf += pitch;
+ dst += _overlayWidth;
+ } while (--h);
+ }
+}
+
+int16 OSystem_IPHONE::getOverlayHeight() {
+ return _overlayHeight;
+}
+
+int16 OSystem_IPHONE::getOverlayWidth() {
+ return _overlayWidth;
+}
+
+bool OSystem_IPHONE::showMouse(bool visible) {
+ bool last = _mouseVisible;
+ _mouseVisible = visible;
+ iPhone_showCursor(visible);
+ _mouseDirty = true;
+
+ return last;
+}
+
+void OSystem_IPHONE::warpMouse(int x, int y) {
+ //printf("warpMouse()\n");
+
+ _mouseX = x;
+ _mouseY = y;
+ _mouseDirty = true;
+}
+
+void OSystem_IPHONE::dirtyFullScreen() {
+ if (!_fullScreenIsDirty) {
+ _dirtyRects.clear();
+ _dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+ _fullScreenIsDirty = true;
+ }
+}
+
+void OSystem_IPHONE::dirtyFullOverlayScreen() {
+ if (!_fullScreenOverlayIsDirty) {
+ _dirtyOverlayRects.clear();
+ _dirtyOverlayRects.push_back(Common::Rect(0, 0, _overlayWidth, _overlayHeight));
+ _fullScreenOverlayIsDirty = true;
+ }
+}
+
+void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
+ //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale);
+
+ if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
+ free(_mouseBuf);
+ _mouseBuf = NULL;
+ }
+
+ if (_mouseBuf == NULL)
+ _mouseBuf = (byte *)malloc(w * h);
+
+ _mouseWidth = w;
+ _mouseHeight = h;
+
+ _mouseHotspotX = hotspotX;
+ _mouseHotspotY = hotspotY;
+
+ _mouseKeyColor = (byte)keycolor;
+
+ memcpy(_mouseBuf, buf, w * h);
+
+ _mouseDirty = true;
+ _mouseNeedTextureUpdate = true;
+}
+
+void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) {
+ assert(start + num <= 256);
+
+ for (uint i = start; i < start + num; ++i, colors += 3)
+ _mouseCursorPalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(colors[0], colors[1], colors[2]);
+
+ // FIXME: This is just stupid, our client code seems to assume that this
+ // automatically enables the cursor palette.
+ _mouseCursorPaletteEnabled = true;
+
+ if (_mouseCursorPaletteEnabled)
+ _mouseDirty = _mouseNeedTextureUpdate = true;
+}
+
+void OSystem_IPHONE::updateMouseTexture() {
+ int texWidth = getSizeNextPOT(_mouseWidth);
+ int texHeight = getSizeNextPOT(_mouseHeight);
+ int bufferSize = texWidth * texHeight * sizeof(int16);
+ uint16 *mouseBuf = (uint16 *)malloc(bufferSize);
+ memset(mouseBuf, 0, bufferSize);
+
+ const uint16 *palette;
+ if (_mouseCursorPaletteEnabled)
+ palette = _mouseCursorPalette;
+ else
+ palette = _gamePaletteRGBA5551;
+
+ for (uint x = 0; x < _mouseWidth; ++x) {
+ for (uint y = 0; y < _mouseHeight; ++y) {
+ const byte color = _mouseBuf[y * _mouseWidth + x];
+ if (color != _mouseKeyColor)
+ mouseBuf[y * texWidth + x] = palette[color] | 0x1;
+ else
+ mouseBuf[y * texWidth + x] = 0x0;
+ }
+ }
+
+ iPhone_setMouseCursor(mouseBuf, _mouseWidth, _mouseHeight, _mouseHotspotX, _mouseHotspotY);
+}
Commit: e83e31c2cc90a5311c839903b0a120eacf3dde20
https://github.com/scummvm/scummvm/commit/e83e31c2cc90a5311c839903b0a120eacf3dde20
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T17:02:14-08:00
Commit Message:
IPHONE: Move mouse coordinate conversion code to iPhoneView.
Changed paths:
backends/platform/iphone/iphone_video.mm
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index b6636e6..e461691 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -184,64 +184,6 @@ const char *iPhone_getDocumentsDir() {
return [documentsDirectory UTF8String];
}
-/**
- * Converts portrait mode coordinates into rotated mode coordinates.
- */
-static bool convertToRotatedCoords(UIDeviceOrientation orientation, CGPoint point, CGPoint *result) {
- switch (orientation) {
- case UIDeviceOrientationLandscapeLeft:
- result->x = point.y;
- result->y = _renderBufferWidth - point.x;
- return true;
-
- case UIDeviceOrientationLandscapeRight:
- result->x = _renderBufferHeight - point.y;
- result->y = point.x;
- return true;
-
- case UIDeviceOrientationPortrait:
- result->x = point.x;
- result->y = point.y;
- return true;
-
- default:
- return false;
- }
-}
-
-static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *x, int *y) {
- if (!convertToRotatedCoords(orientation, point, &point))
- return false;
-
- CGRect *area;
- int width, height, offsetY;
- if (_overlayIsEnabled) {
- area = &_overlayRect;
- width = _videoContext.overlayWidth;
- height = _videoContext.overlayHeight;
- offsetY = _scaledShakeOffsetY;
- } else {
- area = &_gameScreenRect;
- width = _videoContext.screenWidth;
- height = _videoContext.screenHeight;
- offsetY = _videoContext.shakeOffsetY;
- }
-
- point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area);
- point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area);
-
- *x = (int)(point.x * width);
- // offsetY describes the translation of the screen in the upward direction,
- // thus we need to add it here.
- *y = (int)(point.y * height + offsetY);
-
- // Clip coordinates
- if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area))
- return false;
-
- return true;
-}
-
@implementation iPhoneView
+ (Class)layerClass {
@@ -722,6 +664,64 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *
[_events addObject: event];
}
+/**
+ * Converts portrait mode coordinates into rotated mode coordinates.
+ */
+- (bool)convertToRotatedCoords:(CGPoint)point result:(CGPoint *)result {
+ switch (_orientation) {
+ case UIDeviceOrientationLandscapeLeft:
+ result->x = point.y;
+ result->y = _renderBufferWidth - point.x;
+ return true;
+
+ case UIDeviceOrientationLandscapeRight:
+ result->x = _renderBufferHeight - point.y;
+ result->y = point.x;
+ return true;
+
+ case UIDeviceOrientationPortrait:
+ result->x = point.x;
+ result->y = point.y;
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+- (bool)getMouseCoords:(CGPoint)point eventX:(int *)x eventY:(int *)y {
+ if (![self convertToRotatedCoords:point result:&point])
+ return false;
+
+ CGRect *area;
+ int width, height, offsetY;
+ if (_overlayIsEnabled) {
+ area = &_overlayRect;
+ width = _videoContext.overlayWidth;
+ height = _videoContext.overlayHeight;
+ offsetY = _scaledShakeOffsetY;
+ } else {
+ area = &_gameScreenRect;
+ width = _videoContext.screenWidth;
+ height = _videoContext.screenHeight;
+ offsetY = _videoContext.shakeOffsetY;
+ }
+
+ point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area);
+ point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area);
+
+ *x = (int)(point.x * width);
+ // offsetY describes the translation of the screen in the upward direction,
+ // thus we need to add it here.
+ *y = (int)(point.y * height + offsetY);
+
+ // Clip coordinates
+ if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area))
+ return false;
+
+ return true;
+}
+
- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation {
switch (orientation) {
case UIDeviceOrientationLandscapeLeft:
@@ -752,7 +752,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *
case 1: {
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self];
- if (!getMouseCoords(_orientation, point, &x, &y))
+ if (![self getMouseCoords:point eventX:&x eventY:&y])
return;
_firstTouch = touch;
@@ -770,7 +770,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *
case 2: {
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:self];
- if (!getMouseCoords(_orientation, point, &x, &y))
+ if (![self getMouseCoords:point eventX:&x eventY:&y])
return;
_secondTouch = touch;
@@ -794,7 +794,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *
for (UITouch *touch in touches) {
if (touch == _firstTouch) {
CGPoint point = [touch locationInView:self];
- if (!getMouseCoords(_orientation, point, &x, &y))
+ if (![self getMouseCoords:point eventX:&x eventY:&y])
return;
[self addEvent:
@@ -807,7 +807,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *
];
} else if (touch == _secondTouch) {
CGPoint point = [touch locationInView:self];
- if (!getMouseCoords(_orientation, point, &x, &y))
+ if (![self getMouseCoords:point eventX:&x eventY:&y])
return;
[self addEvent:
@@ -830,7 +830,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *
case 1: {
UITouch *touch = [[allTouches allObjects] objectAtIndex:0];
CGPoint point = [touch locationInView:self];
- if (!getMouseCoords(_orientation, point, &x, &y))
+ if (![self getMouseCoords:point eventX:&x eventY:&y])
return;
[self addEvent:
@@ -847,7 +847,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *
case 2: {
UITouch *touch = [[allTouches allObjects] objectAtIndex:1];
CGPoint point = [touch locationInView:self];
- if (!getMouseCoords(_orientation, point, &x, &y))
+ if (![self getMouseCoords:point eventX:&x eventY:&y])
return;
[self addEvent:
Commit: e1edb20fed788aafc70f70448957b03b4f8f237d
https://github.com/scummvm/scummvm/commit/e1edb20fed788aafc70f70448957b03b4f8f237d
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T17:04:40-08:00
Commit Message:
IPHONE: Move VideoContext definition to iphone_common.h.
Changed paths:
backends/platform/iphone/iphone_common.h
backends/platform/iphone/iphone_video.h
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index 5a46a6d..044b279 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -55,6 +55,24 @@ enum GraphicsModes {
kGraphicsModeNone = 1
};
+struct VideoContext {
+ // Game screen state
+ int screenWidth, screenHeight;
+
+ // Overlay state
+ int overlayWidth, overlayHeight;
+
+ // Mouse cursor state
+ int mouseX, mouseY;
+ int mouseHotspotX, mouseHotspotY;
+ int mouseWidth, mouseHeight;
+ bool mouseIsVisible;
+
+ // Misc state
+ GraphicsModes graphicsMode;
+ int shakeOffsetY;
+};
+
// On the ObjC side
void iPhone_setGraphicsMode(GraphicsModes mode);
void iPhone_updateScreen(int mouseX, int mouseY);
diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h
index 733851f..2677267 100644
--- a/backends/platform/iphone/iphone_video.h
+++ b/backends/platform/iphone/iphone_video.h
@@ -34,24 +34,6 @@
#include "iphone_keyboard.h"
#include "iphone_common.h"
-struct VideoContext {
- // Game screen state
- int screenWidth, screenHeight;
-
- // Overlay state
- int overlayWidth, overlayHeight;
-
- // Mouse cursor state
- int mouseX, mouseY;
- int mouseHotspotX, mouseHotspotY;
- int mouseWidth, mouseHeight;
- bool mouseIsVisible;
-
- // Misc state
- GraphicsModes graphicsMode;
- int shakeOffsetY;
-};
-
@interface iPhoneView : UIView {
NSMutableArray *_events;
SoftKeyboard *_keyboardView;
Commit: ab15435ad0aac842ab8321b833cae4e7459df01d
https://github.com/scummvm/scummvm/commit/ab15435ad0aac842ab8321b833cae4e7459df01d
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T17:09:27-08:00
Commit Message:
IPHONE: Move overlay visibility status to VideoContext.
Changed paths:
backends/platform/iphone/iphone_common.h
backends/platform/iphone/iphone_video.mm
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index 044b279..2696888 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -60,6 +60,7 @@ struct VideoContext {
int screenWidth, screenHeight;
// Overlay state
+ bool overlayVisible;
int overlayWidth, overlayHeight;
// Mouse cursor state
@@ -85,7 +86,7 @@ const char *iPhone_getDocumentsDir();
bool iPhone_isHighResDevice();
int iPhone_getScreenHeight();
int iPhone_getScreenWidth();
-void iPhone_enableOverlay(int state);
+void iPhone_enableOverlay(bool state);
void iPhone_showCursor(int state);
void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY);
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index e461691..a4de970 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -37,7 +37,6 @@ static int _overlayTexHeight = 0;
static CGRect _overlayRect;
static int _needsScreenUpdate = 0;
-static int _overlayIsEnabled = 0;
static UITouch *_firstTouch = NULL;
static UITouch *_secondTouch = NULL;
@@ -93,8 +92,8 @@ void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int ho
[sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES];
}
-void iPhone_enableOverlay(int state) {
- _overlayIsEnabled = state;
+void iPhone_enableOverlay(bool state) {
+ _videoContext.overlayVisible = state;
[sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
}
@@ -272,6 +271,7 @@ const char *iPhone_getDocumentsDir() {
_mouseCursorTexture = 0;
_videoContext.graphicsMode = kGraphicsModeLinear;
+ _videoContext.overlayVisible = false;
_gameScreenVertCoords[0] = _gameScreenVertCoords[1] =
_gameScreenVertCoords[2] = _gameScreenVertCoords[3] =
@@ -363,7 +363,7 @@ const char *iPhone_getDocumentsDir() {
[self updateMainSurface];
- if (_overlayIsEnabled)
+ if (_videoContext.overlayVisible)
[self updateOverlaySurface];
if (_videoContext.mouseIsVisible)
@@ -422,7 +422,7 @@ const char *iPhone_getDocumentsDir() {
CGRect *rect;
int maxWidth, maxHeight;
- if (!_overlayIsEnabled) {
+ if (!_videoContext.overlayVisible) {
rect = &_gameScreenRect;
maxWidth = _videoContext.screenWidth;
maxHeight = _videoContext.screenHeight;
@@ -695,7 +695,7 @@ const char *iPhone_getDocumentsDir() {
CGRect *area;
int width, height, offsetY;
- if (_overlayIsEnabled) {
+ if (_videoContext.overlayVisible) {
area = &_overlayRect;
width = _videoContext.overlayWidth;
height = _videoContext.overlayHeight;
Commit: 99ffbfedbcee50d46c49fdd2f78a409a51c91e3b
https://github.com/scummvm/scummvm/commit/99ffbfedbcee50d46c49fdd2f78a409a51c91e3b
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T17:25:26-08:00
Commit Message:
IPHONE: Use VideoContext in OSystem_IPHONE.
Changed paths:
backends/platform/iphone/osys_events.cpp
backends/platform/iphone/osys_main.cpp
backends/platform/iphone/osys_main.h
backends/platform/iphone/osys_video.mm
diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp
index c167da3..94ef565 100644
--- a/backends/platform/iphone/osys_events.cpp
+++ b/backends/platform/iphone/osys_events.cpp
@@ -122,8 +122,8 @@ bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) {
if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_LBUTTONDOWN;
- event.mouse.x = _mouseX;
- event.mouse.y = _mouseY;
+ event.mouse.x = _videoContext.mouseX;
+ event.mouse.y = _videoContext.mouseY;
return true;
} else {
_lastMouseDown = getMillis();
@@ -140,17 +140,17 @@ bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) {
return false;
} else if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_LBUTTONUP;
- event.mouse.x = _mouseX;
- event.mouse.y = _mouseY;
+ event.mouse.x = _videoContext.mouseX;
+ event.mouse.y = _videoContext.mouseY;
} else {
if (getMillis() - _lastMouseDown < 250) {
event.type = Common::EVENT_LBUTTONDOWN;
- event.mouse.x = _mouseX;
- event.mouse.y = _mouseY;
+ event.mouse.x = _videoContext.mouseX;
+ event.mouse.y = _videoContext.mouseY;
_queuedInputEvent.type = Common::EVENT_LBUTTONUP;
- _queuedInputEvent.mouse.x = _mouseX;
- _queuedInputEvent.mouse.y = _mouseY;
+ _queuedInputEvent.mouse.x = _videoContext.mouseX;
+ _queuedInputEvent.mouse.y = _videoContext.mouseY;
_lastMouseTap = getMillis();
_queuedEventTime = _lastMouseTap + kQueuedInputEventDelay;
} else
@@ -167,12 +167,12 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in
if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_LBUTTONUP;
- event.mouse.x = _mouseX;
- event.mouse.y = _mouseY;
+ event.mouse.x = _videoContext.mouseX;
+ event.mouse.y = _videoContext.mouseY;
_queuedInputEvent.type = Common::EVENT_RBUTTONDOWN;
- _queuedInputEvent.mouse.x = _mouseX;
- _queuedInputEvent.mouse.y = _mouseY;
+ _queuedInputEvent.mouse.x = _videoContext.mouseX;
+ _queuedInputEvent.mouse.y = _videoContext.mouseY;
} else
return false;
@@ -184,7 +184,7 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int
if (curTime - _lastSecondaryDown < 400) {
//printf("Right tap!\n");
- if (curTime - _lastSecondaryTap < 400 && !_overlayVisible) {
+ if (curTime - _lastSecondaryTap < 400 && !_videoContext.overlayVisible) {
//printf("Right escape!\n");
event.type = Common::EVENT_KEYDOWN;
_queuedInputEvent.type = Common::EVENT_KEYUP;
@@ -197,11 +197,11 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int
} else if (!_mouseClickAndDragEnabled) {
//printf("Rightclick!\n");
event.type = Common::EVENT_RBUTTONDOWN;
- event.mouse.x = _mouseX;
- event.mouse.y = _mouseY;
+ event.mouse.x = _videoContext.mouseX;
+ event.mouse.y = _videoContext.mouseY;
_queuedInputEvent.type = Common::EVENT_RBUTTONUP;
- _queuedInputEvent.mouse.x = _mouseX;
- _queuedInputEvent.mouse.y = _mouseY;
+ _queuedInputEvent.mouse.x = _videoContext.mouseX;
+ _queuedInputEvent.mouse.y = _videoContext.mouseY;
_lastSecondaryTap = curTime;
_queuedEventTime = curTime + kQueuedInputEventDelay;
} else {
@@ -211,8 +211,8 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int
}
if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_RBUTTONUP;
- event.mouse.x = _mouseX;
- event.mouse.y = _mouseY;
+ event.mouse.x = _videoContext.mouseX;
+ event.mouse.y = _videoContext.mouseY;
}
return true;
@@ -234,11 +234,11 @@ bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y
_lastPadX = x;
_lastPadY = y;
- mouseNewPosX = (int)(_mouseX - deltaX / 0.5f);
- mouseNewPosY = (int)(_mouseY - deltaY / 0.5f);
+ mouseNewPosX = (int)(_videoContext.mouseX - deltaX / 0.5f);
+ mouseNewPosY = (int)(_videoContext.mouseY - deltaY / 0.5f);
- int widthCap = _overlayVisible ? _overlayWidth : _screenWidth;
- int heightCap = _overlayVisible ? _overlayHeight : _screenHeight;
+ int widthCap = _videoContext.overlayVisible ? _videoContext.overlayWidth : _videoContext.screenWidth;
+ int heightCap = _videoContext.overlayVisible ? _videoContext.overlayHeight : _videoContext.screenHeight;
if (mouseNewPosX < 0)
mouseNewPosX = 0;
@@ -350,10 +350,10 @@ void OSystem_IPHONE::handleEvent_orientationChanged(int orientation) {
if (_screenOrientation != newOrientation) {
_screenOrientation = newOrientation;
- iPhone_initSurface(_screenWidth, _screenHeight);
+ iPhone_initSurface(_videoContext.screenWidth, _videoContext.screenHeight);
dirtyFullScreen();
- if (_overlayVisible)
+ if (_videoContext.overlayVisible)
dirtyFullOverlayScreen();
updateScreen();
}
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 2bdc09c..9e73fe7 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -55,18 +55,21 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL;
void *OSystem_IPHONE::s_soundParam = NULL;
OSystem_IPHONE::OSystem_IPHONE() :
- _mixer(NULL), _gameScreenRaw(NULL),
- _overlayVisible(false), _gameScreenConverted(NULL),
- _mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0),
+ _mixer(NULL), _gameScreenRaw(NULL), _gameScreenConverted(NULL),
+ _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0),
_mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0),
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0),
- _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0), _mouseCursorPaletteEnabled(false),
- _currentGraphicsMode(kGraphicsModeLinear) {
+ _overlayBuffer(0), _mouseCursorPaletteEnabled(false) {
_queuedInputEvent.type = Common::EVENT_INVALID;
_touchpadModeEnabled = !iPhone_isHighResDevice();
_fsFactory = new POSIXFilesystemFactory();
+
+ _videoContext.mouseWidth = _videoContext.mouseHeight = 0;
+ _videoContext.overlayWidth = _videoContext.overlayHeight = 0;
+ _videoContext.overlayVisible = false;
+ _videoContext.graphicsMode = kGraphicsModeLinear;
}
OSystem_IPHONE::~OSystem_IPHONE() {
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index e4b3d35..f654537 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -59,15 +59,13 @@ protected:
static SoundProc s_soundCallback;
static void *s_soundParam;
- int _currentGraphicsMode;
-
Audio::MixerImpl *_mixer;
+ VideoContext _videoContext;
+
Graphics::Surface _framebuffer;
byte *_gameScreenRaw;
OverlayColor *_overlayBuffer;
- uint16 _overlayHeight;
- uint16 _overlayWidth;
uint16 *_gameScreenConverted;
@@ -75,21 +73,14 @@ protected:
uint16 _gamePalette[256];
// For use with the mouse texture
uint16 _gamePaletteRGBA5551[256];
- bool _overlayVisible;
- uint16 _screenWidth;
- uint16 _screenHeight;
struct timeval _startTime;
uint32 _timeSuspended;
- bool _mouseVisible;
bool _mouseCursorPaletteEnabled;
uint16 _mouseCursorPalette[256];
byte *_mouseBuf;
byte _mouseKeyColor;
- uint _mouseWidth, _mouseHeight;
- uint _mouseX, _mouseY;
- int _mouseHotspotX, _mouseHotspotY;
bool _mouseDirty;
bool _mouseNeedTextureUpdate;
long _lastMouseDown;
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index e26c360..bfa96c3 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -38,7 +38,7 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) {
switch (mode) {
case kGraphicsModeNone:
case kGraphicsModeLinear:
- _currentGraphicsMode = mode;
+ _videoContext.graphicsMode = (GraphicsModes)mode;
iPhone_setGraphicsMode((GraphicsModes)mode);
return true;
@@ -48,14 +48,14 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) {
}
int OSystem_IPHONE::getGraphicsMode() const {
- return _currentGraphicsMode;
+ return _videoContext.graphicsMode;
}
void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
//printf("initSize(%i, %i)\n", width, height);
- _screenWidth = width;
- _screenHeight = height;
+ _videoContext.screenWidth = width;
+ _videoContext.screenHeight = height;
free(_gameScreenRaw);
@@ -64,7 +64,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
//free(_overlayBuffer);
- int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor);
+ int fullSize = _videoContext.screenWidth * _videoContext.screenHeight * sizeof(OverlayColor);
//_overlayBuffer = (OverlayColor *)malloc(fullSize);
clearOverlay();
@@ -76,27 +76,27 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
iPhone_initSurface(width, height);
if (_overlayBuffer == NULL) {
- _overlayHeight = iPhone_getScreenHeight();
- _overlayWidth = iPhone_getScreenWidth();
+ _videoContext.overlayHeight = iPhone_getScreenHeight();
+ _videoContext.overlayWidth = iPhone_getScreenWidth();
- printf("Overlay: (%u x %u)\n", _overlayWidth, _overlayHeight);
- _overlayBuffer = new OverlayColor[_overlayHeight * _overlayWidth];
+ printf("Overlay: (%u x %u)\n", _videoContext.overlayWidth, _videoContext.overlayHeight);
+ _overlayBuffer = new OverlayColor[_videoContext.overlayHeight * _videoContext.overlayWidth];
}
_fullScreenIsDirty = false;
dirtyFullScreen();
- _mouseVisible = false;
+ _videoContext.mouseIsVisible = false;
_mouseCursorPaletteEnabled = false;
_screenChangeCount++;
updateScreen();
}
int16 OSystem_IPHONE::getHeight() {
- return _screenHeight;
+ return _videoContext.screenHeight;
}
int16 OSystem_IPHONE::getWidth() {
- return _screenWidth;
+ return _videoContext.screenWidth;
}
void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) {
@@ -137,12 +137,12 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
y = 0;
}
- if (w > _screenWidth - x) {
- w = _screenWidth - x;
+ if (w > _videoContext.screenWidth - x) {
+ w = _videoContext.screenWidth - x;
}
- if (h > _screenHeight - y) {
- h = _screenHeight - y;
+ if (h > _videoContext.screenHeight - y) {
+ h = _videoContext.screenHeight - y;
}
if (w <= 0 || h <= 0)
@@ -153,14 +153,14 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
}
- byte *dst = _gameScreenRaw + y * _screenWidth + x;
- if (_screenWidth == pitch && pitch == w)
+ byte *dst = _gameScreenRaw + y * _videoContext.screenWidth + x;
+ if (_videoContext.screenWidth == pitch && pitch == w)
memcpy(dst, buf, h * w);
else {
do {
memcpy(dst, buf, w);
buf += pitch;
- dst += _screenWidth;
+ dst += _videoContext.screenWidth;
} while (--h);
}
}
@@ -176,7 +176,7 @@ void OSystem_IPHONE::updateScreen() {
_fullScreenIsDirty = false;
_fullScreenOverlayIsDirty = false;
- iPhone_updateScreen(_mouseX, _mouseY);
+ iPhone_updateScreen(_videoContext.mouseX, _videoContext.mouseY);
}
void OSystem_IPHONE::internUpdateScreen() {
@@ -193,7 +193,7 @@ void OSystem_IPHONE::internUpdateScreen() {
updateHardwareSurfaceForRect(dirtyRect);
}
- if (_overlayVisible) {
+ if (_videoContext.overlayVisible) {
while (_dirtyOverlayRects.size()) {
Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1);
@@ -207,14 +207,14 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
int h = dirtyRect.bottom - dirtyRect.top;
int w = dirtyRect.right - dirtyRect.left;
- byte *src = &_gameScreenRaw[dirtyRect.top * _screenWidth + dirtyRect.left];
- uint16 *dst = &_gameScreenConverted[dirtyRect.top * _screenWidth + dirtyRect.left];
+ byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext.screenWidth + dirtyRect.left];
+ uint16 *dst = &_gameScreenConverted[dirtyRect.top * _videoContext.screenWidth + dirtyRect.left];
for (int y = h; y > 0; y--) {
for (int x = w; x > 0; x--)
*dst++ = _gamePalette[*src++];
- dst += _screenWidth - w;
- src += _screenWidth - w;
+ dst += _videoContext.screenWidth - w;
+ src += _videoContext.screenWidth - w;
}
}
@@ -230,9 +230,9 @@ Graphics::Surface *OSystem_IPHONE::lockScreen() {
//printf("lockScreen()\n");
_framebuffer.pixels = _gameScreenRaw;
- _framebuffer.w = _screenWidth;
- _framebuffer.h = _screenHeight;
- _framebuffer.pitch = _screenWidth;
+ _framebuffer.w = _videoContext.screenWidth;
+ _framebuffer.h = _videoContext.screenHeight;
+ _framebuffer.pitch = _videoContext.screenWidth;
_framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
return &_framebuffer;
@@ -252,7 +252,7 @@ void OSystem_IPHONE::setShakePos(int shakeOffset) {
void OSystem_IPHONE::showOverlay() {
//printf("showOverlay()\n");
- _overlayVisible = true;
+ _videoContext.overlayVisible = true;
dirtyFullOverlayScreen();
updateScreen();
iPhone_enableOverlay(true);
@@ -260,7 +260,7 @@ void OSystem_IPHONE::showOverlay() {
void OSystem_IPHONE::hideOverlay() {
//printf("hideOverlay()\n");
- _overlayVisible = false;
+ _videoContext.overlayVisible = false;
_dirtyOverlayRects.clear();
dirtyFullScreen();
iPhone_enableOverlay(false);
@@ -268,18 +268,18 @@ void OSystem_IPHONE::hideOverlay() {
void OSystem_IPHONE::clearOverlay() {
//printf("clearOverlay()\n");
- bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor));
+ bzero(_overlayBuffer, _videoContext.overlayWidth * _videoContext.overlayHeight * sizeof(OverlayColor));
dirtyFullOverlayScreen();
}
void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
//printf("grabOverlay()\n");
- int h = _overlayHeight;
+ int h = _videoContext.overlayHeight;
OverlayColor *src = _overlayBuffer;
do {
- memcpy(buf, src, _overlayWidth * sizeof(OverlayColor));
- src += _overlayWidth;
+ memcpy(buf, src, _videoContext.overlayWidth * sizeof(OverlayColor));
+ src += _videoContext.overlayWidth;
buf += pitch;
} while (--h);
}
@@ -300,11 +300,11 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x
y = 0;
}
- if (w > _overlayWidth - x)
- w = _overlayWidth - x;
+ if (w > _videoContext.overlayWidth - x)
+ w = _videoContext.overlayWidth - x;
- if (h > _overlayHeight - y)
- h = _overlayHeight - y;
+ if (h > _videoContext.overlayHeight - y)
+ h = _videoContext.overlayHeight - y;
if (w <= 0 || h <= 0)
return;
@@ -313,29 +313,29 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x
_dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h));
}
- OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x);
- if (_overlayWidth == pitch && pitch == w)
+ OverlayColor *dst = _overlayBuffer + (y * _videoContext.overlayWidth + x);
+ if (_videoContext.overlayWidth == pitch && pitch == w)
memcpy(dst, buf, h * w * sizeof(OverlayColor));
else {
do {
memcpy(dst, buf, w * sizeof(OverlayColor));
buf += pitch;
- dst += _overlayWidth;
+ dst += _videoContext.overlayWidth;
} while (--h);
}
}
int16 OSystem_IPHONE::getOverlayHeight() {
- return _overlayHeight;
+ return _videoContext.overlayHeight;
}
int16 OSystem_IPHONE::getOverlayWidth() {
- return _overlayWidth;
+ return _videoContext.overlayWidth;
}
bool OSystem_IPHONE::showMouse(bool visible) {
- bool last = _mouseVisible;
- _mouseVisible = visible;
+ bool last = _videoContext.mouseIsVisible;
+ _videoContext.mouseIsVisible = visible;
iPhone_showCursor(visible);
_mouseDirty = true;
@@ -345,15 +345,15 @@ bool OSystem_IPHONE::showMouse(bool visible) {
void OSystem_IPHONE::warpMouse(int x, int y) {
//printf("warpMouse()\n");
- _mouseX = x;
- _mouseY = y;
+ _videoContext.mouseX = x;
+ _videoContext.mouseY = y;
_mouseDirty = true;
}
void OSystem_IPHONE::dirtyFullScreen() {
if (!_fullScreenIsDirty) {
_dirtyRects.clear();
- _dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+ _dirtyRects.push_back(Common::Rect(0, 0, _videoContext.screenWidth, _videoContext.screenHeight));
_fullScreenIsDirty = true;
}
}
@@ -361,7 +361,7 @@ void OSystem_IPHONE::dirtyFullScreen() {
void OSystem_IPHONE::dirtyFullOverlayScreen() {
if (!_fullScreenOverlayIsDirty) {
_dirtyOverlayRects.clear();
- _dirtyOverlayRects.push_back(Common::Rect(0, 0, _overlayWidth, _overlayHeight));
+ _dirtyOverlayRects.push_back(Common::Rect(0, 0, _videoContext.overlayWidth, _videoContext.overlayHeight));
_fullScreenOverlayIsDirty = true;
}
}
@@ -369,7 +369,7 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() {
void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
//printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale);
- if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
+ if (_mouseBuf != NULL && (_videoContext.mouseWidth != w || _videoContext.mouseHeight != h)) {
free(_mouseBuf);
_mouseBuf = NULL;
}
@@ -377,11 +377,11 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot
if (_mouseBuf == NULL)
_mouseBuf = (byte *)malloc(w * h);
- _mouseWidth = w;
- _mouseHeight = h;
+ _videoContext.mouseWidth = w;
+ _videoContext.mouseHeight = h;
- _mouseHotspotX = hotspotX;
- _mouseHotspotY = hotspotY;
+ _videoContext.mouseHotspotX = hotspotX;
+ _videoContext.mouseHotspotY = hotspotY;
_mouseKeyColor = (byte)keycolor;
@@ -406,8 +406,8 @@ void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num)
}
void OSystem_IPHONE::updateMouseTexture() {
- int texWidth = getSizeNextPOT(_mouseWidth);
- int texHeight = getSizeNextPOT(_mouseHeight);
+ int texWidth = getSizeNextPOT(_videoContext.mouseWidth);
+ int texHeight = getSizeNextPOT(_videoContext.mouseHeight);
int bufferSize = texWidth * texHeight * sizeof(int16);
uint16 *mouseBuf = (uint16 *)malloc(bufferSize);
memset(mouseBuf, 0, bufferSize);
@@ -418,9 +418,9 @@ void OSystem_IPHONE::updateMouseTexture() {
else
palette = _gamePaletteRGBA5551;
- for (uint x = 0; x < _mouseWidth; ++x) {
- for (uint y = 0; y < _mouseHeight; ++y) {
- const byte color = _mouseBuf[y * _mouseWidth + x];
+ for (uint x = 0; x < _videoContext.mouseWidth; ++x) {
+ for (uint y = 0; y < _videoContext.mouseHeight; ++y) {
+ const byte color = _mouseBuf[y * _videoContext.mouseWidth + x];
if (color != _mouseKeyColor)
mouseBuf[y * texWidth + x] = palette[color] | 0x1;
else
@@ -428,5 +428,5 @@ void OSystem_IPHONE::updateMouseTexture() {
}
}
- iPhone_setMouseCursor(mouseBuf, _mouseWidth, _mouseHeight, _mouseHotspotX, _mouseHotspotY);
+ iPhone_setMouseCursor(mouseBuf, _videoContext.mouseWidth, _videoContext.mouseHeight, _videoContext.mouseHotspotX, _videoContext.mouseHotspotY);
}
Commit: e00fc73eb891b7f460e2377fed7f12224a9103cf
https://github.com/scummvm/scummvm/commit/e00fc73eb891b7f460e2377fed7f12224a9103cf
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T17:26:54-08:00
Commit Message:
IPHONE: Silence a few signed/unsigned integer comparison warnings.
Changed paths:
backends/platform/iphone/iphone_common.h
backends/platform/iphone/osys_video.mm
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index 2696888..93637a3 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -57,16 +57,16 @@ enum GraphicsModes {
struct VideoContext {
// Game screen state
- int screenWidth, screenHeight;
+ uint screenWidth, screenHeight;
// Overlay state
bool overlayVisible;
- int overlayWidth, overlayHeight;
+ uint overlayWidth, overlayHeight;
// Mouse cursor state
- int mouseX, mouseY;
+ uint mouseX, mouseY;
int mouseHotspotX, mouseHotspotY;
- int mouseWidth, mouseHeight;
+ uint mouseWidth, mouseHeight;
bool mouseIsVisible;
// Misc state
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index bfa96c3..574fc07 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -137,11 +137,11 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
y = 0;
}
- if (w > _videoContext.screenWidth - x) {
+ if (w > (int)_videoContext.screenWidth - x) {
w = _videoContext.screenWidth - x;
}
- if (h > _videoContext.screenHeight - y) {
+ if (h > (int)_videoContext.screenHeight - y) {
h = _videoContext.screenHeight - y;
}
@@ -154,7 +154,7 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
byte *dst = _gameScreenRaw + y * _videoContext.screenWidth + x;
- if (_videoContext.screenWidth == pitch && pitch == w)
+ if ((int)_videoContext.screenWidth == pitch && pitch == w)
memcpy(dst, buf, h * w);
else {
do {
@@ -300,10 +300,10 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x
y = 0;
}
- if (w > _videoContext.overlayWidth - x)
+ if (w > (int)_videoContext.overlayWidth - x)
w = _videoContext.overlayWidth - x;
- if (h > _videoContext.overlayHeight - y)
+ if (h > (int)_videoContext.overlayHeight - y)
h = _videoContext.overlayHeight - y;
if (w <= 0 || h <= 0)
@@ -314,7 +314,7 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x
}
OverlayColor *dst = _overlayBuffer + (y * _videoContext.overlayWidth + x);
- if (_videoContext.overlayWidth == pitch && pitch == w)
+ if ((int)_videoContext.overlayWidth == pitch && pitch == w)
memcpy(dst, buf, h * w * sizeof(OverlayColor));
else {
do {
Commit: 5ae958bcf3a1dc4d7be093eac99eb0d5145c8c7e
https://github.com/scummvm/scummvm/commit/5ae958bcf3a1dc4d7be093eac99eb0d5145c8c7e
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-22T18:18:00-08:00
Commit Message:
IPHONE: Let iPhoneView and OSystem_IPHONE share the same VideoContext.
This allows for better sharing between the current video state in the view and
the OSystem implementation.
This also gets rid of most C interface functions for calling ObjC code.
Changed paths:
backends/platform/iphone/iphone_common.h
backends/platform/iphone/iphone_video.h
backends/platform/iphone/iphone_video.mm
backends/platform/iphone/osys_events.cpp
backends/platform/iphone/osys_main.cpp
backends/platform/iphone/osys_main.h
backends/platform/iphone/osys_video.mm
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index 93637a3..18821e6 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -75,20 +75,13 @@ struct VideoContext {
};
// On the ObjC side
-void iPhone_setGraphicsMode(GraphicsModes mode);
-void iPhone_updateScreen(int mouseX, int mouseY);
-void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2);
-void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2);
-void iPhone_initSurface(int width, int height);
-void iPhone_setShakeOffset(int offset);
+void iPhone_updateScreen();
+void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width);
+void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width);
bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY);
const char *iPhone_getDocumentsDir();
bool iPhone_isHighResDevice();
-int iPhone_getScreenHeight();
-int iPhone_getScreenWidth();
-void iPhone_enableOverlay(bool state);
-void iPhone_showCursor(int state);
-void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY);
+void iPhone_setMouseCursor(unsigned short *buffer);
uint getSizeNextPOT(uint size);
diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h
index 2677267..1d9d7e7 100644
--- a/backends/platform/iphone/iphone_video.h
+++ b/backends/platform/iphone/iphone_video.h
@@ -35,6 +35,8 @@
#include "iphone_common.h"
@interface iPhoneView : UIView {
+ VideoContext _videoContext;
+
NSMutableArray *_events;
SoftKeyboard *_keyboardView;
@@ -56,6 +58,8 @@
- (id)initWithFrame:(struct CGRect)frame;
+- (VideoContext *)getVideoContext;
+
- (void)drawRect:(CGRect)frame;
- (void)initSurface;
@@ -81,4 +85,6 @@
@end
+extern iPhoneView *g_iPhoneViewInstance;
+
#endif
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index a4de970..387ed72 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -22,7 +22,7 @@
#include "iphone_video.h"
-static iPhoneView *sharedInstance = nil;
+iPhoneView *g_iPhoneViewInstance = nil;
static int _fullWidth;
static int _fullHeight;
static CGRect _gameScreenRect;
@@ -48,8 +48,6 @@ static GLint _renderBufferHeight;
static int _scaledShakeOffsetY;
-static VideoContext _videoContext;
-
#if 0
static long lastTick = 0;
static int frames = 0;
@@ -70,83 +68,36 @@ int printOglError(const char *file, int line) {
return retCode;
}
-void iPhone_setGraphicsMode(GraphicsModes mode) {
- _videoContext.graphicsMode = mode;
-
- [sharedInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES];
-}
-
-void iPhone_showCursor(int state) {
- _videoContext.mouseIsVisible = state;
-}
-
-void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY) {
+void iPhone_setMouseCursor(unsigned short *buffer) {
_mouseCursor = buffer;
-
- _videoContext.mouseWidth = width;
- _videoContext.mouseHeight = height;
-
- _videoContext.mouseHotspotX = hotspotX;
- _videoContext.mouseHotspotY = hotspotY;
-
- [sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES];
-}
-
-void iPhone_enableOverlay(bool state) {
- _videoContext.overlayVisible = state;
-
- [sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
-}
-
-int iPhone_getScreenHeight() {
- return _videoContext.overlayHeight;
-}
-
-int iPhone_getScreenWidth() {
- return _videoContext.overlayWidth;
+ [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES];
}
bool iPhone_isHighResDevice() {
return _fullHeight > 480;
}
-void iPhone_updateScreen(int mouseX, int mouseY) {
+void iPhone_updateScreen() {
//printf("Mouse: (%i, %i)\n", mouseX, mouseY);
-
- _videoContext.mouseX = mouseX;
- _videoContext.mouseY = mouseY;
-
if (!_needsScreenUpdate) {
_needsScreenUpdate = 1;
- [sharedInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO];
+ [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO];
}
}
-void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) {
+void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width) {
for (int y = y1; y < y2; ++y)
- memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * _videoContext.screenWidth + x1], (x2 - x1) * 2);
+ memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * width + x1], (x2 - x1) * 2);
}
-void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) {
+void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width) {
//printf("Overlaywidth: %u, fullwidth %u\n", _videoContext.overlayWidth, _fullWidth);
for (int y = y1; y < y2; ++y)
- memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * _videoContext.overlayWidth + x1], (x2 - x1) * 2);
-}
-
-void iPhone_initSurface(int width, int height) {
- _videoContext.screenWidth = width;
- _videoContext.screenHeight = height;
- _videoContext.shakeOffsetY = 0;
- [sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES];
-}
-
-void iPhone_setShakeOffset(int offset) {
- _videoContext.shakeOffsetY = offset;
- [sharedInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES];
+ memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * width + x1], (x2 - x1) * 2);
}
bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) {
- id event = [sharedInstance getEvent];
+ id event = [g_iPhoneViewInstance getEvent];
if (event == nil) {
return false;
}
@@ -189,6 +140,10 @@ const char *iPhone_getDocumentsDir() {
return [CAEAGLLayer class];
}
+- (VideoContext *)getVideoContext {
+ return &_videoContext;
+}
+
- (void)createContext {
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
@@ -263,13 +218,14 @@ const char *iPhone_getDocumentsDir() {
_fullWidth = (int)frame.size.width;
_fullHeight = (int)frame.size.height;
- sharedInstance = self;
+ g_iPhoneViewInstance = self;
_keyboardView = nil;
_screenTexture = 0;
_overlayTexture = 0;
_mouseCursorTexture = 0;
+ memset(&_videoContext, 0, sizeof(_videoContext));
_videoContext.graphicsMode = kGraphicsModeLinear;
_videoContext.overlayVisible = false;
diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp
index 94ef565..85efbda 100644
--- a/backends/platform/iphone/osys_events.cpp
+++ b/backends/platform/iphone/osys_events.cpp
@@ -122,8 +122,8 @@ bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) {
if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_LBUTTONDOWN;
- event.mouse.x = _videoContext.mouseX;
- event.mouse.y = _videoContext.mouseY;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
return true;
} else {
_lastMouseDown = getMillis();
@@ -140,17 +140,17 @@ bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) {
return false;
} else if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_LBUTTONUP;
- event.mouse.x = _videoContext.mouseX;
- event.mouse.y = _videoContext.mouseY;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
} else {
if (getMillis() - _lastMouseDown < 250) {
event.type = Common::EVENT_LBUTTONDOWN;
- event.mouse.x = _videoContext.mouseX;
- event.mouse.y = _videoContext.mouseY;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
_queuedInputEvent.type = Common::EVENT_LBUTTONUP;
- _queuedInputEvent.mouse.x = _videoContext.mouseX;
- _queuedInputEvent.mouse.y = _videoContext.mouseY;
+ _queuedInputEvent.mouse.x = _videoContext->mouseX;
+ _queuedInputEvent.mouse.y = _videoContext->mouseY;
_lastMouseTap = getMillis();
_queuedEventTime = _lastMouseTap + kQueuedInputEventDelay;
} else
@@ -167,12 +167,12 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in
if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_LBUTTONUP;
- event.mouse.x = _videoContext.mouseX;
- event.mouse.y = _videoContext.mouseY;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
_queuedInputEvent.type = Common::EVENT_RBUTTONDOWN;
- _queuedInputEvent.mouse.x = _videoContext.mouseX;
- _queuedInputEvent.mouse.y = _videoContext.mouseY;
+ _queuedInputEvent.mouse.x = _videoContext->mouseX;
+ _queuedInputEvent.mouse.y = _videoContext->mouseY;
} else
return false;
@@ -184,7 +184,7 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int
if (curTime - _lastSecondaryDown < 400) {
//printf("Right tap!\n");
- if (curTime - _lastSecondaryTap < 400 && !_videoContext.overlayVisible) {
+ if (curTime - _lastSecondaryTap < 400 && !_videoContext->overlayVisible) {
//printf("Right escape!\n");
event.type = Common::EVENT_KEYDOWN;
_queuedInputEvent.type = Common::EVENT_KEYUP;
@@ -197,11 +197,11 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int
} else if (!_mouseClickAndDragEnabled) {
//printf("Rightclick!\n");
event.type = Common::EVENT_RBUTTONDOWN;
- event.mouse.x = _videoContext.mouseX;
- event.mouse.y = _videoContext.mouseY;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
_queuedInputEvent.type = Common::EVENT_RBUTTONUP;
- _queuedInputEvent.mouse.x = _videoContext.mouseX;
- _queuedInputEvent.mouse.y = _videoContext.mouseY;
+ _queuedInputEvent.mouse.x = _videoContext->mouseX;
+ _queuedInputEvent.mouse.y = _videoContext->mouseY;
_lastSecondaryTap = curTime;
_queuedEventTime = curTime + kQueuedInputEventDelay;
} else {
@@ -211,8 +211,8 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int
}
if (_mouseClickAndDragEnabled) {
event.type = Common::EVENT_RBUTTONUP;
- event.mouse.x = _videoContext.mouseX;
- event.mouse.y = _videoContext.mouseY;
+ event.mouse.x = _videoContext->mouseX;
+ event.mouse.y = _videoContext->mouseY;
}
return true;
@@ -234,11 +234,11 @@ bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y
_lastPadX = x;
_lastPadY = y;
- mouseNewPosX = (int)(_videoContext.mouseX - deltaX / 0.5f);
- mouseNewPosY = (int)(_videoContext.mouseY - deltaY / 0.5f);
+ mouseNewPosX = (int)(_videoContext->mouseX - deltaX / 0.5f);
+ mouseNewPosY = (int)(_videoContext->mouseY - deltaY / 0.5f);
- int widthCap = _videoContext.overlayVisible ? _videoContext.overlayWidth : _videoContext.screenWidth;
- int heightCap = _videoContext.overlayVisible ? _videoContext.overlayHeight : _videoContext.screenHeight;
+ int widthCap = _videoContext->overlayVisible ? _videoContext->overlayWidth : _videoContext->screenWidth;
+ int heightCap = _videoContext->overlayVisible ? _videoContext->overlayHeight : _videoContext->screenHeight;
if (mouseNewPosX < 0)
mouseNewPosX = 0;
@@ -350,10 +350,10 @@ void OSystem_IPHONE::handleEvent_orientationChanged(int orientation) {
if (_screenOrientation != newOrientation) {
_screenOrientation = newOrientation;
- iPhone_initSurface(_videoContext.screenWidth, _videoContext.screenHeight);
+ updateOutputSurface();
dirtyFullScreen();
- if (_videoContext.overlayVisible)
+ if (_videoContext->overlayVisible)
dirtyFullOverlayScreen();
updateScreen();
}
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 9e73fe7..368434c 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -65,11 +65,7 @@ OSystem_IPHONE::OSystem_IPHONE() :
_queuedInputEvent.type = Common::EVENT_INVALID;
_touchpadModeEnabled = !iPhone_isHighResDevice();
_fsFactory = new POSIXFilesystemFactory();
-
- _videoContext.mouseWidth = _videoContext.mouseHeight = 0;
- _videoContext.overlayWidth = _videoContext.overlayHeight = 0;
- _videoContext.overlayVisible = false;
- _videoContext.graphicsMode = kGraphicsModeLinear;
+ initVideoContext();
}
OSystem_IPHONE::~OSystem_IPHONE() {
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index f654537..39395ac 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -61,7 +61,7 @@ protected:
Audio::MixerImpl *_mixer;
- VideoContext _videoContext;
+ VideoContext *_videoContext;
Graphics::Surface _framebuffer;
byte *_gameScreenRaw;
@@ -183,6 +183,9 @@ public:
virtual void logMessage(LogMessageType::Type type, const char *message);
protected:
+ void initVideoContext();
+ void updateOutputSurface();
+
void internUpdateScreen();
void dirtyFullScreen();
void dirtyFullOverlayScreen();
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index 574fc07..a40fcae 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -25,11 +25,16 @@
#include "osys_main.h"
+#include "iphone_video.h"
+
+void OSystem_IPHONE::initVideoContext() {
+ _videoContext = [g_iPhoneViewInstance getVideoContext];
+}
+
const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const {
return s_supportedGraphicsModes;
}
-
int OSystem_IPHONE::getDefaultGraphicsMode() const {
return kGraphicsModeLinear;
}
@@ -38,8 +43,8 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) {
switch (mode) {
case kGraphicsModeNone:
case kGraphicsModeLinear:
- _videoContext.graphicsMode = (GraphicsModes)mode;
- iPhone_setGraphicsMode((GraphicsModes)mode);
+ _videoContext->graphicsMode = (GraphicsModes)mode;
+ [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES];
return true;
default:
@@ -48,14 +53,15 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) {
}
int OSystem_IPHONE::getGraphicsMode() const {
- return _videoContext.graphicsMode;
+ return _videoContext->graphicsMode;
}
void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
//printf("initSize(%i, %i)\n", width, height);
- _videoContext.screenWidth = width;
- _videoContext.screenHeight = height;
+ _videoContext->screenWidth = width;
+ _videoContext->screenHeight = height;
+ _videoContext->shakeOffsetY = 0;
free(_gameScreenRaw);
@@ -64,39 +70,42 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
//free(_overlayBuffer);
- int fullSize = _videoContext.screenWidth * _videoContext.screenHeight * sizeof(OverlayColor);
+ int fullSize = _videoContext->screenWidth * _videoContext->screenHeight * sizeof(OverlayColor);
//_overlayBuffer = (OverlayColor *)malloc(fullSize);
- clearOverlay();
free(_gameScreenConverted);
_gameScreenConverted = (uint16 *)malloc(fullSize);
bzero(_gameScreenConverted, fullSize);
- iPhone_initSurface(width, height);
+ updateOutputSurface();
if (_overlayBuffer == NULL) {
- _videoContext.overlayHeight = iPhone_getScreenHeight();
- _videoContext.overlayWidth = iPhone_getScreenWidth();
-
- printf("Overlay: (%u x %u)\n", _videoContext.overlayWidth, _videoContext.overlayHeight);
- _overlayBuffer = new OverlayColor[_videoContext.overlayHeight * _videoContext.overlayWidth];
+ printf("Overlay: (%u x %u)\n", _videoContext->overlayWidth, _videoContext->overlayHeight);
+ _overlayBuffer = new OverlayColor[_videoContext->overlayHeight * _videoContext->overlayWidth];
}
+ clearOverlay();
+
_fullScreenIsDirty = false;
dirtyFullScreen();
- _videoContext.mouseIsVisible = false;
+ _videoContext->mouseIsVisible = false;
_mouseCursorPaletteEnabled = false;
_screenChangeCount++;
+
updateScreen();
}
+void OSystem_IPHONE::updateOutputSurface() {
+ [g_iPhoneViewInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES];
+}
+
int16 OSystem_IPHONE::getHeight() {
- return _videoContext.screenHeight;
+ return _videoContext->screenHeight;
}
int16 OSystem_IPHONE::getWidth() {
- return _videoContext.screenWidth;
+ return _videoContext->screenWidth;
}
void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) {
@@ -137,12 +146,12 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
y = 0;
}
- if (w > (int)_videoContext.screenWidth - x) {
- w = _videoContext.screenWidth - x;
+ if (w > (int)_videoContext->screenWidth - x) {
+ w = _videoContext->screenWidth - x;
}
- if (h > (int)_videoContext.screenHeight - y) {
- h = _videoContext.screenHeight - y;
+ if (h > (int)_videoContext->screenHeight - y) {
+ h = _videoContext->screenHeight - y;
}
if (w <= 0 || h <= 0)
@@ -153,14 +162,14 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
}
- byte *dst = _gameScreenRaw + y * _videoContext.screenWidth + x;
- if ((int)_videoContext.screenWidth == pitch && pitch == w)
+ byte *dst = _gameScreenRaw + y * _videoContext->screenWidth + x;
+ if ((int)_videoContext->screenWidth == pitch && pitch == w)
memcpy(dst, buf, h * w);
else {
do {
memcpy(dst, buf, w);
buf += pitch;
- dst += _videoContext.screenWidth;
+ dst += _videoContext->screenWidth;
} while (--h);
}
}
@@ -176,7 +185,7 @@ void OSystem_IPHONE::updateScreen() {
_fullScreenIsDirty = false;
_fullScreenOverlayIsDirty = false;
- iPhone_updateScreen(_videoContext.mouseX, _videoContext.mouseY);
+ iPhone_updateScreen();
}
void OSystem_IPHONE::internUpdateScreen() {
@@ -193,7 +202,7 @@ void OSystem_IPHONE::internUpdateScreen() {
updateHardwareSurfaceForRect(dirtyRect);
}
- if (_videoContext.overlayVisible) {
+ if (_videoContext->overlayVisible) {
while (_dirtyOverlayRects.size()) {
Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1);
@@ -207,32 +216,32 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
int h = dirtyRect.bottom - dirtyRect.top;
int w = dirtyRect.right - dirtyRect.left;
- byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext.screenWidth + dirtyRect.left];
- uint16 *dst = &_gameScreenConverted[dirtyRect.top * _videoContext.screenWidth + dirtyRect.left];
+ byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left];
+ uint16 *dst = &_gameScreenConverted[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left];
for (int y = h; y > 0; y--) {
for (int x = w; x > 0; x--)
*dst++ = _gamePalette[*src++];
- dst += _videoContext.screenWidth - w;
- src += _videoContext.screenWidth - w;
+ dst += _videoContext->screenWidth - w;
+ src += _videoContext->screenWidth - w;
}
}
void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) {
- iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
+ iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom, _videoContext->overlayWidth);
}
void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) {
- iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom);
+ iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom, _videoContext->screenWidth);
}
Graphics::Surface *OSystem_IPHONE::lockScreen() {
//printf("lockScreen()\n");
_framebuffer.pixels = _gameScreenRaw;
- _framebuffer.w = _videoContext.screenWidth;
- _framebuffer.h = _videoContext.screenHeight;
- _framebuffer.pitch = _videoContext.screenWidth;
+ _framebuffer.w = _videoContext->screenWidth;
+ _framebuffer.h = _videoContext->screenHeight;
+ _framebuffer.pitch = _videoContext->screenWidth;
_framebuffer.format = Graphics::PixelFormat::createFormatCLUT8();
return &_framebuffer;
@@ -245,41 +254,42 @@ void OSystem_IPHONE::unlockScreen() {
void OSystem_IPHONE::setShakePos(int shakeOffset) {
//printf("setShakePos(%i)\n", shakeOffset);
- iPhone_setShakeOffset(shakeOffset);
+ _videoContext->shakeOffsetY = shakeOffset;
+ [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES];
// HACK: We use this to force a redraw.
_mouseDirty = true;
}
void OSystem_IPHONE::showOverlay() {
//printf("showOverlay()\n");
- _videoContext.overlayVisible = true;
+ _videoContext->overlayVisible = true;
dirtyFullOverlayScreen();
updateScreen();
- iPhone_enableOverlay(true);
+ [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
}
void OSystem_IPHONE::hideOverlay() {
//printf("hideOverlay()\n");
- _videoContext.overlayVisible = false;
+ _videoContext->overlayVisible = false;
_dirtyOverlayRects.clear();
dirtyFullScreen();
- iPhone_enableOverlay(false);
+ [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
}
void OSystem_IPHONE::clearOverlay() {
//printf("clearOverlay()\n");
- bzero(_overlayBuffer, _videoContext.overlayWidth * _videoContext.overlayHeight * sizeof(OverlayColor));
+ bzero(_overlayBuffer, _videoContext->overlayWidth * _videoContext->overlayHeight * sizeof(OverlayColor));
dirtyFullOverlayScreen();
}
void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
//printf("grabOverlay()\n");
- int h = _videoContext.overlayHeight;
+ int h = _videoContext->overlayHeight;
OverlayColor *src = _overlayBuffer;
do {
- memcpy(buf, src, _videoContext.overlayWidth * sizeof(OverlayColor));
- src += _videoContext.overlayWidth;
+ memcpy(buf, src, _videoContext->overlayWidth * sizeof(OverlayColor));
+ src += _videoContext->overlayWidth;
buf += pitch;
} while (--h);
}
@@ -300,11 +310,11 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x
y = 0;
}
- if (w > (int)_videoContext.overlayWidth - x)
- w = _videoContext.overlayWidth - x;
+ if (w > (int)_videoContext->overlayWidth - x)
+ w = _videoContext->overlayWidth - x;
- if (h > (int)_videoContext.overlayHeight - y)
- h = _videoContext.overlayHeight - y;
+ if (h > (int)_videoContext->overlayHeight - y)
+ h = _videoContext->overlayHeight - y;
if (w <= 0 || h <= 0)
return;
@@ -313,30 +323,29 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x
_dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h));
}
- OverlayColor *dst = _overlayBuffer + (y * _videoContext.overlayWidth + x);
- if ((int)_videoContext.overlayWidth == pitch && pitch == w)
+ OverlayColor *dst = _overlayBuffer + (y * _videoContext->overlayWidth + x);
+ if ((int)_videoContext->overlayWidth == pitch && pitch == w)
memcpy(dst, buf, h * w * sizeof(OverlayColor));
else {
do {
memcpy(dst, buf, w * sizeof(OverlayColor));
buf += pitch;
- dst += _videoContext.overlayWidth;
+ dst += _videoContext->overlayWidth;
} while (--h);
}
}
int16 OSystem_IPHONE::getOverlayHeight() {
- return _videoContext.overlayHeight;
+ return _videoContext->overlayHeight;
}
int16 OSystem_IPHONE::getOverlayWidth() {
- return _videoContext.overlayWidth;
+ return _videoContext->overlayWidth;
}
bool OSystem_IPHONE::showMouse(bool visible) {
- bool last = _videoContext.mouseIsVisible;
- _videoContext.mouseIsVisible = visible;
- iPhone_showCursor(visible);
+ bool last = _videoContext->mouseIsVisible;
+ _videoContext->mouseIsVisible = visible;
_mouseDirty = true;
return last;
@@ -345,15 +354,15 @@ bool OSystem_IPHONE::showMouse(bool visible) {
void OSystem_IPHONE::warpMouse(int x, int y) {
//printf("warpMouse()\n");
- _videoContext.mouseX = x;
- _videoContext.mouseY = y;
+ _videoContext->mouseX = x;
+ _videoContext->mouseY = y;
_mouseDirty = true;
}
void OSystem_IPHONE::dirtyFullScreen() {
if (!_fullScreenIsDirty) {
_dirtyRects.clear();
- _dirtyRects.push_back(Common::Rect(0, 0, _videoContext.screenWidth, _videoContext.screenHeight));
+ _dirtyRects.push_back(Common::Rect(0, 0, _videoContext->screenWidth, _videoContext->screenHeight));
_fullScreenIsDirty = true;
}
}
@@ -361,7 +370,7 @@ void OSystem_IPHONE::dirtyFullScreen() {
void OSystem_IPHONE::dirtyFullOverlayScreen() {
if (!_fullScreenOverlayIsDirty) {
_dirtyOverlayRects.clear();
- _dirtyOverlayRects.push_back(Common::Rect(0, 0, _videoContext.overlayWidth, _videoContext.overlayHeight));
+ _dirtyOverlayRects.push_back(Common::Rect(0, 0, _videoContext->overlayWidth, _videoContext->overlayHeight));
_fullScreenOverlayIsDirty = true;
}
}
@@ -369,7 +378,7 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() {
void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
//printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale);
- if (_mouseBuf != NULL && (_videoContext.mouseWidth != w || _videoContext.mouseHeight != h)) {
+ if (_mouseBuf != NULL && (_videoContext->mouseWidth != w || _videoContext->mouseHeight != h)) {
free(_mouseBuf);
_mouseBuf = NULL;
}
@@ -377,11 +386,11 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot
if (_mouseBuf == NULL)
_mouseBuf = (byte *)malloc(w * h);
- _videoContext.mouseWidth = w;
- _videoContext.mouseHeight = h;
+ _videoContext->mouseWidth = w;
+ _videoContext->mouseHeight = h;
- _videoContext.mouseHotspotX = hotspotX;
- _videoContext.mouseHotspotY = hotspotY;
+ _videoContext->mouseHotspotX = hotspotX;
+ _videoContext->mouseHotspotY = hotspotY;
_mouseKeyColor = (byte)keycolor;
@@ -406,8 +415,8 @@ void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num)
}
void OSystem_IPHONE::updateMouseTexture() {
- int texWidth = getSizeNextPOT(_videoContext.mouseWidth);
- int texHeight = getSizeNextPOT(_videoContext.mouseHeight);
+ int texWidth = getSizeNextPOT(_videoContext->mouseWidth);
+ int texHeight = getSizeNextPOT(_videoContext->mouseHeight);
int bufferSize = texWidth * texHeight * sizeof(int16);
uint16 *mouseBuf = (uint16 *)malloc(bufferSize);
memset(mouseBuf, 0, bufferSize);
@@ -418,9 +427,9 @@ void OSystem_IPHONE::updateMouseTexture() {
else
palette = _gamePaletteRGBA5551;
- for (uint x = 0; x < _videoContext.mouseWidth; ++x) {
- for (uint y = 0; y < _videoContext.mouseHeight; ++y) {
- const byte color = _mouseBuf[y * _videoContext.mouseWidth + x];
+ for (uint x = 0; x < _videoContext->mouseWidth; ++x) {
+ for (uint y = 0; y < _videoContext->mouseHeight; ++y) {
+ const byte color = _mouseBuf[y * _videoContext->mouseWidth + x];
if (color != _mouseKeyColor)
mouseBuf[y * texWidth + x] = palette[color] | 0x1;
else
@@ -428,5 +437,5 @@ void OSystem_IPHONE::updateMouseTexture() {
}
}
- iPhone_setMouseCursor(mouseBuf, _videoContext.mouseWidth, _videoContext.mouseHeight, _videoContext.mouseHotspotX, _videoContext.mouseHotspotY);
+ iPhone_setMouseCursor(mouseBuf);
}
More information about the Scummvm-git-logs
mailing list