diff options
| author | Johannes Schickel | 2012-02-24 01:44:17 +0100 | 
|---|---|---|
| committer | Johannes Schickel | 2012-02-24 01:44:17 +0100 | 
| commit | c3b52343dceaae253df9324a417a526f13c52333 (patch) | |
| tree | a38bdb49f16207f987b0258ee71411eb89486fb8 | |
| parent | 5c558660689e3fb6bad1fd979885a349bf77262c (diff) | |
| download | scummvm-rg350-c3b52343dceaae253df9324a417a526f13c52333.tar.gz scummvm-rg350-c3b52343dceaae253df9324a417a526f13c52333.tar.bz2 scummvm-rg350-c3b52343dceaae253df9324a417a526f13c52333.zip | |
IPHONE: Only update on screen mouse coordinates when it's needed.
| -rw-r--r-- | backends/platform/iphone/iphone_video.h | 2 | ||||
| -rw-r--r-- | backends/platform/iphone/iphone_video.mm | 41 | ||||
| -rw-r--r-- | backends/platform/iphone/osys_video.mm | 2 | 
3 files changed, 24 insertions, 21 deletions
| diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 135f4e64c3..168f9a4244 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 da954199ea..3aa76681ab 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 0efeb78aef..31db4c70e7 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;  } | 
