[Scummvm-git-logs] scummvm master -> 6777f200f9db3ee8f64afac9f9229262e9734f68

elasota noreply at scummvm.org
Wed Jul 3 18:54:51 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6777f200f9 MTROPOLIS: add fallback palette to MovieElement blitting (#5811)


Commit: 6777f200f9db3ee8f64afac9f9229262e9734f68
    https://github.com/scummvm/scummvm/commit/6777f200f9db3ee8f64afac9f9229262e9734f68
Author: meekee7 (michael_kuerbis at web.de)
Date: 2024-07-03T14:54:47-04:00

Commit Message:
MTROPOLIS: add fallback palette to MovieElement blitting (#5811)

* MTROPOLIS: add fallback palette to MovieElement blitting

Without a palette, there would be assertions and nullptr segfaults
in Graphics::ManagedSurface::blitFromInner.
Observed in MindGym and The Day The World Broke

The palette content is not correct yet. Mind Gym renders the video
with the wrong colors.

* MTROPOLIS: use global palette as fallback for MovieElement

Changed paths:
    engines/mtropolis/elements.cpp
    engines/mtropolis/elements.h


diff --git a/engines/mtropolis/elements.cpp b/engines/mtropolis/elements.cpp
index 0b82924a8e8..5b2cecfdce7 100644
--- a/engines/mtropolis/elements.cpp
+++ b/engines/mtropolis/elements.cpp
@@ -781,7 +781,9 @@ void MovieElement::render(Window *window) {
 		Graphics::ManagedSurface *target = window->getSurface().get();
 		Common::Rect srcRect(0, 0, displaySurface->w, displaySurface->h);
 		Common::Rect destRect(_cachedAbsoluteOrigin.x, _cachedAbsoluteOrigin.y, _cachedAbsoluteOrigin.x + _rect.width(), _cachedAbsoluteOrigin.y + _rect.height());
-		target->blitFrom(*displaySurface, srcRect, destRect);
+
+		initFallbackPalette();
+		target->blitFrom(*displaySurface, srcRect, destRect, _fallbackPalette.get());
 	}
 }
 
@@ -963,6 +965,13 @@ void MovieElement::stopSubtitles() {
 		_subtitles->stop();
 }
 
+void MovieElement::initFallbackPalette() {
+	if (!_fallbackPalette) {
+		const Palette &globalPalette = getRuntime()->getGlobalPalette();
+		_fallbackPalette = Common::ScopedPtr<Graphics::Palette>(new Graphics::Palette(globalPalette.getPalette(), globalPalette.kNumColors));
+	}
+}
+
 void MovieElement::onPauseStateChanged() {
 	VisualElement::onPauseStateChanged();
 
diff --git a/engines/mtropolis/elements.h b/engines/mtropolis/elements.h
index aee25dc8f84..2ba0e30975e 100644
--- a/engines/mtropolis/elements.h
+++ b/engines/mtropolis/elements.h
@@ -23,6 +23,7 @@
 #define MTROPOLIS_ELEMENTS_H
 
 #include "graphics/fontman.h"
+#include "graphics/palette.h"
 
 #include "mtropolis/data.h"
 #include "mtropolis/runtime.h"
@@ -120,6 +121,8 @@ private:
 
 	void stopSubtitles();
 
+	void initFallbackPalette();
+
 	MiniscriptInstructionOutcome scriptSetRange(MiniscriptThread *thread, const DynamicValue &value);
 	MiniscriptInstructionOutcome scriptSetRangeStart(MiniscriptThread *thread, const DynamicValue &value);
 	MiniscriptInstructionOutcome scriptSetRangeEnd(MiniscriptThread *thread, const DynamicValue &value);
@@ -173,6 +176,8 @@ private:
 	Common::SharedPtr<SubtitlePlayer> _subtitles;
 
 	Common::Array<int> _damagedFrames;
+
+	Common::ScopedPtr<Graphics::Palette> _fallbackPalette;
 };
 
 class ImageElement : public VisualElement {




More information about the Scummvm-git-logs mailing list