[Scummvm-cvs-logs] scummvm master -> c3b52343dceaae253df9324a417a526f13c52333

lordhoto lordhoto at gmail.com
Fri Feb 24 01:45:22 CET 2012


This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5863f6a556 IPHONE: Add a mouse texture buffer surface to VideoContext.
d93e1558fc IPHONE: Move some global variables to iPhoneView.
d691ef2260 IPHONE: Clean up mouse texture coordinate handling.
5c55866068 IPHONE: Cleanup mouse cursor handling slightly.
c3b52343dc IPHONE: Only update on screen mouse coordinates when it's needed.


Commit: 5863f6a5565b22f6e92c1e1254d8e12651d24de4
    https://github.com/scummvm/scummvm/commit/5863f6a5565b22f6e92c1e1254d8e12651d24de4
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-23T15:56:46-08:00

Commit Message:
IPHONE: Add a mouse texture buffer surface to VideoContext.

Changed paths:
    backends/platform/iphone/iphone_common.h
    backends/platform/iphone/iphone_video.mm
    backends/platform/iphone/osys_video.mm



diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index 6e97d9d..4dd9407 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -78,6 +78,7 @@ struct VideoContext {
 	int mouseHotspotX, mouseHotspotY;
 	uint mouseWidth, mouseHeight;
 	bool mouseIsVisible;
+	Graphics::Surface mouseTexture;
 
 	// Misc state
 	GraphicsModes graphicsMode;
@@ -89,7 +90,6 @@ void iPhone_updateScreen();
 bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY);
 const char *iPhone_getDocumentsDir();
 bool iPhone_isHighResDevice();
-void iPhone_setMouseCursor(unsigned short *buffer);
 
 uint getSizeNextPOT(uint size);
 
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index cdd8d68..d7511c5 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -39,8 +39,6 @@ static int _needsScreenUpdate = 0;
 static UITouch *_firstTouch = NULL;
 static UITouch *_secondTouch = NULL;
 
-static unsigned short *_mouseCursor = NULL;
-
 static GLint _renderBufferWidth;
 static GLint _renderBufferHeight;
 
@@ -66,11 +64,6 @@ int printOglError(const char *file, int line) {
 	return retCode;
 }
 
-void iPhone_setMouseCursor(unsigned short *buffer) {
-	_mouseCursor = buffer;
-	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES];
-}
-
 bool iPhone_isHighResDevice() {
 	return _fullHeight > 480;
 }
