aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/iphone/iphone_video.mm
diff options
context:
space:
mode:
authorJohannes Schickel2012-02-23 03:13:09 +0100
committerJohannes Schickel2012-02-23 03:18:00 +0100
commit5ae958bcf3a1dc4d7be093eac99eb0d5145c8c7e (patch)
treec2d7a24d5837b666bfdb8f7dda155f77377334a6 /backends/platform/iphone/iphone_video.mm
parente00fc73eb891b7f460e2377fed7f12224a9103cf (diff)
downloadscummvm-rg350-5ae958bcf3a1dc4d7be093eac99eb0d5145c8c7e.tar.gz
scummvm-rg350-5ae958bcf3a1dc4d7be093eac99eb0d5145c8c7e.tar.bz2
scummvm-rg350-5ae958bcf3a1dc4d7be093eac99eb0d5145c8c7e.zip
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.
Diffstat (limited to 'backends/platform/iphone/iphone_video.mm')
-rw-r--r--backends/platform/iphone/iphone_video.mm76
1 files changed, 16 insertions, 60 deletions
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index a4de970420..387ed7252f 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;