[Scummvm-git-logs] scummvm master -> b2073d64139b7c45a9d3ab61aae967b853d41a36
whiterandrek
whiterandrek at gmail.com
Mon May 25 08:35:42 UTC 2020
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:
3882d61d73 PETKA: simplified adding dirty rects
63df29a5c2 PETKA: optimized drawing of 1 frame flics
b2073d6413 PETKA: fixed starting save load interface more than 1 time
Commit: 3882d61d73157c2fe8b259e889427eff1333343a
https://github.com/scummvm/scummvm/commit/3882d61d73157c2fe8b259e889427eff1333343a
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T11:31:15+03:00
Commit Message:
PETKA: simplified adding dirty rects
Changed paths:
engines/petka/interfaces/startup.cpp
engines/petka/objects/object_cursor.cpp
diff --git a/engines/petka/interfaces/startup.cpp b/engines/petka/interfaces/startup.cpp
index 42d359844e..782e91e42d 100644
--- a/engines/petka/interfaces/startup.cpp
+++ b/engines/petka/interfaces/startup.cpp
@@ -117,8 +117,7 @@ void InterfaceStartup::onMouseMove(const Common::Point p) {
if (obj->_isShown != show) {
obj->_isShown = show;
flc->setFrame(1);
- Common::Rect dirty(flc->getBounds());
- g_vm->videoSystem()->addDirtyRect(dirty);
+ g_vm->videoSystem()->addDirtyRect(flc->getBounds());
}
}
}
diff --git a/engines/petka/objects/object_cursor.cpp b/engines/petka/objects/object_cursor.cpp
index 8736cd3e48..06c6b026eb 100644
--- a/engines/petka/objects/object_cursor.cpp
+++ b/engines/petka/objects/object_cursor.cpp
@@ -71,9 +71,7 @@ void QObjectCursor::update(int time) {
_time += time;
while (flc && _time >= flc->getDelay()) {
flc->setFrame(-1);
- Common::Rect dirty(flc->getBounds());
- dirty.translate(_x, _y);
- g_vm->videoSystem()->addDirtyRect(dirty);
+ g_vm->videoSystem()->addDirtyRect(Common::Point(_x, _y), flc->getBounds());
_time -= flc->getDelay();
}
}
@@ -84,28 +82,23 @@ void QObjectCursor::setCursorPos(int x, int y, bool center) {
flc->setFrame(1);
}
- Common::Rect dirty(flc->getBounds());
- dirty.translate(_x, _y);
- g_vm->videoSystem()->addDirtyRect(dirty);
+ g_vm->videoSystem()->addDirtyRect(Common::Point(_x, _y), flc->getBounds());
if (center) {
- x = x - flc->getBounds().left - dirty.width() / 2;
- y = y - flc->getBounds().top - dirty.height() / 2;
+ Common::Rect bounds = flc->getBounds();
+ x = x - bounds.left - bounds.width() / 2;
+ y = y - bounds.top - bounds.height() / 2;
}
_x = x;
_y = y;
- dirty = flc->getBounds();
- dirty.translate(_x, _y);
- g_vm->videoSystem()->addDirtyRect(dirty);
+ g_vm->videoSystem()->addDirtyRect(Common::Point(_x, _y), flc->getBounds());
}
void QObjectCursor::show(bool v) {
FlicDecoder *flc = g_vm->resMgr()->loadFlic(_resourceId);
- Common::Rect rect = flc->getBounds();
- rect.translate(_x, _y);
- g_vm->videoSystem()->addDirtyRect(rect);
+ g_vm->videoSystem()->addDirtyRect(Common::Point(_x, _y), flc->getBounds());
QMessageObject::show(v);
}
Commit: 63df29a5c2ef3f086fcb0b9ee89ad9d31250f3b5
https://github.com/scummvm/scummvm/commit/63df29a5c2ef3f086fcb0b9ee89ad9d31250f3b5
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T11:33:16+03:00
Commit Message:
PETKA: optimized drawing of 1 frame flics
Changed paths:
engines/petka/flc.cpp
engines/petka/flc.h
engines/petka/objects/object.cpp
engines/petka/objects/object_case.cpp
diff --git a/engines/petka/flc.cpp b/engines/petka/flc.cpp
index d74f5209ab..657cb906c9 100644
--- a/engines/petka/flc.cpp
+++ b/engines/petka/flc.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/system.h"
#include "common/stream.h"
#include "graphics/surface.h"
@@ -73,6 +74,14 @@ const Common::Rect &FlicDecoder::getBounds() const {
return *(new Common::Rect(0, 0));
}
+Common::Point FlicDecoder::getPos() const {
+ const Track *track = getTrack(0);
+ if (track)
+ return ((const FlicVideoTrack *)track)->getPos();
+
+ return Common::Point(0, 0);
+}
+
const Common::Array<Common::Rect> &FlicDecoder::getMskRects() const {
const Track *track = getTrack(0);
if (track)
@@ -95,7 +104,7 @@ uint32 FlicDecoder::getTransColor(const Graphics::PixelFormat &fmt) const {
void FlicDecoder::setFrame(int frame) {
FlicVideoTrack *flc = ((FlicVideoTrack *)getTrack(0));
- if (!flc || flc->getCurFrame() + 1 == frame)
+ if (!flc || flc->getFrameCount() == 1 || flc->getCurFrame() + 1 == frame)
return;
if (frame == -1) {
@@ -139,27 +148,43 @@ bool FlicDecoder::FlicVideoTrack::loadMsk(Common::SeekableReadStream &stream) {
_bounds.right = (int16)stream.readSint32LE();
_bounds.bottom = (int16)stream.readSint32LE();
- if (_bounds.left > _bounds.right) {
- int16 t = _bounds.left;
- _bounds.left = _bounds.right;
- _bounds.right = t;
+ if (_surface->w <= _bounds.right) {
+ _bounds.right = _surface->w - 1;
}
- if (_bounds.top > _bounds.bottom) {
- int16 t = _bounds.top;
- _bounds.top = _bounds.bottom;
- _bounds.bottom = t;
+ if (_surface->h <= _bounds.bottom) {
+ _bounds.bottom = _surface->h - 1;
}
- assert(stream.size() == stream.pos());
- if (getWidth() <= _bounds.right) {
- _bounds.right = getWidth() - 1;
+
+ if (_bounds.left > _bounds.right) {
+ SWAP(_bounds.left, _bounds.right);
}
- if (getHeight() <= _bounds.bottom) {
- _bounds.bottom = getHeight() - 1;
+ if (_bounds.top > _bounds.bottom) {
+ SWAP(_bounds.top, _bounds.bottom);
}
+
_bounds = _bounds.findIntersectingRect(Common::Rect(0, 0, _bounds.right, 479));
_bounds.right++;
_bounds.bottom++;
+ _pos.x = 0;
+ _pos.y = 0;
+
+ if (_frameCount == 1 && _surface->w > 630 && _surface->h > 470 && (_bounds.width() < 620 || _bounds.height() < 460)) {
+ Graphics::Surface *s = new Graphics::Surface();
+ s->create(_bounds.width(), _bounds.height(), g_system->getScreenFormat());
+
+ _surface->convertToInPlace(s->format, _palette);
+ s->copyRectToSurface(*_surface, 0, 0, _bounds);
+
+ _surface->free();
+ delete _surface;
+
+ _pos.x = _bounds.left;
+ _pos.y = _bounds.top;
+
+ _surface = s;
+ }
+
return true;
}
@@ -180,4 +205,8 @@ uint FlicDecoder::FlicVideoTrack::getDelay() const {
return _frameDelay;
}
+Common::Point FlicDecoder::FlicVideoTrack::getPos() const {
+ return _pos;
+}
+
} // End of namespace Petka
diff --git a/engines/petka/flc.h b/engines/petka/flc.h
index 17b88c6492..feffe542a6 100644
--- a/engines/petka/flc.h
+++ b/engines/petka/flc.h
@@ -35,6 +35,7 @@ public:
uint getDelay() const;
const Common::Rect &getBounds() const;
+ Common::Point getPos() const;
const Common::Array<Common::Rect> &getMskRects() const;
const Graphics::Surface *getCurrentFrame() const;
uint32 getTransColor(const Graphics::PixelFormat &fmt) const;
@@ -48,11 +49,13 @@ protected:
uint getDelay() const;
const Common::Rect &getBounds() const;
+ Common::Point getPos() const;
const Common::Array<Common::Rect> &getMskRects() const;
const Graphics::Surface *getSurface() const;
private:
Common::Rect _bounds;
+ Common::Point _pos;
Common::Array<Common::Array<Common::Rect> > _msk;
};
};
diff --git a/engines/petka/objects/object.cpp b/engines/petka/objects/object.cpp
index 29b04d6d8c..d17a16c6d1 100644
--- a/engines/petka/objects/object.cpp
+++ b/engines/petka/objects/object.cpp
@@ -416,10 +416,9 @@ bool QObject::isInPoint(int x, int y) {
return false;
FlicDecoder *flc = g_vm->resMgr()->loadFlic(_resourceId);
if (flc) {
- Common::Rect rect(_x, _y, _x + flc->getWidth(), _y + flc->getHeight());
- if (!rect.contains(x, y))
+ if (!flc->getBounds().contains(x - _x, y - _y))
return false;
- return *(const byte *)flc->getCurrentFrame()->getBasePtr(x - _x, y - _y) != 0;
+ return *(const byte *)flc->getCurrentFrame()->getBasePtr(x - _x - flc->getPos().x, y - _y - flc->getPos().y) != 0;
}
return false;
}
@@ -441,7 +440,6 @@ void QObject::draw() {
Common::Rect screen(640, 480);
Common::Rect dest(flc->getBounds());
- //flcRect.translate(_x, _y);
dest.translate(_x, _y);
Common::Rect intersect(screen.findIntersectingRect(dest));
@@ -456,7 +454,7 @@ void QObject::draw() {
if (destRect.isEmpty())
continue;
Common::Rect srcRect(destRect);
- srcRect.translate(-_x, -_y);
+ srcRect.translate(-_x - flc->getPos().x, -_y - flc->getPos().y);
g_vm->videoSystem()->transBlitFrom(*s, srcRect, destRect, flc->getTransColor(s->format));
}
s->free();
diff --git a/engines/petka/objects/object_case.cpp b/engines/petka/objects/object_case.cpp
index b4cf6f9521..58b9f5cebb 100644
--- a/engines/petka/objects/object_case.cpp
+++ b/engines/petka/objects/object_case.cpp
@@ -106,9 +106,10 @@ void QObjectCase::draw() {
for (Common::List<Common::Rect>::const_iterator it = dirty.begin(); it != dirty.end(); ++it) {
for (uint i = 0; i < mskRects.size(); ++i) {
- Common::Rect rect = mskRects[i].findIntersectingRect(*it);
- debug("%d %d", rect.width(), rect.height());
- g_vm->videoSystem()->transBlitFrom(*s, rect, rect, flc->getTransColor(s->format));
+ Common::Rect destRect = mskRects[i].findIntersectingRect(*it);
+ Common::Rect srcRect = destRect;
+ srcRect.translate(-flc->getPos().x - _x, -flc->getPos().y - _y);
+ g_vm->videoSystem()->transBlitFrom(*s, srcRect, destRect, flc->getTransColor(s->format));
}
}
Commit: b2073d64139b7c45a9d3ab61aae967b853d41a36
https://github.com/scummvm/scummvm/commit/b2073d64139b7c45a9d3ab61aae967b853d41a36
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T11:34:02+03:00
Commit Message:
PETKA: fixed starting save load interface more than 1 time
Changed paths:
engines/petka/interfaces/save_load.cpp
diff --git a/engines/petka/interfaces/save_load.cpp b/engines/petka/interfaces/save_load.cpp
index c7a56b1d0e..aacb8835e2 100644
--- a/engines/petka/interfaces/save_load.cpp
+++ b/engines/petka/interfaces/save_load.cpp
@@ -52,6 +52,7 @@ void InterfaceSaveLoad::start(int id) {
_loadMode = (id == kLoadMode);
+ _objs.clear();
QObjectBG *bg = (QObjectBG *)sys->findObject("SAVELOAD");
_objs.push_back(bg);
bg->_resourceId = kFirstSaveLoadPageId + _page + (_loadMode ? 0 : 5);
More information about the Scummvm-git-logs
mailing list