[Scummvm-cvs-logs] scummvm master -> 8edcedf3b65965df6ade9899a7a07855cf51195c
lordhoto
lordhoto at gmail.com
Thu Feb 23 21:36:59 CET 2012
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
97feac5342 IPHONE: Add a constructor to VideoContext.
2ab5958c93 IPHONE: Move screen and overlay texture buffer to VideoContext.
8edcedf3b6 IPHONE: Directly use the overlay's texture buffer instead of another intermediate buffer.
Commit: 97feac5342420653bb1f4a5fbca68a5aae6b09a8
https://github.com/scummvm/scummvm/commit/97feac5342420653bb1f4a5fbca68a5aae6b09a8
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-23T11:59:26-08:00
Commit Message:
IPHONE: Add a constructor to VideoContext.
Changed paths:
backends/platform/iphone/iphone_common.h
backends/platform/iphone/iphone_video.mm
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index 18821e6..f5111fb 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -56,6 +56,12 @@ enum GraphicsModes {
};
struct VideoContext {
+ VideoContext() : screenWidth(), screenHeight(), overlayVisible(false),
+ overlayWidth(), overlayHeight(), mouseX(), mouseY(),
+ mouseHotspotX(), mouseHotspotY(), mouseWidth(), mouseHeight(),
+ mouseIsVisible(), graphicsMode(kGraphicsModeLinear), shakeOffsetY() {
+ }
+
// Game screen state
uint screenWidth, screenHeight;
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index 387ed72..4442552 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -225,10 +225,6 @@ const char *iPhone_getDocumentsDir() {
_overlayTexture = 0;
_mouseCursorTexture = 0;
- memset(&_videoContext, 0, sizeof(_videoContext));
- _videoContext.graphicsMode = kGraphicsModeLinear;
- _videoContext.overlayVisible = false;
-
_gameScreenVertCoords[0] = _gameScreenVertCoords[1] =
_gameScreenVertCoords[2] = _gameScreenVertCoords[3] =
_gameScreenVertCoords[4] = _gameScreenVertCoords[5] =
Commit: 2ab5958c93c19a0ea23b76c2360ca8ef4d905b94
https://github.com/scummvm/scummvm/commit/2ab5958c93c19a0ea23b76c2360ca8ef4d905b94
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-23T12:20:24-08:00
Commit Message:
IPHONE: Move screen and overlay texture buffer to VideoContext.
Changed paths:
backends/platform/iphone/iphone_common.h
backends/platform/iphone/iphone_main.mm
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 f5111fb..6e97d9d 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -23,6 +23,8 @@
#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H
#define BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H
+#include "graphics/surface.h"
+
enum InputEvent {
kInputMouseDown,
kInputMouseUp,
@@ -64,10 +66,12 @@ struct VideoContext {
// Game screen state
uint screenWidth, screenHeight;
+ Graphics::Surface screenTexture;
// Overlay state
bool overlayVisible;
uint overlayWidth, overlayHeight;
+ Graphics::Surface overlayTexture;
// Mouse cursor state
uint mouseX, mouseY;
@@ -82,8 +86,6 @@ struct VideoContext {
// On the ObjC side
void iPhone_updateScreen();
-void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width);
-void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width);
bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY);
const char *iPhone_getDocumentsDir();
bool iPhone_isHighResDevice();
diff --git a/backends/platform/iphone/iphone_main.mm b/backends/platform/iphone/iphone_main.mm
index 1559ef8..20406e6 100644
--- a/backends/platform/iphone/iphone_main.mm
+++ b/backends/platform/iphone/iphone_main.mm
@@ -20,6 +20,9 @@
*
*/
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include <UIKit/UIKit.h>
#include <Foundation/NSThread.h>
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index 4442552..7ae5dd6 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -20,20 +20,18 @@
*
*/
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "iphone_video.h"
+#include "graphics/colormasks.h"
+
iPhoneView *g_iPhoneViewInstance = nil;
static int _fullWidth;
static int _fullHeight;
static CGRect _gameScreenRect;
-static char *_gameScreenTextureBuffer = 0;
-static int _gameScreenTextureWidth = 0;
-static int _gameScreenTextureHeight = 0;
-
-static char *_overlayTexBuffer = 0;
-static int _overlayTexWidth = 0;
-static int _overlayTexHeight = 0;
static CGRect _overlayRect;
static int _needsScreenUpdate = 0;
@@ -85,17 +83,6 @@ void iPhone_updateScreen() {
}
}
-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 * width + x1], (x2 - x1) * 2);
-}
-
-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 * width + x1], (x2 - x1) * 2);
-}
-
bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) {
id event = [g_iPhoneViewInstance getEvent];
if (event == nil) {
@@ -181,18 +168,16 @@ const char *iPhone_getDocumentsDir() {
_videoContext.overlayHeight = _renderBufferWidth;
_videoContext.overlayWidth = _renderBufferHeight;
- _overlayTexWidth = getSizeNextPOT(_videoContext.overlayHeight);
- _overlayTexHeight = getSizeNextPOT(_videoContext.overlayWidth);
+ uint overlayTextureWidth = getSizeNextPOT(_videoContext.overlayHeight);
+ uint overlayTextureHeight = getSizeNextPOT(_videoContext.overlayWidth);
// Since the overlay size won't change the whole run, we can
// precalculate the texture coordinates for the overlay texture here
// and just use it later on.
- _overlayTexCoords[2] = _overlayTexCoords[6] = _videoContext.overlayWidth / (GLfloat)_overlayTexWidth;
- _overlayTexCoords[5] = _overlayTexCoords[7] = _videoContext.overlayHeight / (GLfloat)_overlayTexHeight;
+ _overlayTexCoords[2] = _overlayTexCoords[6] = _videoContext.overlayWidth / (GLfloat)overlayTextureWidth;
+ _overlayTexCoords[5] = _overlayTexCoords[7] = _videoContext.overlayHeight / (GLfloat)overlayTextureHeight;
- int textureSize = _overlayTexWidth * _overlayTexHeight * 2;
- _overlayTexBuffer = (char *)malloc(textureSize);
- memset(_overlayTexBuffer, 0, textureSize);
+ _videoContext.overlayTexture.create(overlayTextureWidth, overlayTextureHeight, Graphics::createPixelFormat<5551>());
glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError();
@@ -258,8 +243,8 @@ const char *iPhone_getDocumentsDir() {
[_keyboardView dealloc];
}
- free(_gameScreenTextureBuffer);
- free(_overlayTexBuffer);
+ _videoContext.screenTexture.free();
+ _videoContext.overlayTexture.free();
}
- (void)drawRect:(CGRect)frame {
@@ -348,7 +333,7 @@ const char *iPhone_getDocumentsDir() {
// Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases
// due to the iPhone internals having to convert the whole texture back from its internal format when used.
// In the future we could use several tiled textures instead.
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _gameScreenTextureWidth, _gameScreenTextureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _gameScreenTextureBuffer); printOpenGLError();
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.pixels); printOpenGLError();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}
@@ -357,7 +342,7 @@ const char *iPhone_getDocumentsDir() {
glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError();
glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError();
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _overlayTexWidth, _overlayTexHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _overlayTexBuffer); printOpenGLError();
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.overlayTexture.w, _videoContext.overlayTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.overlayTexture.pixels); printOpenGLError();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}
@@ -473,17 +458,15 @@ const char *iPhone_getDocumentsDir() {
}
- (void)initSurface {
- _gameScreenTextureWidth = getSizeNextPOT(_videoContext.screenWidth);
- _gameScreenTextureHeight = getSizeNextPOT(_videoContext.screenHeight);
+ uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth);
+ uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight);
- _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)_gameScreenTextureWidth;
- _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)_gameScreenTextureHeight;
+ _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)screenTexWidth;
+ _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)screenTexHeight;
int screenWidth, screenHeight;
[self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight];
- //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _videoContext.screenWidth, _videoContext.screenHeight, _gameScreenTextureWidth, _gameScreenTextureHeight);
-
if (_screenTexture > 0) {
glDeleteTextures(1, &_screenTexture); printOpenGLError();
}
@@ -498,10 +481,7 @@ const char *iPhone_getDocumentsDir() {
glGenTextures(1, &_overlayTexture); printOpenGLError();
[self setFilterModeForTexture:_overlayTexture];
- free(_gameScreenTextureBuffer);
- int textureSize = _gameScreenTextureWidth * _gameScreenTextureHeight * 2;
- _gameScreenTextureBuffer = (char *)malloc(textureSize);
- memset(_gameScreenTextureBuffer, 0, textureSize);
+ _videoContext.screenTexture.create(screenTexWidth, screenTexHeight, Graphics::createPixelFormat<565>());
glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError();
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index a40fcae..45f6237 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -228,11 +228,23 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
}
void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) {
- iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom, _videoContext->overlayWidth);
+ const int x1 = dirtyRect.left;
+ const int y1 = dirtyRect.top;
+ const int x2 = dirtyRect.right;
+ const int y2 = dirtyRect.bottom;
+
+ for (int y = y1; y < y2; ++y)
+ memcpy(_videoContext->overlayTexture.getBasePtr(x1, y), &_overlayBuffer[y * _videoContext->overlayWidth + x1], (x2 - x1) * 2);
}
void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) {
- iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom, _videoContext->screenWidth);
+ const int x1 = updatedRect.left;
+ const int y1 = updatedRect.top;
+ const int x2 = updatedRect.right;
+ const int y2 = updatedRect.bottom;
+
+ for (int y = y1; y < y2; ++y)
+ memcpy(_videoContext->screenTexture.getBasePtr(x1, y), &_gameScreenConverted[y * _videoContext->screenWidth + x1], (x2 - x1) * 2);
}
Graphics::Surface *OSystem_IPHONE::lockScreen() {
Commit: 8edcedf3b65965df6ade9899a7a07855cf51195c
https://github.com/scummvm/scummvm/commit/8edcedf3b65965df6ade9899a7a07855cf51195c
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-23T12:34:12-08:00
Commit Message:
IPHONE: Directly use the overlay's texture buffer instead of another intermediate buffer.
Changed paths:
backends/platform/iphone/osys_main.cpp
backends/platform/iphone/osys_main.h
backends/platform/iphone/osys_video.mm
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 368434c..e2de6ca 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -61,7 +61,7 @@ OSystem_IPHONE::OSystem_IPHONE() :
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0),
- _overlayBuffer(0), _mouseCursorPaletteEnabled(false) {
+ _mouseCursorPaletteEnabled(false) {
_queuedInputEvent.type = Common::EVENT_INVALID;
_touchpadModeEnabled = !iPhone_isHighResDevice();
_fsFactory = new POSIXFilesystemFactory();
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index 39395ac..8b1365a 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -65,7 +65,6 @@ protected:
Graphics::Surface _framebuffer;
byte *_gameScreenRaw;
- OverlayColor *_overlayBuffer;
uint16 *_gameScreenConverted;
@@ -191,7 +190,6 @@ protected:
void dirtyFullOverlayScreen();
void suspendLoop();
void drawDirtyRect(const Common::Rect &dirtyRect);
- void drawDirtyOverlayRect(const Common::Rect &dirtyRect);
void updateHardwareSurfaceForRect(const Common::Rect &updatedRect);
void updateMouseTexture();
static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index 45f6237..8fc9535 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -68,10 +68,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
_gameScreenRaw = (byte *)malloc(width * height);
bzero(_gameScreenRaw, width * height);
- //free(_overlayBuffer);
-
int fullSize = _videoContext->screenWidth * _videoContext->screenHeight * sizeof(OverlayColor);
- //_overlayBuffer = (OverlayColor *)malloc(fullSize);
free(_gameScreenConverted);
@@ -80,11 +77,6 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
updateOutputSurface();
- if (_overlayBuffer == NULL) {
- printf("Overlay: (%u x %u)\n", _videoContext->overlayWidth, _videoContext->overlayHeight);
- _overlayBuffer = new OverlayColor[_videoContext->overlayHeight * _videoContext->overlayWidth];
- }
-
clearOverlay();
_fullScreenIsDirty = false;
@@ -203,12 +195,14 @@ void OSystem_IPHONE::internUpdateScreen() {
}
if (_videoContext->overlayVisible) {
- while (_dirtyOverlayRects.size()) {
+ // TODO: Implement dirty rect code
+ _dirtyOverlayRects.clear();
+ /*while (_dirtyOverlayRects.size()) {
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);
- }
+ }*/
}
}
@@ -227,16 +221,6 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
}
}
-void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) {
- const int x1 = dirtyRect.left;
- const int y1 = dirtyRect.top;
- const int x2 = dirtyRect.right;
- const int y2 = dirtyRect.bottom;
-
- for (int y = y1; y < y2; ++y)
- memcpy(_videoContext->overlayTexture.getBasePtr(x1, y), &_overlayBuffer[y * _videoContext->overlayWidth + x1], (x2 - x1) * 2);
-}
-
void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) {
const int x1 = updatedRect.left;
const int y1 = updatedRect.top;
@@ -290,18 +274,18 @@ void OSystem_IPHONE::hideOverlay() {
void OSystem_IPHONE::clearOverlay() {
//printf("clearOverlay()\n");
- bzero(_overlayBuffer, _videoContext->overlayWidth * _videoContext->overlayHeight * sizeof(OverlayColor));
+ bzero(_videoContext->overlayTexture.getBasePtr(0, 0), _videoContext->overlayTexture.h * _videoContext->overlayTexture.pitch);
dirtyFullOverlayScreen();
}
void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
//printf("grabOverlay()\n");
int h = _videoContext->overlayHeight;
- OverlayColor *src = _overlayBuffer;
+ const byte *src = (const byte *)_videoContext->overlayTexture.getBasePtr(0, 0);
do {
memcpy(buf, src, _videoContext->overlayWidth * sizeof(OverlayColor));
- src += _videoContext->overlayWidth;
+ src += _videoContext->overlayTexture.pitch;
buf += pitch;
} while (--h);
}
@@ -335,16 +319,12 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x
_dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h));
}
- OverlayColor *dst = _overlayBuffer + (y * _videoContext->overlayWidth + x);
- if ((int)_videoContext->overlayWidth == pitch && pitch == w)
- memcpy(dst, buf, h * w * sizeof(OverlayColor));
- else {
- do {
- memcpy(dst, buf, w * sizeof(OverlayColor));
- buf += pitch;
- dst += _videoContext->overlayWidth;
- } while (--h);
- }
+ byte *dst = (byte *)_videoContext->overlayTexture.getBasePtr(x, y);
+ do {
+ memcpy(dst, buf, w * sizeof(OverlayColor));
+ buf += pitch;
+ dst += _videoContext->overlayTexture.pitch;
+ } while (--h);
}
int16 OSystem_IPHONE::getOverlayHeight() {
More information about the Scummvm-git-logs
mailing list