aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/iphone/iphone_video.m44
-rw-r--r--backends/platform/iphone/osys_main.cpp2
-rw-r--r--backends/platform/iphone/osys_main.h3
-rw-r--r--backends/platform/iphone/osys_video.cpp102
4 files changed, 31 insertions, 120 deletions
diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m
index 4ef43f20df..df95b36310 100644
--- a/backends/platform/iphone/iphone_video.m
+++ b/backends/platform/iphone/iphone_video.m
@@ -108,8 +108,8 @@ void iPhone_updateScreen(int mouseX, int mouseY) {
//_mouseX = _overlayHeight - mouseX;
//_mouseY = mouseY;
- _mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _overlayHeight;
- _mouseY = mouseY / (float)_overlayHeight * _overlayWidth;
+ _mouseX = mouseX;
+ _mouseY = mouseY;
if (!_needsScreenUpdate) {
_needsScreenUpdate = 1;
@@ -259,16 +259,14 @@ bool getLocalMouseCoords(CGPoint *point) {
}
_needsScreenUpdate = 0;
- if (_overlayIsEnabled) {
- glClear(GL_COLOR_BUFFER_BIT); printOpenGLError();
- }
+ glClear(GL_COLOR_BUFFER_BIT); printOpenGLError();
[self updateMainSurface];
- if (_overlayIsEnabled) {
+ if (_overlayIsEnabled)
[self updateOverlaySurface];
- [self updateMouseSurface];
- }
+
+ [self updateMouseSurface];
glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError();
[_context presentRenderbuffer:GL_RENDERBUFFER_OES];
@@ -350,14 +348,32 @@ bool getLocalMouseCoords(CGPoint *point) {
- (void)updateMouseSurface {
- int width = _mouseCursorWidth / (float)_backingWidth * _backingHeight;
- int height = _mouseCursorHeight / (float)_backingHeight * _backingWidth;
+ int width = _mouseCursorWidth;
+ int height = _mouseCursorHeight;
+
+ int mouseX = _mouseX;
+ int mouseY = _mouseY;
+
+ if (!_overlayIsEnabled) {
+ const GLint gameWidth = (_visibleHeight - 2 * _widthOffset);
+ const GLint gameHeight = (_visibleWidth - 2 * _heightOffset);
+
+ mouseX = (_width - mouseX) / (float)_width * gameHeight + _heightOffset;
+ mouseY = mouseY / (float)_height * gameWidth + _widthOffset;
+ width = width / (float)_width * gameHeight;
+ height = height / (float)_height * gameWidth;
+ } else {
+ mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _backingWidth;
+ mouseY = mouseY / (float)_overlayHeight * _backingHeight;
+ width = width / (float)_overlayWidth * _backingWidth;
+ height = height / (float)_overlayHeight * _backingHeight;
+ }
GLfloat vertices[] = {
- _mouseX, _mouseY,
- _mouseX + height, _mouseY,
- _mouseX, _mouseY + width,
- _mouseX + height, _mouseY + width
+ mouseX , mouseY,
+ mouseX + width, mouseY,
+ mouseX , mouseY + height,
+ mouseX + width, mouseY + height
};
//printf("Cursor: width %u height %u\n", _mouseCursorWidth, _mouseCursorHeight);
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index ba1604f435..5cf8913835 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -62,8 +62,6 @@ OSystem_IPHONE::OSystem_IPHONE() :
_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0),
_overlayHeight(0), _overlayWidth(0), _overlayBuffer(0) {
_queuedInputEvent.type = Common::EVENT_INVALID;
- _lastDrawnMouseRect = Common::Rect(0, 0, 0, 0);
-
_touchpadModeEnabled = !iPhone_isHighResDevice();
_fsFactory = new POSIXFilesystemFactory();
}
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index c63ba41319..dad2e9f676 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -91,7 +91,6 @@ protected:
long _lastMouseDown;
long _lastMouseTap;
long _queuedEventTime;
- Common::Rect _lastDrawnMouseRect;
Common::Event _queuedInputEvent;
bool _secondaryTapped;
long _lastSecondaryDown;
@@ -192,11 +191,9 @@ protected:
void internUpdateScreen();
void dirtyFullScreen();
void dirtyFullOverlayScreen();
- void clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h);
void suspendLoop();
void drawDirtyRect(const Common::Rect &dirtyRect);
void drawDirtyOverlayRect(const Common::Rect &dirtyRect);
- void drawMouseCursorOnRectUpdate(const Common::Rect &updatedRect, const Common::Rect &mouseRect);
void updateHardwareSurfaceForRect(const Common::Rect &updatedRect);
static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
static int timerHandler(int t);
diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp
index 3b14126234..ad434153ec 100644
--- a/backends/platform/iphone/osys_video.cpp
+++ b/backends/platform/iphone/osys_video.cpp
@@ -159,32 +159,6 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
}
}
-void OSystem_IPHONE::clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h) {
- if (x < 0) {
- w += x;
- x = 0;
- }
-
- if (y < 0) {
- h += y;
- y = 0;
- }
-
- if (w > _screenWidth - x)
- w = _screenWidth - x;
-
- if (h > _screenHeight - y)
- h = _screenHeight - y;
-
- if (w < 0) {
- w = 0;
- }
-
- if (h < 0) {
- h = 0;
- }
-}
-
void OSystem_IPHONE::updateScreen() {
//printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size());
@@ -192,6 +166,7 @@ void OSystem_IPHONE::updateScreen() {
return;
internUpdateScreen();
+ _mouseDirty = false;
_fullScreenIsDirty = false;
_fullScreenOverlayIsDirty = false;
@@ -199,40 +174,11 @@ void OSystem_IPHONE::updateScreen() {
}
void OSystem_IPHONE::internUpdateScreen() {
- int16 mouseX = _mouseX - _mouseHotspotX;
- int16 mouseY = _mouseY - _mouseHotspotY;
- int16 mouseWidth = _mouseWidth;
- int16 mouseHeight = _mouseHeight;
-
- clipRectToScreen(mouseX, mouseY, mouseWidth, mouseHeight);
-
- Common::Rect mouseRect(mouseX, mouseY, mouseX + mouseWidth, mouseY + mouseHeight);
-
- if (_mouseDirty) {
- if (!_fullScreenIsDirty) {
- _dirtyRects.push_back(_lastDrawnMouseRect);
- _dirtyRects.push_back(mouseRect);
- }
- if (!_fullScreenOverlayIsDirty && _overlayVisible) {
- _dirtyOverlayRects.push_back(_lastDrawnMouseRect);
- _dirtyOverlayRects.push_back(mouseRect);
- }
- _mouseDirty = false;
- _lastDrawnMouseRect = mouseRect;
- }
-
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);
-
- if (_overlayVisible)
- drawDirtyOverlayRect(dirtyRect);
- else
- drawMouseCursorOnRectUpdate(dirtyRect, mouseRect);
-
updateHardwareSurfaceForRect(dirtyRect);
}
@@ -241,10 +187,7 @@ void OSystem_IPHONE::internUpdateScreen() {
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);
- //drawMouseCursorOnRectUpdate(dirtyRect, mouseRect);
- //updateHardwareSurfaceForRect(dirtyRect);
}
}
}
@@ -278,49 +221,6 @@ void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) {
iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
}
-void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect &updatedRect, const Common::Rect &mouseRect) {
- //draw mouse on top
- if (_mouseVisible && (updatedRect.intersects(mouseRect))) {
- int srcX = 0;
- int srcY = 0;
- int left = _mouseX - _mouseHotspotX;
- if (left < 0) {
- srcX -= left;
- left = 0;
- }
- int top = _mouseY - _mouseHotspotY;
- if (top < 0) {
- srcY -= top;
- top = 0;
- }
-
- int bottom = top + _mouseHeight;
- if (bottom > _screenWidth)
- bottom = _screenWidth;
-
- int displayWidth = _mouseWidth;
- if (_mouseWidth + left > _screenWidth)
- displayWidth = _screenWidth - left;
-
- int displayHeight = _mouseHeight;
- if (_mouseHeight + top > _screenHeight)
- displayHeight = _screenHeight - top;
-
- byte *src = &_mouseBuf[srcY * _mouseWidth + srcX];
- uint16 *dst = &_fullscreen[top * _screenWidth + left];
- for (int y = displayHeight; y > srcY; y--) {
- for (int x = displayWidth; x > srcX; x--) {
- if (*src != _mouseKeyColor)
- *dst = _gamePalette[*src];
- dst++;
- src++;
- }
- dst += _screenWidth - displayWidth + srcX;
- src += _mouseWidth - displayWidth + srcX;
- }
- }
-}
-
void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) {
iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom);
}