[Scummvm-cvs-logs] scummvm master -> 8102e7e645db5103369799cd7aae390da099746f
lordhoto
lordhoto at gmail.com
Mon Feb 20 01:34:53 CET 2012
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
723a38c699 IPHONE: Rename screen related buffers a bit.
1b9c4f3845 IPHONE: Remove some dead code.
65cda4cd6b IPHONE: Fix some mismatching malloc/delete calls.
8102e7e645 IPHONE: Implement cursor palette support.
Commit: 723a38c699d2bd7a8e8967e231ae4360d5a77f1b
https://github.com/scummvm/scummvm/commit/723a38c699d2bd7a8e8967e231ae4360d5a77f1b
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-19T15:35:14-08:00
Commit Message:
IPHONE: Rename screen related buffers a bit.
Changed paths:
backends/platform/iphone/osys_main.cpp
backends/platform/iphone/osys_main.h
backends/platform/iphone/osys_video.cpp
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 5cf8913..8064fe4 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -53,8 +53,8 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL;
void *OSystem_IPHONE::s_soundParam = NULL;
OSystem_IPHONE::OSystem_IPHONE() :
- _mixer(NULL), _offscreen(NULL),
- _overlayVisible(false), _fullscreen(NULL),
+ _mixer(NULL), _gameScreenRaw(NULL),
+ _overlayVisible(false), _gameScreenConverted(NULL),
_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0),
_secondaryTapped(false), _lastSecondaryTap(0),
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
@@ -70,8 +70,8 @@ OSystem_IPHONE::~OSystem_IPHONE() {
AudioQueueDispose(s_AudioQueue.queue, true);
delete _mixer;
- delete _offscreen;
- delete _fullscreen;
+ delete _gameScreenRaw;
+ delete _gameScreenConverted;
}
int OSystem_IPHONE::timerHandler(int t) {
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index dad2e9f..6a779a8 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -63,12 +63,12 @@ protected:
Audio::MixerImpl *_mixer;
Graphics::Surface _framebuffer;
- byte *_offscreen;
+ byte *_gameScreenRaw;
OverlayColor *_overlayBuffer;
uint16 _overlayHeight;
uint16 _overlayWidth;
- uint16 *_fullscreen;
+ uint16 *_gameScreenConverted;
// For use with the game texture
uint16 _gamePalette[256];
diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp
index 2c9e563..2b86c1d 100644
--- a/backends/platform/iphone/osys_video.cpp
+++ b/backends/platform/iphone/osys_video.cpp
@@ -52,10 +52,10 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
_screenWidth = width;
_screenHeight = height;
- free(_offscreen);
+ free(_gameScreenRaw);
- _offscreen = (byte *)malloc(width * height);
- bzero(_offscreen, width * height);
+ _gameScreenRaw = (byte *)malloc(width * height);
+ bzero(_gameScreenRaw, width * height);
//free(_overlayBuffer);
@@ -63,10 +63,10 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
//_overlayBuffer = (OverlayColor *)malloc(fullSize);
clearOverlay();
- free(_fullscreen);
+ free(_gameScreenConverted);
- _fullscreen = (uint16 *)malloc(fullSize);
- bzero(_fullscreen, fullSize);
+ _gameScreenConverted = (uint16 *)malloc(fullSize);
+ bzero(_gameScreenConverted, fullSize);
iPhone_initSurface(width, height);
@@ -147,7 +147,7 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
}
- byte *dst = _offscreen + y * _screenWidth + x;
+ byte *dst = _gameScreenRaw + y * _screenWidth + x;
if (_screenWidth == pitch && pitch == w)
memcpy(dst, buf, h * w);
else {
@@ -196,8 +196,8 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
int h = dirtyRect.bottom - dirtyRect.top;
int w = dirtyRect.right - dirtyRect.left;
- byte *src = &_offscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
- uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
+ byte *src = &_gameScreenRaw[dirtyRect.top * _screenWidth + dirtyRect.left];
+ uint16 *dst = &_gameScreenConverted[dirtyRect.top * _screenWidth + dirtyRect.left];
for (int y = h; y > 0; y--) {
for (int x = w; x > 0; x--)
*dst++ = _gamePalette[*src++];
@@ -222,13 +222,13 @@ void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) {
}
void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) {
- iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom);
+ iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom);
}
Graphics::Surface *OSystem_IPHONE::lockScreen() {
//printf("lockScreen()\n");
- _framebuffer.pixels = _offscreen;
+ _framebuffer.pixels = _gameScreenRaw;
_framebuffer.w = _screenWidth;
_framebuffer.h = _screenHeight;
_framebuffer.pitch = _screenWidth;
Commit: 1b9c4f38456d607abf13dc483bd205351553122f
https://github.com/scummvm/scummvm/commit/1b9c4f38456d607abf13dc483bd205351553122f
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-19T15:35:44-08:00
Commit Message:
IPHONE: Remove some dead code.
Changed paths:
backends/platform/iphone/osys_video.cpp
diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp
index 2b86c1d..a610708 100644
--- a/backends/platform/iphone/osys_video.cpp
+++ b/backends/platform/iphone/osys_video.cpp
@@ -208,16 +208,6 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
}
void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) {
- // int h = dirtyRect.bottom - dirtyRect.top;
- //
- // uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left];
- // uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
- // int x = (dirtyRect.right - dirtyRect.left) * 2;
- // for (int y = h; y > 0; y--) {
- // memcpy(dst, src, x);
- // src += _screenWidth;
- // dst += _screenWidth;
- // }
iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
}
Commit: 65cda4cd6b39c9b9e694a0a8ef696458ac1c2b20
https://github.com/scummvm/scummvm/commit/65cda4cd6b39c9b9e694a0a8ef696458ac1c2b20
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-19T15:36:13-08:00
Commit Message:
IPHONE: Fix some mismatching malloc/delete calls.
Changed paths:
backends/platform/iphone/osys_main.cpp
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 8064fe4..c47a2fc 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -70,8 +70,8 @@ OSystem_IPHONE::~OSystem_IPHONE() {
AudioQueueDispose(s_AudioQueue.queue, true);
delete _mixer;
- delete _gameScreenRaw;
- delete _gameScreenConverted;
+ free(_gameScreenRaw);
+ free(_gameScreenConverted);
}
int OSystem_IPHONE::timerHandler(int t) {
Commit: 8102e7e645db5103369799cd7aae390da099746f
https://github.com/scummvm/scummvm/commit/8102e7e645db5103369799cd7aae390da099746f
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-19T16:32:48-08:00
Commit Message:
IPHONE: Implement cursor palette support.
Changed paths:
NEWS
backends/platform/iphone/iphone_common.h
backends/platform/iphone/iphone_video.m
backends/platform/iphone/osys_main.cpp
backends/platform/iphone/osys_main.h
backends/platform/iphone/osys_video.cpp
diff --git a/NEWS b/NEWS
index 53c6ca7..8ce6709 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,8 @@ For a more comprehensive changelog of the latest experimental code, see:
iPhone port:
- Changed "F5 (menu)" gesture to open up the global main menu instead.
+ - Added support for custom cursor palettes, this makes the moderm theme use
+ the red pointer cursor for example.
Windows port:
- Changed default savegames location for Windows NT4/2000/XP/Vista/7.
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index 470c042..2c57365 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -76,7 +76,7 @@ int iPhone_getScreenHeight();
int iPhone_getScreenWidth();
void iPhone_enableOverlay(int state);
void iPhone_showCursor(int state);
-void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY);
+void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY);
uint getSizeNextPOT(uint size);
diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m
index a18d68e..c163384 100644
--- a/backends/platform/iphone/iphone_video.m
+++ b/backends/platform/iphone/iphone_video.m
@@ -48,7 +48,7 @@ static int _overlayIsEnabled = 0;
static UITouch *_firstTouch = NULL;
static UITouch *_secondTouch = NULL;
-static short *_mouseCursor = NULL;
+static unsigned short *_mouseCursor = NULL;
static int _mouseCursorHeight = 0;
static int _mouseCursorWidth = 0;
static int _mouseCursorHotspotX = 0;
@@ -79,7 +79,7 @@ void iPhone_showCursor(int state) {
_mouseCursorEnabled = state;
}
-void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY) {
+void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY) {
_mouseCursor = buffer;
_mouseCursorWidth = width;
@@ -326,7 +326,6 @@ bool getLocalMouseCoords(CGPoint *point) {
// 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, _textureWidth, _textureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _textureBuffer); printOpenGLError();
- glDisable(GL_BLEND);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}
@@ -353,7 +352,6 @@ bool getLocalMouseCoords(CGPoint *point) {
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();
- glEnable(GL_BLEND);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}
@@ -413,7 +411,6 @@ bool getLocalMouseCoords(CGPoint *point) {
glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError();
glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();
- glEnable(GL_BLEND);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}
@@ -463,6 +460,7 @@ bool getLocalMouseCoords(CGPoint *point) {
glViewport(0, 0, _backingWidth, _backingHeight); printOpenGLError();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError();
+ glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D); printOpenGLError();
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index c47a2fc..06b3227 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -56,11 +56,11 @@ OSystem_IPHONE::OSystem_IPHONE() :
_mixer(NULL), _gameScreenRaw(NULL),
_overlayVisible(false), _gameScreenConverted(NULL),
_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0),
- _secondaryTapped(false), _lastSecondaryTap(0),
+ _mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0),
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0),
- _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0) {
+ _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0), _mouseCursorPaletteEnabled(false) {
_queuedInputEvent.type = Common::EVENT_INVALID;
_touchpadModeEnabled = !iPhone_isHighResDevice();
_fsFactory = new POSIXFilesystemFactory();
@@ -99,14 +99,38 @@ void OSystem_IPHONE::initBackend() {
}
bool OSystem_IPHONE::hasFeature(Feature f) {
- return false;
+ switch (f) {
+ case kFeatureCursorPalette:
+ return true;
+
+ default:
+ return false;
+ }
}
void OSystem_IPHONE::setFeatureState(Feature f, bool enable) {
+ switch (f) {
+ case kFeatureCursorPalette:
+ if (_mouseCursorPaletteEnabled != enable) {
+ _mouseNeedTextureUpdate = true;
+ _mouseDirty = true;
+ _mouseCursorPaletteEnabled = enable;
+ }
+ break;
+
+ default:
+ break;
+ }
}
bool OSystem_IPHONE::getFeatureState(Feature f) {
- return false;
+ switch (f) {
+ case kFeatureCursorPalette:
+ return _mouseCursorPaletteEnabled;
+
+ default:
+ return false;
+ }
}
void OSystem_IPHONE::suspendLoop() {
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index 6a779a8..61816cf 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -82,12 +82,15 @@ protected:
uint32 _timeSuspended;
bool _mouseVisible;
+ bool _mouseCursorPaletteEnabled;
+ uint16 _mouseCursorPalette[256];
byte *_mouseBuf;
byte _mouseKeyColor;
uint _mouseWidth, _mouseHeight;
uint _mouseX, _mouseY;
int _mouseHotspotX, _mouseHotspotY;
bool _mouseDirty;
+ bool _mouseNeedTextureUpdate;
long _lastMouseDown;
long _lastMouseTap;
long _queuedEventTime;
@@ -159,6 +162,7 @@ public:
virtual void warpMouse(int x, int y);
virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL);
+ virtual void setCursorPalette(const byte *colors, uint start, uint num);
virtual bool pollEvent(Common::Event &event);
virtual uint32 getMillis();
@@ -195,6 +199,7 @@ protected:
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);
static int timerHandler(int t);
diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp
index a610708..0483c72 100644
--- a/backends/platform/iphone/osys_video.cpp
+++ b/backends/platform/iphone/osys_video.cpp
@@ -81,6 +81,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
_fullScreenIsDirty = false;
dirtyFullScreen();
_mouseVisible = false;
+ _mouseCursorPaletteEnabled = false;
_screenChangeCount++;
updateScreen();
}
@@ -174,6 +175,11 @@ void OSystem_IPHONE::updateScreen() {
}
void OSystem_IPHONE::internUpdateScreen() {
+ if (_mouseNeedTextureUpdate) {
+ updateMouseTexture();
+ _mouseNeedTextureUpdate = false;
+ }
+
while (_dirtyRects.size()) {
Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1);
@@ -355,24 +361,6 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() {
void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
//printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale);
- int texWidth = getSizeNextPOT(w);
- int texHeight = getSizeNextPOT(h);
- int bufferSize = texWidth * texHeight * sizeof(int16);
- int16 *mouseBuf = (int16 *)malloc(bufferSize);
- memset(mouseBuf, 0, bufferSize);
-
- for (uint x = 0; x < w; ++x) {
- for (uint y = 0; y < h; ++y) {
- byte color = buf[y * w + x];
- if (color != keycolor)
- mouseBuf[y * texWidth + x] = _gamePaletteRGBA5551[color] | 0x1;
- else
- mouseBuf[y * texWidth + x] = 0x0;
- }
- }
-
- iPhone_setMouseCursor(mouseBuf, w, h, hotspotX, hotspotY);
-
if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
free(_mouseBuf);
_mouseBuf = NULL;
@@ -392,4 +380,45 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot
memcpy(_mouseBuf, buf, w * h);
_mouseDirty = true;
+ _mouseNeedTextureUpdate = true;
+}
+
+void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) {
+ assert(start + num <= 256);
+
+ for (uint i = start; i < start + num; ++i, colors += 3)
+ _mouseCursorPalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(colors[0], colors[1], colors[2]);
+
+ // FIXME: This is just stupid, our client code seems to assume that this
+ // automatically enables the cursor palette.
+ _mouseCursorPaletteEnabled = true;
+
+ if (_mouseCursorPaletteEnabled)
+ _mouseDirty = _mouseNeedTextureUpdate = true;
+}
+
+void OSystem_IPHONE::updateMouseTexture() {
+ int texWidth = getSizeNextPOT(_mouseWidth);
+ int texHeight = getSizeNextPOT(_mouseHeight);
+ int bufferSize = texWidth * texHeight * sizeof(int16);
+ uint16 *mouseBuf = (uint16 *)malloc(bufferSize);
+ memset(mouseBuf, 0, bufferSize);
+
+ const uint16 *palette;
+ if (_mouseCursorPaletteEnabled)
+ palette = _mouseCursorPalette;
+ else
+ palette = _gamePaletteRGBA5551;
+
+ for (uint x = 0; x < _mouseWidth; ++x) {
+ for (uint y = 0; y < _mouseHeight; ++y) {
+ const byte color = _mouseBuf[y * _mouseWidth + x];
+ if (color != _mouseKeyColor)
+ mouseBuf[y * texWidth + x] = palette[color] | 0x1;
+ else
+ mouseBuf[y * texWidth + x] = 0x0;
+ }
+ }
+
+ iPhone_setMouseCursor(mouseBuf, _mouseWidth, _mouseHeight, _mouseHotspotX, _mouseHotspotY);
}
More information about the Scummvm-git-logs
mailing list