[Scummvm-cvs-logs] scummvm master -> 2dfbad8074dce96af03f3bf2927e9bdffc3a16ec

somaen einarjohants at gmail.com
Tue Jan 21 02:27:29 CET 2014


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:
2dfbad8074 WINTERMUTE: Avoid using Graphics::copyFrom to copy FMV-frames.


Commit: 2dfbad8074dce96af03f3bf2927e9bdffc3a16ec
    https://github.com/scummvm/scummvm/commit/2dfbad8074dce96af03f3bf2927e9bdffc3a16ec
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2014-01-20T17:25:18-08:00

Commit Message:
WINTERMUTE: Avoid using Graphics::copyFrom to copy FMV-frames.

copyFrom frees and reallocates the surface for every update, as long
as the dimensions and format stay the same, we can do with just a
memcpy.

This gives a tiny improvement in the update-part of the Theora-player
(on the order of a bit more than 1 second saved total in the 1:28 long
J.U.L.I.A.-intro)

Changed paths:
    engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
    engines/wintermute/video/video_theora_player.cpp



diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 9ec8573..73797f2 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -447,8 +447,14 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect,
 
 bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) {
 	_loaded = true;
-	_surface->free();
-	_surface->copyFrom(surface);
+	if (surface.format == _surface->format && surface.w == _surface->w && surface.h == _surface->h) {
+		const byte *src = (const byte*) surface.getBasePtr(0, 0);
+		byte *dst = (byte*) _surface->getBasePtr(0, 0);
+		memcpy(dst, src, surface.pitch * surface.h);
+	} else {
+		_surface->free();
+		_surface->copyFrom(surface);
+	}
 	if (hasAlpha) {
 		_alphaType = TransparentSurface::ALPHA_FULL;
 	} else {
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index 44eecf9..aedc9bf 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -305,8 +305,15 @@ bool VideoTheoraPlayer::update() {
 			if (!_theoraDecoder->endOfVideo() && _theoraDecoder->getTimeToNextFrame() == 0) {
 				const Graphics::Surface *decodedFrame = _theoraDecoder->decodeNextFrame();
 				if (decodedFrame) {
-					_surface.free();
-					_surface.copyFrom(*decodedFrame);
+					if (decodedFrame->format == _surface.format && decodedFrame->w == _surface.w && decodedFrame->h == _surface.h) {
+						const byte *src = (const byte*) decodedFrame->getBasePtr(0, 0);
+						byte *dst = (byte*) _surface.getBasePtr(0, 0);
+						memcpy(dst, src, _surface.pitch * _surface.h);
+					} else {
+						_surface.free();
+						_surface.copyFrom(*decodedFrame);
+					}
+
 					if (_texture) {
 						writeVideo();
 					}






More information about the Scummvm-git-logs mailing list