[Scummvm-git-logs] scummvm master -> e26a677f6214a1c88d63a41e136dc78ad07cca11
csnover
csnover at users.noreply.github.com
Mon Oct 16 02:03:22 CEST 2017
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:
db5676fec2 TITANIC: Simplify cursors to build up as RGBA during loading
17606700c4 TITANIC: Fix use after free and remove IFDEF code from mouse cursors
e26a677f62 SCI32: Tell OSystem to show/hide cursors as appropriate
Commit: db5676fec2410a8843302225948f12e9d778cccc
https://github.com/scummvm/scummvm/commit/db5676fec2410a8843302225948f12e9d778cccc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-10-15T19:03:09-05:00
Commit Message:
TITANIC: Simplify cursors to build up as RGBA during loading
Changed paths:
engines/titanic/support/mouse_cursor.cpp
engines/titanic/support/mouse_cursor.h
diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp
index 1c5e0da..d9a3578 100644
--- a/engines/titanic/support/mouse_cursor.cpp
+++ b/engines/titanic/support/mouse_cursor.cpp
@@ -54,8 +54,7 @@ static const int CURSOR_DATA[NUM_CURSORS][4] = {
};
CMouseCursor::CursorEntry::~CursorEntry() {
- delete _videoSurface;
- delete _transSurface;
+ delete _surface;
}
CMouseCursor::CMouseCursor(CScreenManager *screenManager) :
@@ -80,15 +79,32 @@ void CMouseCursor::loadCursorImages() {
// Create the surface
CVideoSurface *surface = _screenManager->createSurface(CURSOR_SIZE, CURSOR_SIZE);
- _cursors[idx]._videoSurface = surface;
// Open the cursors video and move to the given frame
OSMovie movie(key, surface);
movie.setFrame(idx);
-
Graphics::ManagedSurface *transSurface = movie.duplicateTransparency();
- _cursors[idx]._transSurface = transSurface;
- surface->setTransparencySurface(transSurface);
+
+ // Create a managed surface to hold the RGBA version of the cursor
+ Graphics::PixelFormat rgbaFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
+ _cursors[idx]._surface = new Graphics::ManagedSurface(CURSOR_SIZE, CURSOR_SIZE, rgbaFormat);
+
+ // Copy the cursor from the movie's video surface
+ surface->lock();
+ _cursors[idx]._surface->blitFrom(*surface->getRawSurface());
+ surface->unlock();
+
+ // We need to separately merge in the transparency surface
+ for (int y = 0; y < CURSOR_SIZE; ++y) {
+ const byte *srcP = (const byte *)transSurface->getBasePtr(0, y);
+ uint32 *destP = (uint32 *)_cursors[idx]._surface->getBasePtr(0, y);
+
+ for (int x = 0; x < CURSOR_SIZE; ++x, ++srcP, ++destP)
+ *destP = (*destP & ~0xff) | *srcP;
+ }
+
+ delete transSurface;
+ delete surface;
}
}
@@ -131,35 +147,22 @@ void CMouseCursor::setCursor(CursorId cursorId) {
++_setCursorCount;
if (cursorId != _cursorId && _busyCount == 0) {
- // The original cursors supported partial alpha when rendering the cursor.
- // Since we're using the ScummVM CursorMan, we can't do that, so we need
- // to build up a surface of the cursor with even partially transparent
- // pixels as wholy transparent
- CursorEntry &ce = _cursors[cursorId - 1];
- CVideoSurface &srcSurface = *ce._videoSurface;
- srcSurface.lock();
-
- Graphics::ManagedSurface surface(CURSOR_SIZE, CURSOR_SIZE, g_system->getScreenFormat());
- const uint16 *srcP = srcSurface.getPixels();
- CTransparencySurface transSurface(&ce._transSurface->rawSurface(), TRANS_ALPHA0);
- uint16 *destP = (uint16 *)surface.getPixels();
-
- for (int y = 0; y < CURSOR_SIZE; ++y) {
- transSurface.setRow(y);
- transSurface.setCol(0);
-
- for (int x = 0; x < CURSOR_SIZE; ++x, ++srcP, ++destP) {
- *destP = transSurface.isPixelTransparent() ? srcSurface.getTransparencyColor() : *srcP;
- transSurface.moveX();
- }
- }
-
- srcSurface.unlock();
+ const CursorEntry &ce = _cursors[cursorId - 1];
+ _cursorId = cursorId;
// Set the cursor
- _cursorId = cursorId;
- CursorMan.replaceCursor(surface.getPixels(), CURSOR_SIZE, CURSOR_SIZE,
- ce._centroid.x, ce._centroid.y, srcSurface.getTransparencyColor(), false, &g_vm->_screen->format);
+ #ifdef RGBA_CURSORS
+ CursorMan.replaceCursor(ce._surface->getPixels(), CURSOR_SIZE, CURSOR_SIZE,
+ ce._centroid.x, ce._centroid.y, 0, false, &ce._surface->format);
+ #else
+ const Graphics::Surface &surf = *ce._surface;
+ Graphics::Surface *s = surf.convertTo(g_system->getScreenFormat());
+
+ CursorMan.replaceCursor(s->getPixels(), CURSOR_SIZE, CURSOR_SIZE,
+ ce._centroid.x, ce._centroid.y, 0, false, &s->format);
+
+ delete s;
+ #endif
}
}
diff --git a/engines/titanic/support/mouse_cursor.h b/engines/titanic/support/mouse_cursor.h
index aff3bac..efcb1f8 100644
--- a/engines/titanic/support/mouse_cursor.h
+++ b/engines/titanic/support/mouse_cursor.h
@@ -54,11 +54,10 @@ class CVideoSurface;
class CMouseCursor {
struct CursorEntry {
- CVideoSurface *_videoSurface;
- Graphics::ManagedSurface *_transSurface;
+ Graphics::ManagedSurface *_surface;
Common::Point _centroid;
- CursorEntry() : _videoSurface(nullptr), _transSurface(nullptr) {}
+ CursorEntry() : _surface(nullptr) {}
~CursorEntry();
};
private:
Commit: 17606700c49b056b655f1d7e3d4a39c707520f24
https://github.com/scummvm/scummvm/commit/17606700c49b056b655f1d7e3d4a39c707520f24
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-10-15T19:03:09-05:00
Commit Message:
TITANIC: Fix use after free and remove IFDEF code from mouse cursors
Changed paths:
engines/titanic/support/mouse_cursor.cpp
diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp
index d9a3578..21b4258 100644
--- a/engines/titanic/support/mouse_cursor.cpp
+++ b/engines/titanic/support/mouse_cursor.cpp
@@ -81,9 +81,9 @@ void CMouseCursor::loadCursorImages() {
CVideoSurface *surface = _screenManager->createSurface(CURSOR_SIZE, CURSOR_SIZE);
// Open the cursors video and move to the given frame
- OSMovie movie(key, surface);
- movie.setFrame(idx);
- Graphics::ManagedSurface *transSurface = movie.duplicateTransparency();
+ OSMovie *movie = new OSMovie(key, surface);
+ movie->setFrame(idx);
+ Graphics::ManagedSurface *transSurface = movie->duplicateTransparency();
// Create a managed surface to hold the RGBA version of the cursor
Graphics::PixelFormat rgbaFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
@@ -103,6 +103,7 @@ void CMouseCursor::loadCursorImages() {
*destP = (*destP & ~0xff) | *srcP;
}
+ delete movie;
delete transSurface;
delete surface;
}
@@ -151,18 +152,8 @@ void CMouseCursor::setCursor(CursorId cursorId) {
_cursorId = cursorId;
// Set the cursor
- #ifdef RGBA_CURSORS
CursorMan.replaceCursor(ce._surface->getPixels(), CURSOR_SIZE, CURSOR_SIZE,
ce._centroid.x, ce._centroid.y, 0, false, &ce._surface->format);
- #else
- const Graphics::Surface &surf = *ce._surface;
- Graphics::Surface *s = surf.convertTo(g_system->getScreenFormat());
-
- CursorMan.replaceCursor(s->getPixels(), CURSOR_SIZE, CURSOR_SIZE,
- ce._centroid.x, ce._centroid.y, 0, false, &s->format);
-
- delete s;
- #endif
}
}
Commit: e26a677f6214a1c88d63a41e136dc78ad07cca11
https://github.com/scummvm/scummvm/commit/e26a677f6214a1c88d63a41e136dc78ad07cca11
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-10-15T19:03:09-05:00
Commit Message:
SCI32: Tell OSystem to show/hide cursors as appropriate
This is needed so that the system cursor can be appropriately
hidden outside the game's draw area, to match the normal behaviour
of ScummVM.
Changed paths:
engines/sci/graphics/cursor32.cpp
diff --git a/engines/sci/graphics/cursor32.cpp b/engines/sci/graphics/cursor32.cpp
index f401d1b..a189f74 100644
--- a/engines/sci/graphics/cursor32.cpp
+++ b/engines/sci/graphics/cursor32.cpp
@@ -57,6 +57,7 @@ void GfxCursor32::hide() {
return;
}
+ g_system->showMouse(false);
if (!_cursorBack.rect.isEmpty()) {
drawToScreen(_cursorBack);
}
@@ -136,12 +137,14 @@ void GfxCursor32::unhide() {
return;
}
+ g_system->showMouse(true);
_cursor.rect.moveTo(_position.x - _hotSpot.x, _position.y - _hotSpot.y);
revealCursor();
}
void GfxCursor32::show() {
if (_hideCount) {
+ g_system->showMouse(true);
_hideCount = 0;
_cursor.rect.moveTo(_position.x - _hotSpot.x, _position.y - _hotSpot.y);
revealCursor();
More information about the Scummvm-git-logs
mailing list