aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Bénony2015-12-08 11:04:04 +0100
committerVincent Bénony2016-01-06 16:17:35 +0100
commitdd950fdb22dcc3d4be06ed416c09b6fb438144c4 (patch)
tree1e8e9c6f34d8c4b69127a69ff24cb1d8c29c5888
parentdad50ae0cc5c6daaa27d89cc85b07fffcaca7a77 (diff)
downloadscummvm-rg350-dd950fdb22dcc3d4be06ed416c09b6fb438144c4.tar.gz
scummvm-rg350-dd950fdb22dcc3d4be06ed416c09b6fb438144c4.tar.bz2
scummvm-rg350-dd950fdb22dcc3d4be06ed416c09b6fb438144c4.zip
IOS: Removes a global variable
-rw-r--r--backends/platform/ios7/iOS7AppDelegate.h6
-rw-r--r--backends/platform/ios7/iOS7AppDelegate.mm10
-rw-r--r--backends/platform/ios7/ios7_osys_video.mm23
-rw-r--r--backends/platform/ios7/ios7_video.h2
-rw-r--r--backends/platform/ios7/ios7_video.mm8
5 files changed, 31 insertions, 18 deletions
diff --git a/backends/platform/ios7/iOS7AppDelegate.h b/backends/platform/ios7/iOS7AppDelegate.h
index 49411698c1..7f903a692d 100644
--- a/backends/platform/ios7/iOS7AppDelegate.h
+++ b/backends/platform/ios7/iOS7AppDelegate.h
@@ -4,6 +4,12 @@
#import <UIKit/UIKit.h>
+@class iPhoneView;
+
@interface iOS7AppDelegate : NSObject<UIApplicationDelegate>
+
++ (iOS7AppDelegate *)iOS7AppDelegate;
++ (iPhoneView *)iPhoneView;
+
@end
diff --git a/backends/platform/ios7/iOS7AppDelegate.mm b/backends/platform/ios7/iOS7AppDelegate.mm
index 784566228c..0f645e5055 100644
--- a/backends/platform/ios7/iOS7AppDelegate.mm
+++ b/backends/platform/ios7/iOS7AppDelegate.mm
@@ -76,6 +76,16 @@
[_view deviceOrientationChanged:screenOrientation];
}
++ (iOS7AppDelegate *)iOS7AppDelegate {
+ UIApplication *app = [UIApplication sharedApplication];
+ return (iOS7AppDelegate *) app.delegate;
+}
+
++ (iPhoneView *)iPhoneView {
+ iOS7AppDelegate *appDelegate = [self iOS7AppDelegate];
+ return appDelegate->_view;
+}
+
@end
const char *iOS7_getDocumentsDir() {
diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm
index 4835ef5638..e2ac189baa 100644
--- a/backends/platform/ios7/ios7_osys_video.mm
+++ b/backends/platform/ios7/ios7_osys_video.mm
@@ -27,9 +27,10 @@
#include "ios7_video.h"
#include "graphics/conversion.h"
+#import "iOS7AppDelegate.h"
void OSystem_iOS7::initVideoContext() {
- _videoContext = [g_iPhoneViewInstance getVideoContext];
+ _videoContext = [[iOS7AppDelegate iPhoneView] getVideoContext];
}
const OSystem::GraphicsMode *OSystem_iOS7::getSupportedGraphicsModes() const {
@@ -82,7 +83,7 @@ void OSystem_iOS7::initSize(uint width, uint height, const Graphics::PixelFormat
// Create the screen texture right here. We need to do this here, since
// when a game requests hi-color mode, we actually set the framebuffer
// to the texture buffer to avoid an additional copy step.
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(createScreenTexture) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] 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.
@@ -119,13 +120,13 @@ void OSystem_iOS7::beginGFXTransaction() {
OSystem::TransactionError OSystem_iOS7::endGFXTransaction() {
_screenChangeCount++;
updateOutputSurface();
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES];
return _gfxTransactionError;
}
void OSystem_iOS7::updateOutputSurface() {
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES];
}
int16 OSystem_iOS7::getHeight() {
@@ -285,7 +286,7 @@ void OSystem_iOS7::unlockScreen() {
void OSystem_iOS7::setShakePos(int shakeOffset) {
//printf("setShakePos(%i)\n", shakeOffset);
_videoContext->shakeOffsetY = shakeOffset;
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES];
// HACK: We use this to force a redraw.
_mouseDirty = true;
}
@@ -295,8 +296,8 @@ void OSystem_iOS7::showOverlay() {
_videoContext->overlayVisible = true;
dirtyFullOverlayScreen();
updateScreen();
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES];
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
}
void OSystem_iOS7::hideOverlay() {
@@ -304,8 +305,8 @@ void OSystem_iOS7::hideOverlay() {
_videoContext->overlayVisible = false;
_dirtyOverlayRects.clear();
dirtyFullScreen();
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES];
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
}
void OSystem_iOS7::clearOverlay() {
@@ -386,7 +387,7 @@ void OSystem_iOS7::warpMouse(int x, int y) {
//printf("warpMouse(%d, %d)\n", x, y);
_videoContext->mouseX = x;
_videoContext->mouseY = y;
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(notifyMouseMove) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(notifyMouseMove) withObject:nil waitUntilDone: YES];
_mouseDirty = true;
}
@@ -499,5 +500,5 @@ void OSystem_iOS7::updateMouseTexture() {
}
}
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES];
}
diff --git a/backends/platform/ios7/ios7_video.h b/backends/platform/ios7/ios7_video.h
index 63a570d19d..09a84b5498 100644
--- a/backends/platform/ios7/ios7_video.h
+++ b/backends/platform/ios7/ios7_video.h
@@ -104,6 +104,4 @@
@end
-extern iPhoneView *g_iPhoneViewInstance;
-
#endif
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index dbb750362c..1a2ae5ee91 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -27,8 +27,8 @@
#include "graphics/colormasks.h"
#include "common/system.h"
+#import "iOS7AppDelegate.h"
-iPhoneView *g_iPhoneViewInstance = nil;
static int g_fullWidth;
static int g_fullHeight;
@@ -62,12 +62,12 @@ void iOS7_updateScreen() {
//printf("Mouse: (%i, %i)\n", mouseX, mouseY);
if (!g_needsScreenUpdate) {
g_needsScreenUpdate = 1;
- [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO];
+ [[iOS7AppDelegate iPhoneView] performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO];
}
}
bool iOS7_fetchEvent(InternalEvent *event) {
- return [g_iPhoneViewInstance fetchEvent:event];
+ return [[iOS7AppDelegate iPhoneView] fetchEvent:event];
}
uint getSizeNextPOT(uint size) {
@@ -233,8 +233,6 @@ uint getSizeNextPOT(uint size) {
_contentScaleFactor = [self optimalScale];
[self setContentScaleFactor:_contentScaleFactor];
- g_iPhoneViewInstance = self;
-
_keyboardView = nil;
_screenTexture = 0;
_overlayTexture = 0;