@@ -245,6 +238,7 @@ const char *iPhone_getDocumentsDir() {
 
 	_videoContext.screenTexture.free();
 	_videoContext.overlayTexture.free();
+	_videoContext.mouseTexture.free();
 }
 
 - (void)drawRect:(CGRect)frame {
@@ -318,10 +312,7 @@ const char *iPhone_getDocumentsDir() {
 	}
 
 	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
-	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_videoContext.mouseWidth), getSizeNextPOT(_videoContext.mouseHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError();
-
-	free(_mouseCursor);
-	_mouseCursor = NULL;
+	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.pixels); printOpenGLError();
 }
 
 - (void)updateMainSurface {
@@ -398,8 +389,8 @@ const char *iPhone_getDocumentsDir() {
 
 	//printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight);
 
-	float texWidth = _videoContext.mouseWidth / (float)getSizeNextPOT(_videoContext.mouseWidth);
-	float texHeight = _videoContext.mouseHeight / (float)getSizeNextPOT(_videoContext.mouseHeight);
+	float texWidth = _videoContext.mouseWidth / (float)_videoContext.mouseTexture.w;
+	float texHeight = _videoContext.mouseHeight / (float)_videoContext.mouseTexture.h;
 
 	const GLfloat texCoords[] = {
 		// Top left
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index 7e2b1ee..6fa800a 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -392,11 +392,12 @@ 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 bufferSize = texWidth * texHeight * sizeof(int16);
-	uint16 *mouseBuf = (uint16 *)malloc(bufferSize);
-	memset(mouseBuf, 0, bufferSize);
+	uint texWidth = getSizeNextPOT(_videoContext->mouseWidth);
+	uint texHeight = getSizeNextPOT(_videoContext->mouseHeight);
+
+	Graphics::Surface &mouseTexture = _videoContext->mouseTexture;
+	if (mouseTexture.w != texWidth || mouseTexture.h != texHeight)
+		mouseTexture.create(texWidth, texHeight, Graphics::createPixelFormat<5551>());
 
 	const uint16 *palette;
 	if (_mouseCursorPaletteEnabled)
@@ -404,6 +405,7 @@ void OSystem_IPHONE::updateMouseTexture() {
 	else
 		palette = _gamePaletteRGBA5551;
 
+	uint16 *mouseBuf = (uint16 *)mouseTexture.getBasePtr(0, 0);
 	for (uint x = 0; x < _videoContext->mouseWidth; ++x) {
 		for (uint y = 0; y < _videoContext->mouseHeight; ++y) {
 			const byte color = _mouseBuf[y * _videoContext->mouseWidth + x];
@@ -414,5 +416,5 @@ void OSystem_IPHONE::updateMouseTexture() {
 		}
 	}
 
-	iPhone_setMouseCursor(mouseBuf);
+	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES];
 }


Commit: d93e1558fca1a13d71e588189c309b4daec8d150
    https://github.com/scummvm/scummvm/commit/d93e1558fca1a13d71e588189c309b4daec8d150
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-23T16:02:29-08:00

Commit Message:
IPHONE: Move some global variables to iPhoneView.

Changed paths:
    backends/platform/iphone/iphone_video.h
    backends/platform/iphone/iphone_video.mm



diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h
index 1d9d7e7..4d6d906 100644
--- a/backends/platform/iphone/iphone_video.h
+++ b/backends/platform/iphone/iphone_video.h
@@ -49,11 +49,18 @@
 
 	UIDeviceOrientation _orientation;
 
+	GLint _renderBufferWidth;
+	GLint _renderBufferHeight;
+
 	GLfloat _gameScreenVertCoords[4 * 2];
 	GLfloat _gameScreenTexCoords[4 * 2];
+	CGRect _gameScreenRect;
 
 	GLfloat _overlayVertCoords[4 * 2];
 	GLfloat _overlayTexCoords[4 * 2];
+	CGRect _overlayRect;
+
+	int _scaledShakeOffsetY;
 }
 
 - (id)initWithFrame:(struct CGRect)frame;
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index d7511c5..621238d 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -30,20 +30,12 @@
 iPhoneView *g_iPhoneViewInstance = nil;
 static int _fullWidth;
 static int _fullHeight;
-static CGRect _gameScreenRect;
-
-static CGRect _overlayRect;
 
 static int _needsScreenUpdate = 0;
 
 static UITouch *_firstTouch = NULL;
 static UITouch *_secondTouch = NULL;
 
-static GLint _renderBufferWidth;
-static GLint _renderBufferHeight;
-
-static int _scaledShakeOffsetY;
-
 #if 0
 static long lastTick = 0;
 static int frames = 0;
@@ -203,6 +195,8 @@ const char *iPhone_getDocumentsDir() {
 	_overlayTexture = 0;
 	_mouseCursorTexture = 0;
 
+	_scaledShakeOffsetY = 0;
+
 	_gameScreenVertCoords[0] = _gameScreenVertCoords[1] =
 	    _gameScreenVertCoords[2] = _gameScreenVertCoords[3] =
 	    _gameScreenVertCoords[4] = _gameScreenVertCoords[5] =


Commit: d691ef2260fb76ac7bdba60e8383db5c27e842b6
    https://github.com/scummvm/scummvm/commit/d691ef2260fb76ac7bdba60e8383db5c27e842b6
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-23T16:13:44-08:00

Commit Message:
IPHONE: Clean up mouse texture coordinate handling.

Changed paths:
    backends/platform/iphone/iphone_video.h
    backends/platform/iphone/iphone_video.mm



diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h
index 4d6d906..bd32a58 100644
--- a/backends/platform/iphone/iphone_video.h
+++ b/backends/platform/iphone/iphone_video.h
@@ -60,6 +60,8 @@
 	GLfloat _overlayTexCoords[4 * 2];
 	CGRect _overlayRect;
 
+	GLfloat _mouseTexCoords[4 * 2];
+
 	int _scaledShakeOffsetY;
 }
 
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index 621238d..477254f 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -217,6 +217,11 @@ const char *iPhone_getDocumentsDir() {
 	    _overlayTexCoords[4] = _overlayTexCoords[5] =
 	    _overlayTexCoords[6] = _overlayTexCoords[7] = 0;
 
+	_mouseTexCoords[0] = _mouseTexCoords[1] =
+	    _mouseTexCoords[2] = _mouseTexCoords[3] =
+	    _mouseTexCoords[4] = _mouseTexCoords[5] =
+	    _mouseTexCoords[6] = _mouseTexCoords[7] = 0;
+
 	// Initialize the OpenGL ES context
 	[self createContext];
 
@@ -305,6 +310,9 @@ const char *iPhone_getDocumentsDir() {
 		[self setFilterModeForTexture:_mouseCursorTexture];
 	}
 
+	_mouseTexCoords[2] = _mouseTexCoords[6] = _videoContext.mouseWidth / (GLfloat)_videoContext.mouseTexture.w;
+	_mouseTexCoords[5] = _mouseTexCoords[7] = _videoContext.mouseHeight / (GLfloat)_videoContext.mouseTexture.h;
+
 	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
 	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.pixels); printOpenGLError();
 }
@@ -383,22 +391,8 @@ const char *iPhone_getDocumentsDir() {
 
 	//printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight);
 
-	float texWidth = _videoContext.mouseWidth / (float)_videoContext.mouseTexture.w;
-	float texHeight = _videoContext.mouseHeight / (float)_videoContext.mouseTexture.h;
-
-	const GLfloat texCoords[] = {
-		// Top left
-		0       , 0,
-		// Top right
-		texWidth, 0,
-		// Bottom left
-		0       , texHeight,
-		// Bottom right
-		texWidth, texHeight
-	};
-
 	glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError();
-	glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError();
+	glTexCoordPointer(2, GL_FLOAT, 0, _mouseTexCoords); printOpenGLError();
 
 	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
 	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();


Commit: 5c558660689e3fb6bad1fd979885a349bf77262c
    https://github.com/scummvm/scummvm/commit/5c558660689e3fb6bad1fd979885a349bf77262c
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-23T16:33:37-08:00

Commit Message:
IPHONE: Cleanup mouse cursor handling slightly.

Now the scaling etc. will be precalculated instead of being done on every
frame.

Changed paths:
    backends/platform/iphone/iphone_video.h
    backends/platform/iphone/iphone_video.mm
    backends/platform/iphone/osys_video.mm



diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h
index bd32a58..135f4e6 100644
--- a/backends/platform/iphone/iphone_video.h
+++ b/backends/platform/iphone/iphone_video.h
@@ -61,6 +61,9 @@
 	CGRect _overlayRect;
 
 	GLfloat _mouseTexCoords[4 * 2];
+	GLint _mouseHotspotX, _mouseHotspotY;
+	GLint _mouseWidth, _mouseHeight;
+	GLfloat _mouseScaleX, _mouseScaleY;
 
 	int _scaledShakeOffsetY;
 }
@@ -82,6 +85,7 @@
 - (void)updateMouseSurface;
 - (void)clearColorBuffer;
 
+- (void)updateMouseCursorScaling;
 - (void)updateMouseCursor;
 
 - (id)getEvent;
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index 477254f..da95419 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -304,12 +304,50 @@ const char *iPhone_getDocumentsDir() {
 
 }
 
+- (void)updateMouseCursorScaling {
+	CGRect *rect;
+	int maxWidth, maxHeight;
+
+	if (!_videoContext.overlayVisible) {
+		rect = &_gameScreenRect;
+		maxWidth = _videoContext.screenWidth;
+		maxHeight = _videoContext.screenHeight;
+	} else {
+		rect = &_overlayRect;
+		maxWidth = _videoContext.overlayWidth;
+		maxHeight = _videoContext.overlayHeight;
+	}
+
+	if (!maxWidth || !maxHeight) {
+		printf("WARNING: updateMouseCursorScaling called when screen was not ready (%d)!\n", _videoContext.overlayVisible);
+		return;
+	}
+
+	_mouseScaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth;
+	_mouseScaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight;
+
+	_mouseWidth = (GLint)(_videoContext.mouseWidth * _mouseScaleX);
+	_mouseHeight = (GLint)(_videoContext.mouseHeight * _mouseScaleY);
+
+	_mouseHotspotX = (GLint)(_videoContext.mouseHotspotX * _mouseScaleX);
+	_mouseHotspotY = (GLint)(_videoContext.mouseHotspotY * _mouseScaleY);
+
+	// We subtract the screen offset to the hotspot here to simplify the
+	// screen offset handling in the mouse code. Note the subtraction here
+	// makes sure that the offset actually gets added to the mouse position,
+	// since the hotspot offset is substracted from the position.
+	_mouseHotspotX -= (GLint)CGRectGetMinX(*rect);
+	_mouseHotspotY -= (GLint)CGRectGetMinY(*rect);
+}
+
 - (void)updateMouseCursor {
 	if (_mouseCursorTexture == 0) {
 		glGenTextures(1, &_mouseCursorTexture); printOpenGLError();
 		[self setFilterModeForTexture:_mouseCursorTexture];
 	}
 
+	[self updateMouseCursorScaling];
+
 	_mouseTexCoords[2] = _mouseTexCoords[6] = _videoContext.mouseWidth / (GLfloat)_videoContext.mouseTexture.w;
 	_mouseTexCoords[5] = _mouseTexCoords[7] = _videoContext.mouseHeight / (GLfloat)_videoContext.mouseTexture.h;
 
@@ -340,53 +378,21 @@ const char *iPhone_getDocumentsDir() {
 }
 
 - (void)updateMouseSurface {
-	int width = _videoContext.mouseWidth;
-	int height = _videoContext.mouseHeight;
-
 	int mouseX = _videoContext.mouseX;
 	int mouseY = _videoContext.mouseY;
 
-	int hotspotX = _videoContext.mouseHotspotX;
-	int hotspotY = _videoContext.mouseHotspotY;
-
-	CGRect *rect;
-	int maxWidth, maxHeight;
-
-	if (!_videoContext.overlayVisible) {
-		rect = &_gameScreenRect;
-		maxWidth = _videoContext.screenWidth;
-		maxHeight = _videoContext.screenHeight;
-	} else {
-		rect = &_overlayRect;
-		maxWidth = _videoContext.overlayWidth;
-		maxHeight = _videoContext.overlayHeight;
-	}
-
-	const GLfloat scaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth;
-	const GLfloat scaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight;
-
-	mouseX = (int)(mouseX * scaleX);
-	mouseY = (int)(mouseY * scaleY);
-	hotspotX = (int)(hotspotX * scaleX);
-	hotspotY = (int)(hotspotY * scaleY);
-	width = (int)(width * scaleX);
-	height = (int)(height * scaleY);
-
-	mouseX -= hotspotX;
-	mouseY -= hotspotY;
-
-	mouseX += (int)CGRectGetMinX(*rect);
-	mouseY += (int)CGRectGetMinY(*rect);
+	mouseX = (int)(mouseX * _mouseScaleX) - _mouseHotspotX;
+	mouseY = (int)(mouseY * _mouseScaleY) - _mouseHotspotY;
 
 	GLfloat vertices[] = {
 		// Top left
-		mouseX        , mouseY,
+		mouseX              , mouseY,
 		// Top right
-		mouseX + width, mouseY,
+		mouseX + _mouseWidth, mouseY,
 		// Bottom left
-		mouseX        , mouseY + height,
+		mouseX              , mouseY + _mouseHeight,
 		// Bottom right
-		mouseX + width, mouseY + height
+		mouseX + _mouseWidth, mouseY + _mouseHeight
 	};
 
 	//printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight);
@@ -531,6 +537,7 @@ const char *iPhone_getDocumentsDir() {
 	_overlayVertCoords[5] = _overlayVertCoords[7] = CGRectGetMaxY(_overlayRect);
 
 	[self setViewTransformation];
+	[self updateMouseCursorScaling];
 }
 
 - (void)setViewTransformation {
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index 6fa800a..0efeb78 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -246,6 +246,7 @@ void OSystem_IPHONE::showOverlay() {
 	_videoContext->overlayVisible = true;
 	dirtyFullOverlayScreen();
 	updateScreen();
+	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES];
 	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES];
 }
 
@@ -254,6 +255,7 @@ void OSystem_IPHONE::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];
 }
 


