aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus
diff options
context:
space:
mode:
authorBastien Bouclet2017-09-10 09:55:07 +0200
committerBastien Bouclet2017-09-12 20:25:24 +0200
commitd534299d384dfe4543208419cb372a63c2891a00 (patch)
tree8331389976a770e144f83bdfdc28ec11fefb8d11 /engines/pegasus
parent1519b2befcb71ff52f92144406d67ce8a7b76b35 (diff)
downloadscummvm-rg350-d534299d384dfe4543208419cb372a63c2891a00.tar.gz
scummvm-rg350-d534299d384dfe4543208419cb372a63c2891a00.tar.bz2
scummvm-rg350-d534299d384dfe4543208419cb372a63c2891a00.zip
PEGASUS: Don't do virtual calls when fading the screen
For better performance.
Diffstat (limited to 'engines/pegasus')
-rw-r--r--engines/pegasus/transition.cpp28
-rw-r--r--engines/pegasus/transition.h2
2 files changed, 14 insertions, 16 deletions
diff --git a/engines/pegasus/transition.cpp b/engines/pegasus/transition.cpp
index b6b13be919..b22f51f96d 100644
--- a/engines/pegasus/transition.cpp
+++ b/engines/pegasus/transition.cpp
@@ -34,54 +34,52 @@ ScreenFader::ScreenFader() {
_isBlack = true;
// Initially, assume screens are on at full brightness.
Fader::setFaderValue(100);
- _screen = new Graphics::Surface();
}
ScreenFader::~ScreenFader() {
- _screen->free();
- delete _screen;
+ _screen.free();
}
void ScreenFader::doFadeOutSync(const TimeValue duration, const TimeValue scale, bool isBlack) {
_isBlack = isBlack;
- _screen->copyFrom(*g_system->lockScreen());
+ _screen.copyFrom(*g_system->lockScreen());
g_system->unlockScreen();
FaderMoveSpec spec;
spec.makeTwoKnotFaderSpec(scale, 0, getFaderValue(), duration, 0);
startFaderSync(spec);
- _screen->free();
+ _screen.free();
}
void ScreenFader::doFadeInSync(const TimeValue duration, const TimeValue scale, bool isBlack) {
_isBlack = isBlack;
- _screen->copyFrom(*g_system->lockScreen());
+ _screen.copyFrom(*g_system->lockScreen());
g_system->unlockScreen();
FaderMoveSpec spec;
spec.makeTwoKnotFaderSpec(scale, 0, getFaderValue(), duration, 100);
startFaderSync(spec);
- _screen->free();
+ _screen.free();
}
void ScreenFader::setFaderValue(const int32 value) {
if (value != getFaderValue()) {
Fader::setFaderValue(value);
- if (_screen->getPixels()) {
+ if (_screen.getPixels()) {
// The original game does a gamma fade here using the Mac API. In order to do
// that, it would require an immense amount of CPU processing. This does a
// linear fade instead, which looks fairly well, IMO.
Graphics::Surface *screen = g_system->lockScreen();
- for (uint y = 0; y < _screen->h; y++) {
- for (uint x = 0; x < _screen->w; x++) {
- if (_screen->format.bytesPerPixel == 2)
- WRITE_UINT16(screen->getBasePtr(x, y), fadePixel(READ_UINT16(_screen->getBasePtr(x, y)), value));
+ for (uint y = 0; y < _screen.h; y++) {
+ for (uint x = 0; x < _screen.w; x++) {
+ if (_screen.format.bytesPerPixel == 2)
+ WRITE_UINT16(screen->getBasePtr(x, y), fadePixel(READ_UINT16(_screen.getBasePtr(x, y)), value));
else
- WRITE_UINT32(screen->getBasePtr(x, y), fadePixel(READ_UINT32(_screen->getBasePtr(x, y)), value));
+ WRITE_UINT32(screen->getBasePtr(x, y), fadePixel(READ_UINT32(_screen.getBasePtr(x, y)), value));
}
}
@@ -97,7 +95,7 @@ static inline byte fadeComponent(byte comp, int32 percent) {
uint32 ScreenFader::fadePixel(uint32 color, int32 percent) const {
byte r, g, b;
- g_system->getScreenFormat().colorToRGB(color, r, g, b);
+ _screen.format.colorToRGB(color, r, g, b);
if (_isBlack) {
r = fadeComponent(r, percent);
@@ -109,7 +107,7 @@ uint32 ScreenFader::fadePixel(uint32 color, int32 percent) const {
b = 0xFF - fadeComponent(0xFF - b, percent);
}
- return g_system->getScreenFormat().RGBToColor(r, g, b);
+ return _screen.format.RGBToColor(r, g, b);
}
Transition::Transition(const DisplayElementID id) : FaderAnimation(id) {
diff --git a/engines/pegasus/transition.h b/engines/pegasus/transition.h
index e1f0822f1b..f8cdb3e365 100644
--- a/engines/pegasus/transition.h
+++ b/engines/pegasus/transition.h
@@ -47,7 +47,7 @@ public:
private:
bool _isBlack;
uint32 fadePixel(uint32 color, int32 percent) const;
- Graphics::Surface *_screen;
+ Graphics::Surface _screen;
};
// Transitions are faders that range over [0,1000], which makes their