From 2ac1fdad321a510fdb10f01f89c32818a06488a3 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Mon, 29 Nov 2010 20:57:41 +0000 Subject: Revert "MOHAWK: Revert the screen cache since it has a huge performance hit, and is not needed as is." This reverts commit 291bea1858c12b8557aeb46e6f57dc701293c956. svn-id: r54624 --- engines/mohawk/graphics.cpp | 11 +++++++++-- engines/mohawk/graphics.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index ee1ffb26f1..5732c96d0d 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -138,6 +138,9 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) { _pictureFile.entries = NULL; + // Initialize our buffer + _mainScreen = new Graphics::Surface(); + _mainScreen->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat.bytesPerPixel); _dirtyScreen = false; } @@ -146,6 +149,9 @@ MystGraphics::~MystGraphics() { delete _jpegDecoder; delete _pictDecoder; delete[] _pictureFile.entries; + + _mainScreen->free(); + delete _mainScreen; } static const char* picFileNames[] = { @@ -267,9 +273,9 @@ void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Comm // Convert from bitmap coordinates to surface coordinates uint16 top = surface->h - src.top - height; - - _vm->_system->copyRectToScreen((byte *)surface->getBasePtr(src.left, top), surface->pitch, dest.left, dest.top, width, height); + for (uint16 i = 0; i < height; i++) + memcpy(_mainScreen->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel); // Mark the screen as dirty _dirtyScreen = true; @@ -282,6 +288,7 @@ void MystGraphics::copyImageToScreen(uint16 image, Common::Rect dest) { void MystGraphics::updateScreen() { if (_dirtyScreen) { // Only copy the buffer to the screen if it's dirty + _vm->_system->copyRectToScreen((byte *)_mainScreen->pixels, _mainScreen->pitch, 0, 0, _mainScreen->w, _mainScreen->h); _vm->_system->updateScreen(); _dirtyScreen = false; } diff --git a/engines/mohawk/graphics.h b/engines/mohawk/graphics.h index 75ffe12987..6942aba4f4 100644 --- a/engines/mohawk/graphics.h +++ b/engines/mohawk/graphics.h @@ -130,6 +130,7 @@ private: Common::File picFile; } _pictureFile; + Graphics::Surface *_mainScreen; bool _dirtyScreen; Graphics::PixelFormat _pixelFormat; }; -- cgit v1.2.3