Commit: c3b52343dceaae253df9324a417a526f13c52333
    https://github.com/scummvm/scummvm/commit/c3b52343dceaae253df9324a417a526f13c52333
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-23T16:44:17-08:00

Commit Message:
IPHONE: Only update on screen mouse coordinates when it's needed.

Changed paths:
    backends/platform/iphone/iphone_video.h
    backends/platform/iphone/iphone_video.mm
    backends/platform/iphone/osys_video.mm



diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h
index 135f4e6..168f9a4 100644
--- a/backends/platform/iphone/iphone_video.h
+++ b/backends/platform/iphone/iphone_video.h
@@ -60,6 +60,7 @@
 	GLfloat _overlayTexCoords[4 * 2];
 	CGRect _overlayRect;
 
+	GLfloat _mouseVertCoords[4 * 2];
 	GLfloat _mouseTexCoords[4 * 2];
 	GLint _mouseHotspotX, _mouseHotspotY;
 	GLint _mouseWidth, _mouseHeight;
@@ -85,6 +86,7 @@
 - (void)updateMouseSurface;
 - (void)clearColorBuffer;
 
+- (void)notifyMouseMove;
 - (void)updateMouseCursorScaling;
 - (void)updateMouseCursor;
 
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index da95419..3aa7668 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -217,6 +217,11 @@ const char *iPhone_getDocumentsDir() {
 	    _overlayTexCoords[4] = _overlayTexCoords[5] =
 	    _overlayTexCoords[6] = _overlayTexCoords[7] = 0;
 
+	_mouseVertCoords[0] = _mouseVertCoords[1] =
+	    _mouseVertCoords[2] = _mouseVertCoords[3] =
+	    _mouseVertCoords[4] = _mouseVertCoords[5] =
+	    _mouseVertCoords[6] = _mouseVertCoords[7] = 0;
+
 	_mouseTexCoords[0] = _mouseTexCoords[1] =
 	    _mouseTexCoords[2] = _mouseTexCoords[3] =
 	    _mouseTexCoords[4] = _mouseTexCoords[5] =
@@ -304,6 +309,16 @@ const char *iPhone_getDocumentsDir() {
 
 }
 
+- (void)notifyMouseMove {
+	const GLint mouseX = (GLint)(_videoContext.mouseX * _mouseScaleX) - _mouseHotspotX;
+	const GLint mouseY = (GLint)(_videoContext.mouseY * _mouseScaleY) - _mouseHotspotY;
+
+	_mouseVertCoords[0] = _mouseVertCoords[4] = mouseX;
+	_mouseVertCoords[1] = _mouseVertCoords[3] = mouseY;
+	_mouseVertCoords[2] = _mouseVertCoords[6] = mouseX + _mouseWidth;
+	_mouseVertCoords[5] = _mouseVertCoords[7] = mouseY + _mouseHeight;
+}
+
 - (void)updateMouseCursorScaling {
 	CGRect *rect;
 	int maxWidth, maxHeight;
@@ -338,6 +353,11 @@ const char *iPhone_getDocumentsDir() {
 	// since the hotspot offset is substracted from the position.
 	_mouseHotspotX -= (GLint)CGRectGetMinX(*rect);
 	_mouseHotspotY -= (GLint)CGRectGetMinY(*rect);
+
+	// FIXME: For now we also adapt the mouse position here. In reality we
+	// would be better off to also adjust the event position when switching
+	// from overlay to game screen or vica versa.
+	[self notifyMouseMove];
 }
 
 - (void)updateMouseCursor {
@@ -378,26 +398,7 @@ const char *iPhone_getDocumentsDir() {
 }
 
 - (void)updateMouseSurface {
-	int mouseX = _videoContext.mouseX;
-	int mouseY = _videoContext.mouseY;
-
-	mouseX = (int)(mouseX * _mouseScaleX) - _mouseHotspotX;
-	mouseY = (int)(mouseY * _mouseScaleY) - _mouseHotspotY;
-
-	GLfloat vertices[] = {
-		// Top left
-		mouseX              , mouseY,
-		// Top right
-		mouseX + _mouseWidth, mouseY,
-		// Bottom left
-		mouseX              , mouseY + _mouseHeight,
-		// Bottom right
-		mouseX + _mouseWidth, mouseY + _mouseHeight
-	};
-
-	//printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight);
-
-	glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError();
+	glVertexPointer(2, GL_FLOAT, 0, _mouseVertCoords); printOpenGLError();
 	glTexCoordPointer(2, GL_FLOAT, 0, _mouseTexCoords); printOpenGLError();
 
 	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index 0efeb78..31db4c7 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -332,9 +332,9 @@ bool OSystem_IPHONE::showMouse(bool visible) {
 
 void OSystem_IPHONE::warpMouse(int x, int y) {
 	//printf("warpMouse()\n");
-
 	_videoContext->mouseX = x;
 	_videoContext->mouseY = y;
+	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(notifyMouseMove) withObject:nil waitUntilDone: YES];
 	_mouseDirty = true;
 }
 






More information about the Scummvm-git-logs mailing list