aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2010-10-05 10:30:26 +0000
committerFilippos Karapetis2010-10-05 10:30:26 +0000
commitc8fd37c9f0eca0164f44c07c9013ad6e7e733e2e (patch)
tree44fc0fa6f85ddd761728708afe3320927ef946c3
parent61afea6cbe527b0c4dedc587e1beb4568f7d379d (diff)
downloadscummvm-rg350-c8fd37c9f0eca0164f44c07c9013ad6e7e733e2e.tar.gz
scummvm-rg350-c8fd37c9f0eca0164f44c07c9013ad6e7e733e2e.tar.bz2
scummvm-rg350-c8fd37c9f0eca0164f44c07c9013ad6e7e733e2e.zip
SCI: Some fixes for zoom cursors
- Now the cursor buffer is initialized outside the mouse movement code, thus saving a memcpy there - Plugged some memory leaks - Removed an obsolete check svn-id: r53028
-rw-r--r--engines/sci/graphics/cursor.cpp23
-rw-r--r--engines/sci/graphics/cursor.h1
2 files changed, 12 insertions, 12 deletions
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp
index 0fa490cfa8..b7ec23fda9 100644
--- a/engines/sci/graphics/cursor.cpp
+++ b/engines/sci/graphics/cursor.cpp
@@ -58,10 +58,12 @@ GfxCursor::GfxCursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *sc
_zoomPicView = 0;
_zoomColor = 0;
_zoomMultiplier = 0;
+ _cursorSurface = 0;
}
GfxCursor::~GfxCursor() {
purgeCache();
+ kernelClearZoomZone();
}
void GfxCursor::init(GfxCoordAdjuster *coordAdjuster, EventManager *event) {
@@ -368,15 +370,12 @@ void GfxCursor::refreshPosition() {
// Cursor
const CelInfo *cursorCelInfo = _zoomCursorView->getCelInfo(_zoomCursorLoop, _zoomCursorCel);
const byte *cursorBitmap = _zoomCursorView->getBitmap(_zoomCursorLoop, _zoomCursorCel);
- byte *finalBitmap = new byte[cursorCelInfo->width * cursorCelInfo->height];
// Pic
const CelInfo *picCelInfo = _zoomPicView->getCelInfo(0, 0);
const byte *rawPicBitmap = _zoomPicView->getBitmap(0, 0);
// Compute hotspot from xoffset/yoffset
Common::Point cursorHotspot = Common::Point((cursorCelInfo->width >> 1) - cursorCelInfo->displaceX, cursorCelInfo->height - cursorCelInfo->displaceY - 1);
- memcpy(finalBitmap, cursorBitmap, cursorCelInfo->width * cursorCelInfo->height);
-
uint16 targetX = CLIP<int>((mousePoint.x - _zoomZone.left) * _zoomMultiplier, 0, picCelInfo->width - cursorCelInfo->width);
uint16 targetY = CLIP<int>((mousePoint.y - _zoomZone.top) * _zoomMultiplier, 0, picCelInfo->height - cursorCelInfo->height);
@@ -384,15 +383,13 @@ void GfxCursor::refreshPosition() {
for (int x = 0; x < cursorCelInfo->width; x++) {
for (int y = 0; y < cursorCelInfo->height; y++) {
int curPos = cursorCelInfo->width * y + x;
- if (finalBitmap[curPos] == _zoomColor) {
- finalBitmap[curPos] = rawPicBitmap[picCelInfo->width * (targetY + y) + (targetX + x)];
+ if (cursorBitmap[curPos] == _zoomColor) {
+ _cursorSurface[curPos] = rawPicBitmap[picCelInfo->width * (targetY + y) + (targetX + x)];
}
}
}
- CursorMan.replaceCursor((const byte *)finalBitmap, cursorCelInfo->width, cursorCelInfo->height, cursorHotspot.x, cursorHotspot.y, cursorCelInfo->clearKey);
-
- delete[] finalBitmap;
+ CursorMan.replaceCursor((const byte *)_cursorSurface, cursorCelInfo->width, cursorCelInfo->height, cursorHotspot.x, cursorHotspot.y, cursorCelInfo->clearKey);
}
}
@@ -413,13 +410,11 @@ void GfxCursor::kernelClearZoomZone() {
_zoomZoneActive = false;
delete _zoomCursorView;
delete _zoomPicView;
+ delete[] _cursorSurface;
}
void GfxCursor::kernelSetZoomZone(byte multiplier, Common::Rect zone, GuiResourceId viewNum, int loopNum, int celNum, GuiResourceId picNum, byte zoomColor) {
- if (multiplier != 1 && multiplier != 2) {
- warning("kernelSetZoomZone: Unsupported magnifier %d", multiplier);
- return;
- }
+ kernelClearZoomZone();
_zoomMultiplier = multiplier;
@@ -427,6 +422,10 @@ void GfxCursor::kernelSetZoomZone(byte multiplier, Common::Rect zone, GuiResourc
_zoomCursorLoop = (byte)loopNum;
_zoomCursorCel = (byte)celNum;
_zoomPicView = new GfxView(_resMan, _screen, _palette, picNum);
+ const CelInfo *cursorCelInfo = _zoomCursorView->getCelInfo(_zoomCursorLoop, _zoomCursorCel);
+ const byte *cursorBitmap = _zoomCursorView->getBitmap(_zoomCursorLoop, _zoomCursorCel);
+ _cursorSurface = new byte[cursorCelInfo->width * cursorCelInfo->height];
+ memcpy(_cursorSurface, cursorBitmap, cursorCelInfo->width * cursorCelInfo->height);
_zoomZone = zone;
kernelSetMoveZone(_zoomZone);
diff --git a/engines/sci/graphics/cursor.h b/engines/sci/graphics/cursor.h
index 5edc715649..ae3b51e26a 100644
--- a/engines/sci/graphics/cursor.h
+++ b/engines/sci/graphics/cursor.h
@@ -107,6 +107,7 @@ private:
GfxView *_zoomPicView;
byte _zoomColor;
byte _zoomMultiplier;
+ byte *_cursorSurface;
CursorCache _cachedCursors;